Closed snowtema closed 2 years ago
Hi @snowtema
Sorry, I don't think I fully understood the question. Do you want to replace the view controller in the second tab?
Hi @ekazaev, thank you for the fast response! Yeah, exactly
@snowtema at the end of the flow you can call something like this:
let step = StepAssembly(
finder: ClassFinder(options: .currentAllStack),
factory: NewSecondTabControllerFactory())
.using(UITabBarController.add(at: 1, replacing: true))
.from(tabBarScreen)
.assemble()
You can write your own more advanced UITabBarController.add(...)
action the will take instead of index a finder of the view controller that needs to be replaced to be independent from the numeric indexes.
One thing to keep in mind, is that if which view controller should appear in the second tab depends on some flag, you need to cover it in the TabBarFactory, so that on the next application start TabBarFactory build itself with a proper view controller in the second tab. It probably worth to consider to write a custom TabBarFactory instead of using CompleteFactoryAssembly so that it will have that logic inside.
Thank you a lot! Will do this soon
@ekazaev It works perfectly! But is there any way to replace view controller for UITabBarController
without navigating to it immediately? Like when the user finished some flow and then manually opens the second tab, he will see a new view controller there.
@snowtema Then youll have to do it manually. Basically youll have to do what the router would just without navigation. Use a finder to find a TabBarController then use a factory and replace it.
I use this code to init tab bar with 3 tabs –
First
,Second
andProfile
:After the user opens the
Second
tab bar the first time and finished some flow, how can I change in runtimeSecond
flow for the second tab to another flow, likeSecond_v2
?