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

Fixed bug where dismissing a presentedViewController would force RNSwipeViewController to unexpectedly revert to its centerViewController #14

Open
wants to merge 2 commits 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
8 changes: 8 additions & 0 deletions RNSwipeViewController/RNSwipeViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ extern NSString * const RNSwipeViewControllerCenterDidAppear;
*/
@property (assign, nonatomic) BOOL canTapOut;

/** Disable/Enable swiping to all other controllers besides the current one.

@see canShowLeft
@see canShowRight
@see canShowBottom
*/
@property (assign, nonatomic) BOOL swipingDisabled;

///---------------------------------------------------------------------------------------
/// @name Controller Delegates
///---------------------------------------------------------------------------------------
Expand Down
32 changes: 30 additions & 2 deletions RNSwipeViewController/RNSwipeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ - (void)viewDidLoad {
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self _layoutContainersAnimated:NO duration:0.f];
if (! self.visibleController.presentedViewController.isBeingDismissed) {
[super viewWillAppear:animated];
[self _layoutContainersAnimated:NO duration:0.f];
}
}

- (void)viewDidLayoutSubviews {
Expand Down Expand Up @@ -389,6 +391,32 @@ - (void)setBottomVisibleHeight:(CGFloat)bottomVisibleHeight {
}
}

- (void)setSwipingDisabled:(BOOL)swipingDisabled {

BOOL leftEnabled = ! swipingDisabled;
BOOL rightEnabled = ! swipingDisabled;
BOOL bottomEnabled = ! swipingDisabled;

switch (self.visibleState) {
case RNSwipeVisibleLeft:
leftEnabled = YES;
break;
case RNSwipeVisibleRight:
rightEnabled = YES;
break;
case RNSwipeVisibleBottom:
bottomEnabled = YES;
break;
case RNSwipeVisibleCenter:
break;
}
self.canShowLeft = leftEnabled;
self.canShowRight = rightEnabled;
self.canShowBottom = bottomEnabled;

_swipingDisabled = swipingDisabled;
}

#pragma mark - Getters

- (UIViewController*)visibleController {
Expand Down