Skip to content
Merged
Changes from 2 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 @@ -101,17 +101,6 @@ struct PaymentMethodsView: View {
) {
AttributedText(viewModel.learnMoreViewModel.learnMoreAttributedString)
}.padding(.horizontal)

NavigationLink(isActive: $showingCashAlert) {
CashPaymentTenderView(viewModel: CashPaymentTenderViewModel(total: viewModel.total, formattedTotal: viewModel.formattedTotal) { info in
Task { @MainActor in
await viewModel.markOrderAsPaidByCash(with: info)
dismiss()
}
})
} label: {
EmptyView()
}.hidden()
}

// Pushes content to the top
Expand Down Expand Up @@ -145,6 +134,15 @@ struct PaymentMethodsView: View {
}
.background(FullScreenCoverClearBackgroundView())
}
.navigationDestination(isPresented: $showingCashAlert) {
CashPaymentTenderView(viewModel: CashPaymentTenderViewModel(total: viewModel.total,
formattedTotal: viewModel.formattedTotal) { info in
Task { @MainActor in
await viewModel.markOrderAsPaidByCash(with: info)
dismiss()
}
})
}
.onAppear {
guard rootViewController != nil else {
return viewModel.logNoRootViewControllerError()
Expand Down Expand Up @@ -253,27 +251,47 @@ extension PaymentMethodsView {
}

// MARK: Previews
struct PaymentMethodsView_Preview: PreviewProvider {
static var previews: some View {
NavigationView {
PaymentMethodsView(viewModel: .init(total: "15.99", formattedTotal: "$15.99", flow: .orderPayment, channel: .storeManagement))
.navigationBarTitleDisplayMode(.inline)
}
.environment(\.colorScheme, .light)
.previewDisplayName("Light")
#Preview("Light") {
@Previewable @State var rootViewController = UIViewController()
NavigationView {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: as NavigationView is deprecated, would be nice to replace it with NavigationStack. Simply replacing it with NavigationStack seems to work. Similarly for other previews in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's very true, updated: 84d2e6a

PaymentMethodsView(
rootViewController: rootViewController,
viewModel: PaymentMethodsViewModel(total: "15.99",
formattedTotal: "$15.99",
flow: .orderPayment,
channel: .storeManagement)
)
.navigationBarTitleDisplayMode(.inline)
}
.environment(\.colorScheme, .light)
}

NavigationView {
PaymentMethodsView(viewModel: .init(total: "15.99", formattedTotal: "$15.99", flow: .orderPayment, channel: .storeManagement))
.navigationBarTitleDisplayMode(.inline)
}
.environment(\.colorScheme, .dark)
.previewDisplayName("Dark")
#Preview("Dark") {
@Previewable @State var rootViewController = UIViewController()
NavigationView {
PaymentMethodsView(
rootViewController: rootViewController,
viewModel: PaymentMethodsViewModel(total: "15.99",
formattedTotal: "$15.99",
flow: .orderPayment,
channel: .storeManagement)
)
.navigationBarTitleDisplayMode(.inline)
}
.environment(\.colorScheme, .dark)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unrelated to this PR, I think we could just keep one preview here since the differences are just the color scheme and accessibility font size which can be configured in SwiftUI previews. It's more worth having multiple previews when the data/states are different.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that sounds good to me. Updated: 84d2e6a

}

NavigationView {
PaymentMethodsView(viewModel: .init(total: "15.99", formattedTotal: "$15.99", flow: .orderPayment, channel: .storeManagement))
.navigationBarTitleDisplayMode(.inline)
}
.environment(\.sizeCategory, .accessibilityExtraExtraLarge)
.previewDisplayName("Accessibility")
#Preview("Accessibility") {
@Previewable @State var rootViewController = UIViewController()
NavigationView {
PaymentMethodsView(
rootViewController: rootViewController,
viewModel: PaymentMethodsViewModel(total: "15.99",
formattedTotal: "$15.99",
flow: .orderPayment,
channel: .storeManagement)
)
.navigationBarTitleDisplayMode(.inline)
}
.environment(\.sizeCategory, .accessibilityExtraExtraLarge)
}
Loading