-
Notifications
You must be signed in to change notification settings - Fork 121
[WCiOS17] Update PaymentMethodsView to not use deprecated NavigationLink init
#16196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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() | ||
|
|
@@ -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 { | ||
| 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) | ||
|
||
| } | ||
|
|
||
| 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) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: as
NavigationViewis deprecated, would be nice to replace it withNavigationStack. Simply replacing it withNavigationStackseems to work. Similarly for other previews in this file.There was a problem hiding this comment.
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