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

Swiping does not evaluate whether a view controller should get selected #76

Closed
DarkDust opened this issue Dec 13, 2019 · 3 comments
Closed

Comments

@DarkDust
Copy link
Contributor

In the tab bar controller of one of our apps, we've implemented tabBarController(_:, shouldSelect:) to prevent some view controllers from getting selected. However, the swipe gesture still allows to select them.

So deriving the index of the next view controller to select should take this into account.

Unfortunately, we also need to execute code during tabBarController(_:, shouldSelect:) that should not be executed during the swipe check. This is because we want to detect a top onto the tab bar item without switching to it and AFAIK the only way to achieve that is to override tabBarController(_:, shouldSelect:).

So I propose to introduce a method func swipeableTabBarController(_ tabBarController: SwipeableTabBarController, shouldSelectInteractively viewController: UIViewController) -> Bool which is called during the swiping check. Its default implementation just asks delegate?.tabBarController?(tabBarController, shouldSelect: viewController) but subclasses may override it to do a different decision that with tapping.

@marcosgriselli
Copy link
Owner

@DarkDust I really hate to decline user's proposals but this is a specific requirement for your app/product and I don't think others will be benefited from the increased complexity to support this.

Anyway, this library will rarely get new features/changes. #73 is the only critical fix that comes to mind, so it's fine to use your fork with your specific requirements.

@DarkDust
Copy link
Contributor Author

No problem. I still think tabBarController(_:, shouldSelect:) should be respected, but I agree that my solution is introducing a feature very few (if any) users would need.

@marcosgriselli
Copy link
Owner

I'm going to close this issue and the related PR for the moment. If we find that this is a use case for other library users we can reevaluate it. Thanks for the work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants