Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,7 @@ struct CurrencyCreationWizardScreen: View {
paymentMint: context.paymentMint
)
.environment(\.dismissParentContainer, {
// Sheet dismiss unmounts the wizard, taking the
// fullScreenCover with it as a single animation.
// Nilling the cover binding here would stage a separate
// cover-dismiss before the sheet animation; the @State
// is freed automatically when the wizard unmounts.
router.dismissSheet()
Self.dismissCreationFlow(router: router)
})
}
}
Expand All @@ -282,6 +277,17 @@ struct CurrencyCreationWizardScreen: View {
}
}

/// Unwinds the whole creation flow once the launch cover is done with it —
/// both the finished handoff and the failure dismissal come through here.
///
/// The flow is pushed onto the Wallet tab's stack, so it comes off by
/// popping that stack to its root. Naming the stack rather than using
/// `popToRoot()`'s topmost lookup keeps this working while the cover is up,
/// since the tab host clears `activeTabStack` when it disappears.
static func dismissCreationFlow(router: AppRouter) {
router.popToRoot(on: AppRouter.Destination.currencyCreationWizard.owningStack)
}

// MARK: - Navigation

private func advance() {
Expand Down
43 changes: 43 additions & 0 deletions FlipcashTests/Navigation/CurrencyCreationFlowDismissalTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// CurrencyCreationFlowDismissalTests.swift
// FlipcashTests
//

import SwiftUI
import Testing
import FlipcashCore
@testable import Flipcash

@MainActor
@Suite("Currency Creation Flow Dismissal")
struct CurrencyCreationFlowDismissalTests {

/// Pushes the flow the way the Wallet tile does: summary, then wizard.
private func routerInCreationFlow() -> AppRouter {
let router = AppRouter()
router.activeTabStack = .balance
router.push(.currencyCreationSummary)
router.push(.currencyCreationWizard)
return router
}

@Test("Finishing the launch cover pops the creation flow off the Wallet stack")
func dismissCreationFlow_popsHostStack() {
let router = routerInCreationFlow()

CurrencyCreationWizardScreen.dismissCreationFlow(router: router)

#expect(router[.balance].isEmpty, "the wizard must not stay mounted under the dismissed cover")
}

@Test("Unwinds even though the cover hid the tab host and cleared the active stack")
func dismissCreationFlow_withoutActiveTabStack_popsHostStack() {
let router = routerInCreationFlow()
// `HomeTabView.onDisappear` clears this while the fullScreenCover is up.
router.activeTabStack = nil

CurrencyCreationWizardScreen.dismissCreationFlow(router: router)

#expect(router[.balance].isEmpty, "the unwind must not depend on the tab host still being mounted")
}
}