Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update support us footer on PremiumHome screen #296

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -45,7 +45,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 +195,22 @@ private fun PremiumHomeScreen(
}

else -> {
SupportUsNotice(
visible = state.showSupportUsNotice,
onSupportPrimal = onSupportPrimal,
)
if (state.showSupportUsNotice) {
when (state.membership.isPrimalLegendTier()) {
true -> {
SupportUsNoticeLegend(
visible = state.membership.donatedBtc != null,
donatedSats = state.membership.donatedBtc?.toSats()?.toLong() ?: 0L,
onSupportPrimal = onSupportPrimal,
)
}
false -> {
SupportUsNoticePremium(
onSupportPrimal = onSupportPrimal,
)
}
}
}
}
}
}
Expand Down Expand Up @@ -230,9 +244,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 +265,6 @@ private fun SupportUsNotice(visible: Boolean, onSupportPrimal: () -> Unit) {
Text(
modifier = Modifier
.clickable(
enabled = visible,
onClick = onSupportPrimal,
),
style = AppTheme.typography.bodyMedium,
Expand All @@ -275,3 +288,59 @@ private fun SupportUsNotice(visible: Boolean, onSupportPrimal: () -> Unit) {
}
}
}

@Composable
private fun SupportUsNoticeLegend(
visible: Boolean,
donatedSats: Long,
onSupportPrimal: () -> Unit,
) {
Column(
modifier = Modifier.alpha(if (visible) 1.0f else 0.0f),
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