Skip to content

Commit

Permalink
Add AOSP message on extend subscription screen
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarIlic committed Nov 21, 2024
1 parent 11dd594 commit ed941a0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package net.primal.android.premium.buying.purchase

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -39,11 +42,13 @@ import kotlinx.coroutines.launch
import net.primal.android.R
import net.primal.android.core.compose.AvatarThumbnail
import net.primal.android.core.compose.NostrUserText
import net.primal.android.core.compose.PrimalLoadingSpinner
import net.primal.android.core.compose.PrimalTopAppBar
import net.primal.android.core.compose.button.PrimalFilledButton
import net.primal.android.core.compose.findActivity
import net.primal.android.core.compose.icons.PrimalIcons
import net.primal.android.core.compose.icons.primaliconpack.ArrowBack
import net.primal.android.core.utils.isGoogleBuild
import net.primal.android.premium.buying.PremiumBuyingContract
import net.primal.android.premium.ui.PremiumPrimalNameTable
import net.primal.android.premium.ui.toGetSubscriptionString
Expand Down Expand Up @@ -156,6 +161,7 @@ fun PremiumPurchaseStage(
if (activity != null) {
BuyPremiumButtons(
modifier = Modifier.padding(horizontal = 12.dp),
loading = state.loading,
hasActiveSubscription = state.hasActiveSubscription,
subscriptions = state.subscriptions,
onBuySubscription = { subscription ->
Expand Down Expand Up @@ -211,6 +217,7 @@ private fun MoreInfoPromoCodeRow(
fun BuyPremiumButtons(
modifier: Modifier,
hasActiveSubscription: Boolean,
loading: Boolean,
subscriptions: List<SubscriptionProduct>,
onBuySubscription: (SubscriptionProduct) -> Unit,
onRestoreSubscription: () -> Unit,
Expand Down Expand Up @@ -243,12 +250,40 @@ fun BuyPremiumButtons(
)
}
} else {
subscriptions.forEach {
BuyPremiumButton(
startText = it.toGetSubscriptionString(),
endText = it.toPricingString(),
onClick = { onBuySubscription(it) },
)
when {
subscriptions.isEmpty() -> {
Box(
modifier = Modifier.height(144.dp),
contentAlignment = Alignment.Center,
) {
if (loading) {
PrimalLoadingSpinner(size = 32.dp)
} else {
Text(
modifier = Modifier
.wrapContentSize()
.padding(horizontal = 16.dp),
text = when {
isGoogleBuild() -> stringResource(id = R.string.premium_google_play_not_available)
else -> stringResource(id = R.string.premium_google_play_not_available_aosp)
},
textAlign = TextAlign.Center,
style = AppTheme.typography.bodySmall,
color = AppTheme.extraColorScheme.onSurfaceVariantAlt1,
)
}
}
}

else -> {
subscriptions.forEach {
BuyPremiumButton(
startText = it.toGetSubscriptionString(),
endText = it.toPricingString(),
onClick = { onBuySubscription(it) },
)
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<string name="premium_find_primal_name_button">Find Primal Name</string>
<string name="premium_cancel_button">Cancel</string>
<string name="premium_google_play_not_available">Unable to connect to the Google Play Store. Check your Google account and try again.</string>
<string name="premium_google_play_not_available_aosp">Google Play services are not available. You can use the Primal web app to buy Primal Premium.</string>

<string name="premium_primal_name_title">Find Primal Name</string>
<string name="premium_primal_name_search_button">Search</string>
Expand Down

0 comments on commit ed941a0

Please sign in to comment.