Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added demo method that will partially reveal buttons below cell #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MGSwipeTableCell/MGSwipeTableCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ typedef NS_ENUM(NSInteger, MGSwipeEasingFunction) {
-(void) setSwipeOffset:(CGFloat)offset animated: (BOOL) animated completion:(nullable void(^)(BOOL finished)) completion;
-(void) setSwipeOffset:(CGFloat)offset animation: (nullable MGSwipeAnimation *) animation completion:(nullable void(^)(BOOL finished)) completion;
-(void) expandSwipe: (MGSwipeDirection) direction animated: (BOOL) animated;
-(void) demoSwipe: (MGSwipeDirection) direction expandDistance: (NSInteger) distance;

/** Refresh method to be used when you want to update the cell contents while the user is swiping */
-(void) refreshContentView;
Expand Down
21 changes: 21 additions & 0 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,27 @@ -(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated comple
}
}

-(void) demoSwipe: (MGSwipeDirection) direction expandDistance: (NSInteger) distance {
CGFloat s = direction == MGSwipeDirectionLeftToRight ? 1.0 : -1.0;
MGSwipeExpansionSettings* expSetting = direction == MGSwipeDirectionLeftToRight ? _leftExpansion : _rightExpansion;

if(!_activeExpansion) {
[self createSwipeViewIfNeeded];
_allowSwipeLeftToRight = _leftButtons.count > 0;
_allowSwipeRightToLeft = _rightButtons.count > 0;
UIView * buttonsView = direction == MGSwipeDirectionLeftToRight ? _leftView : _rightView;

if (buttonsView) {
__weak MGSwipeButtonsView * expansionView = direction == MGSwipeDirectionLeftToRight ? _leftView : _rightView;
__weak MGSwipeTableCell * weakself = self;
[self setSwipeOffset:distance * s * expSetting.threshold * 2 animation:expSetting.triggerAnimation completion:^(BOOL finished){
[expansionView endExpansionAnimated:YES];
[weakself setSwipeOffset:0 animated:YES completion:nil];
}];
}
}
}

-(void) expandSwipe: (MGSwipeDirection) direction animated: (BOOL) animated
{
CGFloat s = direction == MGSwipeDirectionLeftToRight ? 1.0 : -1.0;
Expand Down