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

How could I implement a custom action for a UITabBarItem? #74

Closed
jonathansolorzn opened this issue Aug 29, 2018 · 6 comments
Closed

How could I implement a custom action for a UITabBarItem? #74

jonathansolorzn opened this issue Aug 29, 2018 · 6 comments

Comments

@jonathansolorzn
Copy link

I reviewed the code from RxFlowDemo, but there's no example of how to handle a custom action from a UITabBarController.

To handle a custom action we commonly implement the following function from UITabBarControllerDelegate:

    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        
        if viewControllers?.index(of: viewController) == 2 {
            // TODO: Open camera from TabCoordinator
            return false
        }
        
        return true
    }

How would this be done in RxFlow?

@twittemb
Copy link
Collaborator

You could do this in multiple ways:

  • your stepper could also be your tabBarController's delegate and it could call "self.steps.accept(Steps.needCamera)" to trigger the navigation.
  • if your tabBarController's delegate is also your TabBar ViewController and this ViewController has a ViewModel registered as a Stepper you could call a "cameraClicked" function on your ViewModel and this function could call "self.steps.accept(Steps.needCamera)" to trigger the navigation

@jonathansolorzn
Copy link
Author

Could it be possible for you to provide code example of the most appropriate way of doing it following your library style?

@twittemb
Copy link
Collaborator

twittemb commented Sep 3, 2018

Hi @felixsolorzano

I would do something like I did in the demo app for the Settings button in the Navigation Bar of the first tab. This Settings button is handled by the Stepper of the WishlistFlow.

Take a look at the WishlistStepper inside the WishlistFlow.

@twittemb
Copy link
Collaborator

twittemb commented Sep 7, 2018

Hi @felixsolorzano

Have you looked at the demo app ?

@twittemb
Copy link
Collaborator

Hi @felixsolorzano

May I close this issue ?

@jonathansolorzn
Copy link
Author

As you said, the stepper could be the tabBarController's delegate, the only thing I'm kinda disagree is that it's a non rx way to do it.

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

No branches or pull requests

2 participants