mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-20 08:02:24 +00:00
ios, android, desktop: choose a badge on the website
This commit is contained in:
@@ -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)!)
|
||||
|
||||
+36
-11
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user