UIColor colorWithPercentage(nfloat percentage) { UIColor color = DefaultColor ?? UIColor.Clear; if (percentage > ShortTrigger && ModeForStateRightShort != SwipeTableCellMode.None) { color = ColorRightShort; } if (percentage > LongTrigger && ModeForStateRightLong != SwipeTableCellMode.None) { color = ColorRightLong; } if (percentage < ShortTrigger.Neg() && ModeForStateLeftShort != SwipeTableCellMode.None) { color = ColorLeftShort; } if (percentage < LongTrigger.Neg() && ModeForStateLeftLong != SwipeTableCellMode.None) { color = ColorLeftLong; } return(color); }
SwipeTableViewCellState stateWithPercentage(nfloat percentage) { SwipeTableViewCellState state = SwipeTableViewCellState.None; if (percentage >= ShortTrigger && ModeForStateRightShort != SwipeTableCellMode.None) { state = SwipeTableViewCellState.StateRightShort; } if (percentage >= LongTrigger && ModeForStateRightLong != SwipeTableCellMode.None) { state = SwipeTableViewCellState.StateRightLong; } if (percentage <= ShortTrigger.Neg() && ModeForStateLeftShort != SwipeTableCellMode.None) { state = SwipeTableViewCellState.StateLeftShort; } if (percentage <= LongTrigger.Neg() && ModeForStateLeftLong != SwipeTableCellMode.None) { state = SwipeTableViewCellState.StateLeftLong; } return(state); }
void slideViewWithPercentage(nfloat percentage, UIView view, bool isDragging) { if (view == null) { return; } var position = new CGPoint(0.0F, 0.0F); position.Y = cell.Bounds.Height / 2.0F; var hft = ShortTrigger / 2.0F; // half first trigger var width = cell.Bounds.Width; if (isDragging) { if (percentage >= 0 && percentage < ShortTrigger) { position.X = offsetWithPercentage(hft, width); } else if (percentage >= ShortTrigger) { position.X = offsetWithPercentage(percentage - hft, width); } else if (percentage < 0 && percentage >= ShortTrigger.Neg()) { position.X = width - offsetWithPercentage(hft, width); } else if (percentage < ShortTrigger.Neg()) { position.X = width + offsetWithPercentage(percentage + hft, width); } } else { if (direction == SwipeTableViewCellDirection.Right) { position.X = offsetWithPercentage(hft, width); } else if (direction == SwipeTableViewCellDirection.Left) { position.X = width - offsetWithPercentage(hft, width); } else { return; } } var activeViewSize = view.Bounds.Size; var activeViewFrame = new CGRect( position.X - (activeViewSize.Width / 2.0F), position.Y - (activeViewSize.Height / 2.0F), activeViewSize.Width, activeViewSize.Height); slidingView.Frame = activeViewFrame.Integral(); }
nfloat alphaWithPercentage(nfloat percentage) { nfloat alpha; if (percentage >= 0 && percentage < ShortTrigger) { alpha = percentage / ShortTrigger; } else if (percentage < 0 && percentage > ShortTrigger.Neg()) { alpha = (nfloat)Math.Abs(percentage / ShortTrigger); } else { alpha = 1.0F; } return(alpha); }