damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit cdd5327829bebdb95e9f02af6237f2bc3842416f
parent e649c49981a26c121b9a81c10677dbdbe77004c7
Author: Daniel D’Aquino <daniel@daquino.me>
Date:   Tue, 30 Jan 2024 07:41:56 +0000

purple: disable apple IAP ui by default

We do not have Apple In-app purchases ready for the upcoming release.

This commit hides IAP UI/UX behind a developer feature flag which is off
by default, and shows a link inviting the user to visit the website to
learn more.

It also makes the link go to the normal Damus website.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Models/Purple/DamusPurple.swift | 6++++++
Mdamus/Models/UserSettingsStore.swift | 3+++
Mdamus/Views/Purple/DamusPurpleView.swift | 33+++++++++++++++++++--------------
Mdamus/Views/Settings/DeveloperSettingsView.swift | 3+++
4 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/damus/Models/Purple/DamusPurple.swift b/damus/Models/Purple/DamusPurple.swift @@ -31,6 +31,12 @@ class DamusPurple: StoreObserverDelegate { // TODO: On release, we could just replace this with `true` (or some other feature flag) return self.settings.enable_experimental_purple_api } + + // Whether to enable Apple In-app purchase support + var enable_purple_iap_support: Bool { + // TODO: When we have full support for Apple In-app purchases, we can replace this with `true` (or another feature flag) + return self.settings.enable_experimental_purple_iap_support + } func profile_purple_badge_info(pubkey: Pubkey) async -> UserBadgeInfo? { if let cached_result = self.starred_profiles_cache[pubkey] { diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift @@ -208,6 +208,9 @@ class UserSettingsStore: ObservableObject { @StringSetting(key: "purple_environment", default_value: .production) var purple_enviroment: DamusPurpleEnvironment + @Setting(key: "enable_experimental_purple_iap_support", default_value: false) + var enable_experimental_purple_iap_support: Bool + @Setting(key: "emoji_reactions", default_value: default_emoji_reactions) var emoji_reactions: [String] diff --git a/damus/Views/Purple/DamusPurpleView.swift b/damus/Views/Purple/DamusPurpleView.swift @@ -362,18 +362,20 @@ struct DamusPurpleView: View { var ProductStateView: some View { Group { - switch self.products { - case .failed: - ProductLoadError - case .loaded(let products): - if let purchased { - PurchasedView(purchased) - } else { - ProductsView(products) - } - case .loading: - ProgressView() - .progressViewStyle(.circular) + if damus_state.purple.enable_purple_iap_support { + switch self.products { + case .failed: + ProductLoadError + case .loaded(let products): + if let purchased { + PurchasedView(purchased) + } else { + ProductsView(products) + } + case .loading: + ProgressView() + .progressViewStyle(.circular) + } } } } @@ -457,8 +459,11 @@ struct DamusPurpleView: View { HStack { Spacer() Link( - NSLocalizedString("Learn more", comment: "Label for a link to the Damus Purple landing page"), - destination: damus_state.purple.environment.purple_landing_page_url() + damus_state.purple.enable_purple_iap_support ? + NSLocalizedString("Learn more about the features", comment: "Label for a link to the Damus website, to allow the user to learn more about the features of Purple") + : + NSLocalizedString("Coming soon! Visit our website to learn more", comment: "Label announcing Purple, and inviting the user to learn more on the website"), + destination: damus_state.purple.environment.damus_website_url() ) .foregroundColor(DamusColors.pink) .padding() diff --git a/damus/Views/Settings/DeveloperSettingsView.swift b/damus/Views/Settings/DeveloperSettingsView.swift @@ -34,6 +34,9 @@ struct DeveloperSettingsView: View { .tag(purple_environment.rawValue) } } + + Toggle("Enable experimental Purple In-app purchase support", isOn: $settings.enable_experimental_purple_iap_support) + .toggleStyle(.switch) } } }