Skip to content

Commit

Permalink
Merge pull request MortimerGoro#95 from frankfle/master
Browse files Browse the repository at this point in the history
Add completion handlers to convenience show/hide methods
  • Loading branch information
MortimerGoro committed Apr 21, 2015
2 parents d20694a + 6d3a7c8 commit 433157f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions MGSwipeTableCell/MGSwipeTableCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ typedef NS_ENUM(NSInteger, MGSwipeExpansionLayout) {

/** Utility methods to show or hide swipe buttons programmatically */
-(void) hideSwipeAnimated: (BOOL) animated;
-(void) hideSwipeAnimated: (BOOL) animated completion:(void(^)()) completion;
-(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated;
-(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated completion:(void(^)()) completion;
-(void) setSwipeOffset:(CGFloat)offset animated: (BOOL) animated completion:(void(^)()) completion;
-(void) expandSwipe: (MGSwipeDirection) direction animated: (BOOL) animated;

Expand Down
12 changes: 11 additions & 1 deletion MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -865,12 +865,22 @@ -(void) updateSwipe: (CGFloat) offset
self.swipeOffset = offset;
}

-(void) hideSwipeAnimated: (BOOL) animated completion:(void(^)()) completion
{
[self setSwipeOffset:0 animated:animated completion:completion];
}

-(void) hideSwipeAnimated: (BOOL) animated
{
[self setSwipeOffset:0 animated:animated completion:nil];
}

-(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated
{
[self showSwipe:direction animated:animated completion:nil];
}

-(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated completion:(void(^)()) completion
{
[self createSwipeViewIfNeeded];
_allowSwipeLeftToRight = _leftButtons.count > 0;
Expand All @@ -879,7 +889,7 @@ -(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated

if (buttonsView) {
CGFloat s = direction == MGSwipeDirectionLeftToRight ? 1.0 : -1.0;
[self setSwipeOffset:buttonsView.bounds.size.width * s animated:animated completion:nil];
[self setSwipeOffset:buttonsView.bounds.size.width * s animated:animated completion:completion];
}
}

Expand Down

0 comments on commit 433157f

Please sign in to comment.