Skip to content

Commit

Permalink
Update support us footer on PremiumHome screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmedalijaK committed Feb 3, 2025
1 parent c2f6674 commit 3bdf7ce
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ data class MembershipStatusResponse(
@SerialName("renews_on") val renewsOn: Long? = null,
@SerialName("origin") val origin: String? = null,
@SerialName("edited_shoutout") val editedShoutout: String? = null,
@SerialName("donated_btc") val donatedBtc: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ data class PremiumMembership(
val renewsOn: Long? = null,
val origin: String? = null,
val editedShoutout: String? = null,
val donatedBtc: String? = null,
) {
fun isExpired() = expiresOn != null && Clock.System.now().epochSeconds > expiresOn
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
Expand All @@ -45,7 +44,9 @@ import net.primal.android.premium.ui.PremiumBadge
import net.primal.android.premium.ui.PrimalPremiumTable
import net.primal.android.premium.ui.toHumanReadableString
import net.primal.android.premium.utils.isPremiumFreeTier
import net.primal.android.premium.utils.isPrimalLegendTier
import net.primal.android.theme.AppTheme
import net.primal.android.wallet.utils.CurrencyConversionUtils.toSats

@Composable
fun PremiumHomeScreen(
Expand Down Expand Up @@ -193,10 +194,21 @@ private fun PremiumHomeScreen(
}

else -> {
SupportUsNotice(
visible = state.showSupportUsNotice,
onSupportPrimal = onSupportPrimal,
)
if (state.showSupportUsNotice) {
when (state.membership.isPrimalLegendTier()) {
true -> {
SupportUsNoticeLegend(
donatedSats = state.membership.donatedBtc?.toSats()?.toLong() ?: 0L,
onSupportPrimal = onSupportPrimal,
)
}
false -> {
SupportUsNoticePremium(
onSupportPrimal = onSupportPrimal,
)
}
}
}
}
}
}
Expand Down Expand Up @@ -230,9 +242,9 @@ private fun BottomBarButton(
}

@Composable
private fun SupportUsNotice(visible: Boolean, onSupportPrimal: () -> Unit) {
private fun SupportUsNoticePremium(onSupportPrimal: () -> Unit) {
Column(
modifier = Modifier.alpha(if (visible) 1.0f else 0.0f),
modifier = Modifier,
verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Expand All @@ -251,7 +263,6 @@ private fun SupportUsNotice(visible: Boolean, onSupportPrimal: () -> Unit) {
Text(
modifier = Modifier
.clickable(
enabled = visible,
onClick = onSupportPrimal,
),
style = AppTheme.typography.bodyMedium,
Expand All @@ -275,3 +286,55 @@ private fun SupportUsNotice(visible: Boolean, onSupportPrimal: () -> Unit) {
}
}
}

@Composable
private fun SupportUsNoticeLegend(donatedSats: Long, onSupportPrimal: () -> Unit) {
Column(
modifier = Modifier,
verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Row {
Text(
color = AppTheme.extraColorScheme.onSurfaceVariantAlt2,
text = stringResource(id = R.string.legend_contribution_title) + " ",
style = AppTheme.typography.bodyMedium,
)
Text(
modifier = Modifier
.clickable(
onClick = onSupportPrimal,
),
style = AppTheme.typography.bodyMedium,
fontWeight = FontWeight.SemiBold,
text = buildAnnotatedString {
withStyle(
style = SpanStyle(
color = AppTheme.colorScheme.onBackground,
),
) {
append(donatedSats.let { "%,d sats".format(it) })
}
},
)
}
if (donatedSats > 0L) {
Text(
color = AppTheme.extraColorScheme.onSurfaceVariantAlt2,
text = stringResource(id = R.string.legend_support_appreciation),
style = AppTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
)
}
Text(
modifier = Modifier
.clickable(
onClick = onSupportPrimal,
),
color = AppTheme.colorScheme.secondary,
text = stringResource(id = R.string.legend_contribute_more),
style = AppTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import net.primal.android.premium.home.PremiumHomeContract.UiEvent
import net.primal.android.premium.home.PremiumHomeContract.UiState
import net.primal.android.premium.legend.domain.asLegendaryCustomization
import net.primal.android.premium.repository.PremiumRepository
import net.primal.android.premium.utils.isPrimalLegendTier
import net.primal.android.profile.repository.ProfileRepository
import net.primal.android.user.accounts.active.ActiveAccountStore
import net.primal.android.user.repository.UserRepository
Expand Down Expand Up @@ -131,7 +130,7 @@ class PremiumHomeViewModel @Inject constructor(
val clientConfigShowSupport = premiumRepository.shouldShowSupportUsNotice()
setState {
copy(
showSupportUsNotice = clientConfigShowSupport && !membership.isPrimalLegendTier(),
showSupportUsNotice = clientConfigShowSupport,
)
}
} catch (error: WssException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class PremiumRepository @Inject constructor(
recurring = this.recurring,
origin = this.origin,
editedShoutout = this.editedShoutout,
donatedBtc = this.donatedBtc,
)
}
}
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@

<string name="premium_support_primal_title">Support Primal</string>

<string name="legend_contribution_title">Your contribution to Primal:</string>
<string name="legend_support_appreciation">Thank you for your support! 💜🫂</string>
<string name="legend_contribute_more">Want to contribute more?</string>

<string name="premium_become_legend_primal_title">Primal Legend</string>
<string name="premium_become_legend_intro_description">The Legend tier was created to recognize users who have made a significant\ncontribution to Primal.</string>
<string name="premium_become_legend_intro_subtitle">Donate $1000 or more to gain:</string>
Expand Down

0 comments on commit 3bdf7ce

Please sign in to comment.