hyperoslo / Tabby

⛩ A fancy tabbar
Other
103 stars 14 forks source link

Feature intercepting tab bar selections #9

Closed zenangst closed 7 years ago

zenangst commented 8 years ago

I think it could be useful to be able to intercept a navigation before it happens. Play with the idea that you have an item in your tab bar that actually leaves the application, then you don't want that to switch out the controller and to show and empty one when you get back into your application.

We can use Facebook and Facebook Messenger as an example, if you tap that item, you don't navigate inside Facebook, you are transported to Messenger. When you come back to Facebook, it is exactly like you left it.

I don't think this would be to hard to achieve if we change the delegate method on TabbyController to return a boolean value. If it is set to true, it would change, if false, then it is up to the developer to decide what is suppose to happen when a user taps the item.

So instead of this; https://github.com/hyperoslo/Tabby/blob/master/Sources/TabbyController.swift#L8

func tabbyDidPress(item: TabbyBarItem)

You would have something like this;

func tabbyDidPress(item: TabbyBarItem) -> Bool
zenangst commented 8 years ago

Or you could add a property on the item that you add to tabby to indicate what type of item it is.

enum TabBarItemType {
   case .Internal, .External
}
onmyway133 commented 8 years ago

The TabBarItemType approach sounds nifty, but the delegate approach seems to be more flexible I think

RamonGilabert commented 8 years ago

All right, so I added a Behavior that will reside in every TabBarItem. Such behavior has two possibilities: systematic that is the one that Tabby offers, or custom, which is your one. It defaults to systematic, if you set to custom, nothing will happen.

zenangst commented 8 years ago

🚀 🚀 🚀 🚀