-
Notifications
You must be signed in to change notification settings - Fork 404
Close button modifier #5804
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
base: main
Are you sure you want to change the base?
Close button modifier #5804
Conversation
|
Hey @MojtabaHs! Thanks for opening a PR when you found something you wanted improved. I noticed this is for our V1 version of paywalls, which we deprecated a while ago. In our V2 of paywalls, we allow you to delay the visibility of the close button via the editor. Have you tried giving our new paywalls a shot yet? |
|
JZDesign I'm using the v2. This new change works for the loading page in v2 in addition to the actual v1 paywallView. I couldn't find any way to hide the close button placeholder in the v2 except for this change. Am I missing something? |
Hmm... Maybe I misread the code… Looks like it's only applying to the V1 view to me. I'll look again. But if you are using paywalls v2, find the button with a navigate back action, then you'll find this at the bottom of the properties pane.
|
Yeap, and I can even remove the button completely remotely with the editor (which I did 💪). But since we need a seamless loading screen, I've found that introducing an environment variable to override the hardcoded behavior is the best way with the minimal changes to the current one. |
Ah, if you want a seamless loading screen, you could not present the paywall at all until it's loaded: MyView().task {
isLoading = true
Purchases.shared
.getOfferings { _, error in
isLoading = false
if let error {
handleError(error)
} else {
displayPaywall = true
}
}
}I'll chat with the team about this change though. |

There are a bunch of methods to display the paywall, including:
presentPaywallIfNeededmodifierPaywallViewwith configuration and presenting it manuallyPaywallViewwith arguments and presenting it manuallyBut only some of them have the ability to hide or show the
closeButtonsince it is hardcoded into thePaywallView's initializer and cannot be reached from the helpers like thepresentPaywallIfNeeded. Also, it is not how SwiftUI is designed.So I have introduced a modifier called
purchaseDisplayCloseButtonso users can decide to hide/show the button anywhere they need to.As an example, we can do this now:
I've also made it optional, so they can
nilout this override to let the library use its default value if needed.