From 898c6f1266a64fdf9e78bbe23ebb04dc91d3d09e Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 16 Oct 2026 21:07:45 +0400 Subject: [PATCH] ios, android, desktop: choose a badge on the website --- .../Badges/BadgesSupportSimplexView.swift | 32 ++++++++++--- .../views/badges/BadgesSupportSimplexView.kt | 47 ++++++++++++++----- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/apps/ios/Shared/Views/Badges/BadgesSupportSimplexView.swift b/apps/ios/Shared/Views/Badges/BadgesSupportSimplexView.swift index df13abdc97..97e91bfb69 100644 --- a/apps/ios/Shared/Views/Badges/BadgesSupportSimplexView.swift +++ b/apps/ios/Shared/Views/Badges/BadgesSupportSimplexView.swift @@ -45,15 +45,25 @@ struct BadgesSupportSimplexView: View { Spacer(minLength: 0) + // In-app purchase is not released: the badge is chosen on the site, and the code + // redeemed here. Revert this commit to restore the block below. + // VStack(spacing: 10) { + // chooseLevelButton() + // .padding(.vertical, 10) + // Group { + // if badgeBrowserAllowed { + // buyInBrowserButton() + // } else { + // RedeemCodeButton() + // } + // } + // .frame(height: 22) + // } VStack(spacing: 10) { - chooseLevelButton() + chooseBadgeOnSiteButton() .padding(.vertical, 10) Group { - if badgeBrowserAllowed { - buyInBrowserButton() - } else { - RedeemCodeButton() - } + RedeemCodeButton() } .frame(height: 22) } @@ -131,6 +141,16 @@ struct BadgesSupportSimplexView: View { } } + // In-app purchase is not released: delete with the commented block above to restore it. + private func chooseBadgeOnSiteButton() -> some View { + Button { + UIApplication.shared.open(URL(string: badgePageUrl)!) + } label: { + Text("Choose your badge") + } + .buttonStyle(OnboardingButtonStyle(isDisabled: false)) + } + private func buyInBrowserButton() -> some View { Button { UIApplication.shared.open(URL(string: badgePageUrl)!) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/badges/BadgesSupportSimplexView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/badges/BadgesSupportSimplexView.kt index f81d561120..c0e1c968b9 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/badges/BadgesSupportSimplexView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/badges/BadgesSupportSimplexView.kt @@ -63,18 +63,24 @@ fun BadgesSupportSimplexView(modalManager: ModalManager, unwindToDepth: Int) { Spacer(Modifier.weight(1f)) + // In-app purchase is not released: the badge is chosen on the site, and the code redeemed + // here. Revert this commit to restore the block below. + // Column(horizontalAlignment = Alignment.CenterHorizontally) { + // if (badgeStoreAvailable) { + // ChooseLevelButton(modalManager, unwindToDepth) + // if (badgeBrowserAllowed()) { + // BuyInBrowserTextButton() + // } else { + // RedeemCodeButton(modalManager, unwindToDepth) + // } + // } else { + // BuyInBrowserButton(modalManager, unwindToDepth) + // RedeemCodeButton(modalManager, unwindToDepth) + // } + // } Column(horizontalAlignment = Alignment.CenterHorizontally) { - if (badgeStoreAvailable) { - ChooseLevelButton(modalManager, unwindToDepth) - if (badgeBrowserAllowed()) { - BuyInBrowserTextButton() - } else { - RedeemCodeButton(modalManager, unwindToDepth) - } - } else { - BuyInBrowserButton(modalManager, unwindToDepth) - RedeemCodeButton(modalManager, unwindToDepth) - } + ChooseBadgeOnSiteButton(modalManager, unwindToDepth) + RedeemCodeButton(modalManager, unwindToDepth) } } } @@ -134,6 +140,25 @@ private fun BuyInBrowserTextButton() { ) } +// In-app purchase is not released: delete with the commented block above to restore it. +@Composable +private fun ChooseBadgeOnSiteButton(modalManager: ModalManager, unwindToDepth: Int) { + val uriHandler = LocalUriHandler.current + OnboardingActionButton( + modifier = if (appPlatform.isAndroid) Modifier.padding(horizontal = DEFAULT_ONBOARDING_HORIZONTAL_PADDING).fillMaxWidth() else Modifier.widthIn(min = 300.dp), + labelId = MR.strings.badges_choose_your_badge_title, + onboarding = null, + onclick = { + val linkReturns = appLinkSchemeRegistered() + uriHandler.openUriCatching(badgePageUrl(linkReturns)) + // with no scheme to bring the code back, the code is pasted into this screen, opened beside the browser + if (!linkReturns && !modalManager.hasModalOpen(ModalViewId.BADGE_REDEEM_CODE)) { + modalManager.showModal(id = ModalViewId.BADGE_REDEEM_CODE) { BadgesRedeemCodeView(modalManager, unwindToDepth) } + } + } + ) +} + @Composable private fun BuyInBrowserButton(modalManager: ModalManager, unwindToDepth: Int) { val uriHandler = LocalUriHandler.current