@@ -32,7 +32,12 @@ final class BlazeCampaignListHostingController: UIHostingController<BlazeCampaig
3232 super. init ( rootView: BlazeCampaignListView ( viewModel: viewModel) )
3333
3434 rootView. onCreateCampaign = { [ weak self] productID in
35- self ? . startCampaignCreation ( productID: productID)
35+ self ? . startCampaignCoordinator ( productID: productID)
36+ }
37+
38+ rootView. onShowIntro = { [ weak self] in
39+ guard self ? . coordinator == nil else { return }
40+ self ? . startCampaignCoordinator ( showsIntro: true )
3641 }
3742 }
3843
@@ -45,14 +50,14 @@ final class BlazeCampaignListHostingController: UIHostingController<BlazeCampaig
4550 super. viewDidAppear ( animated)
4651 if startsCampaignCreationOnAppear {
4752 startsCampaignCreationOnAppear = false
48- startCampaignCreation ( )
53+ startCampaignCoordinator ( )
4954 }
5055 }
5156}
5257
5358/// Private helper
5459private extension BlazeCampaignListHostingController {
55- func startCampaignCreation ( productID: Int64 ? = nil ) {
60+ func startCampaignCoordinator ( productID: Int64 ? = nil , showsIntro : Bool = false ) {
5661 guard let navigationController else {
5762 return
5863 }
@@ -61,7 +66,7 @@ private extension BlazeCampaignListHostingController {
6166 siteURL: viewModel. siteURL,
6267 productID: productID,
6368 source: . campaignList,
64- shouldShowIntro: viewModel . shouldShowIntroView ,
69+ shouldShowIntro: showsIntro ,
6570 navigationController: navigationController,
6671 onCampaignCreated: { [ weak self] in
6772 self ? . viewModel. didCreateCampaign ( )
@@ -104,6 +109,7 @@ struct BlazeCampaignListView: View {
104109 @ObservedObject private var viewModel : BlazeCampaignListViewModel
105110
106111 var onCreateCampaign : ( Int64 ? ) -> Void = { _ in }
112+ var onShowIntro : ( ) -> Void = { }
107113
108114 init ( viewModel: BlazeCampaignListViewModel ) {
109115 self . viewModel = viewModel
@@ -155,9 +161,12 @@ struct BlazeCampaignListView: View {
155161 } ) { url in
156162 detailView ( url: url)
157163 }
158- . onChange ( of: viewModel. shouldShowIntroView) { shouldShow in
164+ . onChange ( of: viewModel. shouldShowIntroView) { _, shouldShow in
165+ /// Hack: since the campaign creation coordinator takes care of the intro modal,
166+ /// the view triggers creating coordinator in the hosting controller
167+ /// and manually sets shouldShowIntroView to false.
159168 if shouldShow {
160- onCreateCampaign ( nil )
169+ onShowIntro ( )
161170 viewModel. shouldShowIntroView = false
162171 }
163172 }
0 commit comments