Skip to content

Commit

Permalink
Fix toolbar appearing when empty
Browse files Browse the repository at this point in the history
  • Loading branch information
NSExceptional committed Mar 30, 2021
1 parent c37270e commit 8f9a6e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Classes/Core/Controllers/FLEXNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ - (void)_setDelegate:(id)delegate;
@interface FLEXNavigationController ()
@property (nonatomic, readonly) BOOL toolbarWasHidden;
@property (nonatomic) BOOL waitingToAddTab;
@property (nonatomic, readonly) BOOL canShowToolbar;
@property (nonatomic) BOOL didSetupPendingDismissButtons;
@property (nonatomic) UISwipeGestureRecognizer *navigationBarSwipeGesture;
@end
Expand Down Expand Up @@ -99,6 +100,10 @@ - (void)dismissAnimated {
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}

- (BOOL)canShowToolbar {
return self.topViewController.toolbarItems.count;
}

- (void)addNavigationBarItemsToViewController:(UINavigationItem *)navigationItem {
if (!self.presentingViewController) {
return;
Expand Down Expand Up @@ -156,7 +161,7 @@ - (void)handleNavigationBarTap:(UIGestureRecognizer *)sender {
}

if (sender.state == UIGestureRecognizerStateRecognized) {
if (self.toolbarHidden) {
if (self.toolbarHidden && self.canShowToolbar) {
[self setToolbarHidden:NO animated:YES];
}
}
Expand All @@ -172,7 +177,7 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)g1 shouldBeRequiredToFailByGest

- (void)_gestureRecognizedInteractiveHide:(UIPanGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateRecognized) {
BOOL show = self.topViewController.toolbarItems.count;
BOOL show = self.canShowToolbar;
CGFloat yTranslation = [sender translationInView:self.view].y;
CGFloat yVelocity = [sender velocityInView:self.view].y;
if (yVelocity > 2000) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/Controllers/FLEXTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ - (void)viewDidLoad {
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;

// Toolbar
self.navigationController.toolbarHidden = NO;
self.navigationController.toolbarHidden = self.toolbarItems.count > 0;
self.navigationController.hidesBarsOnSwipe = YES;

// On iOS 13, the root view controller shows it's search bar no matter what.
Expand Down

0 comments on commit 8f9a6e8

Please # to comment.