-
Notifications
You must be signed in to change notification settings - Fork 329
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
[Customer Center]: fix navigation when embedded in NavigationStack
#4622
base: main
Are you sure you want to change the base?
Conversation
NavigationStack
NavigationStack
NavigationStack
NavigationStack
NavigationStack
@vegaro hope this is helpful! Can you take it from here to the finish line if it is? |
RevenueCatUI/CustomerCenter/Views/CompatibilityNavigationStack.swift
Outdated
Show resolved
Hide resolved
…s env variable from swiftUI
RevenueCatUI/CustomerCenter/Views/CompatibilityNavigationStack.swift
Outdated
Show resolved
Hide resolved
fileprivate init( | ||
viewModel: CustomerCenterViewModel, | ||
mode: CustomerCenterPresentationMode = CustomerCenterPresentationMode.default | ||
) { |
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.
Btw, do we know if there is some agreed standard on about this kind of formatting?
I see you've changed from
init(param1: Type1,
param2: Type2)
to
init(
param1: Type1,
param2: Type2
)
Whereas I prefer the former, I don't have any problem with agreeing on the latter. But perhaps we should all stick to the same style?
Fixes the navigation issues for Customer Center when presented through a NavigationStack.
Solves the issue by adding an extra optional parameter that you use when showing
CustomerCenterView
in aNavigationStack
:The Problem:
When presenting the Customer Center in a navigation stack, if we add another one, we kinda break navigation. I reproduced this in a very, very simple SwiftUI app:
What happens is that you go into customer center, it flashes but then automatically dismisses as soon as it loads, because the internal navigation stack and the external one kinda fight each other. If you try to tap again, it errors out.
The Solution
The solution is actually dead simple - if we're already in a
NavigationStack
, we don't create a new one.What I don't love about this solution is that we do kind of give the consumer the responsibility of passing in this parameter correctly, but I tried my best to find ways around it to auto-detect and couldn't come up with something reliable.
And it doesn't feel that complicated of a thing to pass in.
Still to be done: