public void setSwipeGestureWithView( UIView view, UIColor color, SwipeTableCellMode mode, SwipeTableViewCellState state, SwipeCompletionBlock completionBlock) { if (view == null || color == null) { return; } // Depending on the state we assign the attributes if ((state & SwipeTableViewCellState.StateRightShort) == SwipeTableViewCellState.StateRightShort) { CompletionBlockRightShort = completionBlock; ViewRightShort = view; ColorRightShort = color; ModeForStateRightShort = mode; } if ((state & SwipeTableViewCellState.StateRightLong) == SwipeTableViewCellState.StateRightLong) { CompletionBlockRightLong = completionBlock; ViewRightLong = view; ColorRightLong = color; ModeForStateRightLong = mode; } if ((state & SwipeTableViewCellState.StateLeftShort) == SwipeTableViewCellState.StateLeftShort) { CompletionBlockLeftShort = completionBlock; ViewLeftShort = view; ColorLeftShort = color; ModeForStateLeftShort = mode; } if ((state & SwipeTableViewCellState.StateLeftLong) == SwipeTableViewCellState.StateLeftLong) { CompletionBlockLeftLong = completionBlock; ViewLeftLong = view; ColorLeftLong = color; ModeForStateLeftLong = mode; } }
void executeCompletionBlock() { SwipeTableViewCellState state = stateWithPercentage((float)currentPercentage); SwipeTableCellMode mode = SwipeTableCellMode.None; SwipeCompletionBlock completionBlock = null; switch (state) { case SwipeTableViewCellState.StateRightShort: mode = ModeForStateRightShort; completionBlock = CompletionBlockRightShort; break; case SwipeTableViewCellState.StateRightLong: mode = ModeForStateRightLong; completionBlock = CompletionBlockRightLong; break; case SwipeTableViewCellState.StateLeftShort: mode = ModeForStateLeftShort; completionBlock = CompletionBlockLeftShort; break; case SwipeTableViewCellState.StateLeftLong: mode = ModeForStateLeftLong; completionBlock = CompletionBlockLeftLong; break; default: break; } if (completionBlock != null) { completionBlock(cell, state, mode); } }
void handlePanGestureRecognizer() { if (!ShouldDrag || isExited) { return; } var state = this.State; var translation = TranslationInView(cell); var velocity = VelocityInView(cell); nfloat percentage; if (contentScreenshotView == null) { percentage = percentageWithOffset(0, cell.Bounds.Width); } else { percentage = percentageWithOffset(contentScreenshotView.Frame.X, cell.Bounds.Width); } var animationDuration = animationDurationWithVelocity(velocity); direction = directionWithPercentage(percentage); if (state == UIGestureRecognizerState.Began || state == UIGestureRecognizerState.Changed) { dragging = true; setupSwipingView(); var center = new CGPoint(contentScreenshotView.Center.X + translation.X, contentScreenshotView.Center.Y); contentScreenshotView.Center = center; animateWithOffset(contentScreenshotView.Frame.GetMinX()); SetTranslation(new CGPoint(0.0F, 0.0F), cell); // Notifying the handler that we are dragging with an offset percentage if (SwipeWithPercentage != null) { SwipeWithPercentage(cell, percentage); } } else if (state == UIGestureRecognizerState.Ended || state == UIGestureRecognizerState.Cancelled) { dragging = false; activeView = viewWithPercentage(percentage); currentPercentage = percentage; SwipeTableViewCellState cellState = stateWithPercentage(percentage); SwipeTableCellMode cellMode = SwipeTableCellMode.None; if (cellState == SwipeTableViewCellState.StateRightShort && ModeForStateRightShort != SwipeTableCellMode.None) { cellMode = ModeForStateRightShort; } else if (cellState == SwipeTableViewCellState.StateRightLong && ModeForStateRightLong != SwipeTableCellMode.None) { cellMode = ModeForStateRightLong; } else if (cellState == SwipeTableViewCellState.StateLeftShort && ModeForStateLeftShort != SwipeTableCellMode.None) { cellMode = ModeForStateLeftShort; } else if (cellState == SwipeTableViewCellState.StateLeftLong && ModeForStateLeftLong != SwipeTableCellMode.None) { cellMode = ModeForStateLeftLong; } if (cellMode == SwipeTableCellMode.Exit && direction != SwipeTableViewCellDirection.Center) { moveWithDuration(animationDuration, direction); } else { swipeToOriginWithCompletion(executeCompletionBlock); } // We notify the handler that we just ended swiping. if (DidEndSwiping != null) { DidEndSwiping(cell); } } }
public void SetSwipeGestureWithView(UIView view, UIColor color, SwipeTableCellMode mode, SwipeTableViewCellState state, SwipeCompletionBlock completionBlock) { gr.setSwipeGestureWithView(view, color, mode, state, completionBlock); }