rundfunk47 / stinsen

Coordinators in SwiftUI. Simple, powerful and elegant.
MIT License
822 stars 87 forks source link

TabBar: present modal view from tabbar item #88

Open Luur opened 1 year ago

Luur commented 1 year ago

Hi everyone,

First of all, thank you for the great framework.

I have a question. Is it possible to present the modal view from tabbar item? If yes, how can I do it? In the app I'm working on, I need to force users to log in before they can reach a specific tabbar item.

LePips commented 1 year ago

I left a comment on this earlier and deleted it as I misunderstood the request.

Sort of, however is that what you should do? Somewhere in your code you store your session and authenticated state and the coordinator should not be concerned with that. Nonetheless, it is possible with the onTapped action in the @Route property wrapper.

Here is a minimal example of that: https://pastebin.com/xkpLbDpC

However, I don't think that's a proper implementation as the view should present the modal if unauthenticated.

Here is a minimal example of that: https://pastebin.com/we7p2Twy

However, there's a bug I experience some times when the router won't do anything so I should track that down as I experience it in my app but haven't bothered with it.

For reference, the Fidelity app has a similar flow.

Luur commented 1 year ago

Hey, thank you very much for your response. I caught the idea. However, I do like your ideas from deleted comment. I'm going to discuss it with the UX designer to find which approach will suit us better.