Skip to content

Commit

Permalink
Merge pull request #8377 from wmontwe/add-funding-contribution-texts
Browse files Browse the repository at this point in the history
Add funding contribution texts
  • Loading branch information
cketti authored Oct 21, 2024
2 parents 67ad2bf + c42541b commit f4f38be
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kotlinx.collections.immutable.persistentListOf
internal object FakeData {

val recurringContribution = RecurringContribution(
id = "monthly_subscription_50",
id = "contribution_tfa_monthly_m",
title = "Monthly subscription: $50",
description = "Monthly subscription for $50",
price = 5000L,
Expand All @@ -16,42 +16,42 @@ internal object FakeData {

val recurringContributions = persistentListOf(
RecurringContribution(
id = "monthly_subscription_250",
id = "contribution_tfa_monthly_xxl",
title = "Monthly subscription: $250",
description = "Monthly subscription for $250",
price = 25000L,
priceFormatted = "250 $",
),
RecurringContribution(
id = "monthly_subscription_140",
id = "contribution_tfa_monthly_xl",
title = "Monthly subscription: $140",
description = "Monthly subscription for $140",
price = 14000L,
priceFormatted = "140 $",
),
RecurringContribution(
id = "monthly_subscription_80",
id = "contribution_tfa_monthly_l",
title = "Monthly subscription: $80",
description = "Monthly subscription for $80",
price = 8000L,
priceFormatted = "80 $",
),
RecurringContribution(
id = "monthly_subscription_50",
id = "contribution_tfa_monthly_m",
title = "Monthly subscription: $50",
description = "Monthly subscription for $50",
price = 5000L,
priceFormatted = "50 $",
),
RecurringContribution(
id = "monthly_subscription_25",
id = "contribution_tfa_monthly_s",
title = "Monthly subscription: $25",
description = "Monthly subscription for $25",
price = 2500L,
priceFormatted = "25 $",
),
RecurringContribution(
id = "monthly_subscription_15",
id = "contribution_tfa_monthly_xs",
title = "Monthly subscription: $15",
description = "Monthly subscription for $15",
price = 1500L,
Expand All @@ -60,7 +60,7 @@ internal object FakeData {
)

val oneTimeContribution = OneTimeContribution(
id = "one_time_payment_50",
id = "contribution_tfa_onetime_m",
title = "One time payment: $50",
description = "One time payment for $50",
price = 5000L,
Expand All @@ -69,42 +69,42 @@ internal object FakeData {

val oneTimeContributions = persistentListOf(
OneTimeContribution(
id = "one_time_payment_250",
id = "contribution_tfa_onetime_xxl",
title = "One time payment: $250",
description = "One time payment for $250",
price = 25000L,
priceFormatted = "250 $",
),
OneTimeContribution(
id = "one_time_payment_140",
id = "contribution_tfa_onetime_xl",
title = "One time payment: $140",
description = "One time payment for $140",
price = 14000L,
priceFormatted = "140 $",
),
OneTimeContribution(
id = "one_time_payment_80",
id = "contribution_tfa_onetime_l",
title = "One time payment: $80",
description = "One time payment for $80",
price = 8000L,
priceFormatted = "80 $",
),
OneTimeContribution(
id = "one_time_payment_50",
id = "contribution_tfa_onetime_m",
title = "One time payment: $50",
description = "One time payment for $50",
price = 5000L,
priceFormatted = "50 $",
),
OneTimeContribution(
id = "one_time_payment_25",
id = "contribution_tfa_onetime_s",
title = "One time payment: $25",
description = "One time payment for $25",
price = 2500L,
priceFormatted = "25 $",
),
OneTimeContribution(
id = "one_time_payment_15",
id = "contribution_tfa_onetime_xs",
title = "One time payment: $15",
description = "One time payment for $15",
price = 1500L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import androidx.compose.animation.AnimatedContent
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.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icon
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons
import app.k9mail.core.ui.compose.designsystem.atom.image.FixedScaleImage
import app.k9mail.core.ui.compose.designsystem.atom.text.TextBodyMedium
import app.k9mail.core.ui.compose.designsystem.atom.text.TextHeadlineSmall
Expand All @@ -21,6 +25,8 @@ import app.k9mail.feature.funding.googleplay.R
import app.k9mail.feature.funding.googleplay.domain.entity.Contribution
import app.k9mail.feature.funding.googleplay.ui.contribution.image.GoldenHearthSunburst
import app.k9mail.feature.funding.googleplay.ui.contribution.image.HearthSunburst
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

@Composable
internal fun ContributionHeader(
Expand All @@ -36,11 +42,13 @@ internal fun ContributionHeader(
val contribution = purchasedContribution!!
ContributionHeaderView(
logo = GoldenHearthSunburst,
title = contribution.title,
description = contribution.description,
title = ContributionIdStringMapper.mapToContributionTitle(contribution.id),
description = ContributionIdStringMapper.mapToContributionDescription(contribution.id),
benefits = ContributionIdStringMapper.mapToContributionBenefits(contribution.id),
modifier = modifier,
)
}

false -> {
ContributionHeaderView(
logo = HearthSunburst,
Expand All @@ -59,6 +67,7 @@ private fun ContributionHeaderView(
title: String,
description: String,
modifier: Modifier = Modifier,
benefits: ImmutableList<String> = persistentListOf(),
) {
Column(
modifier = modifier,
Expand All @@ -85,8 +94,39 @@ private fun ContributionHeaderView(
textAlign = TextAlign.Center,
)

if (benefits.isNotEmpty()) {
Column(
verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
) {
benefits.forEach { benefit ->
ContributionBenefit(
benefit = benefit,
)
}
}
}

TextBodyMedium(
text = description,
)
}
}

@Composable
private fun ContributionBenefit(
benefit: String,
modifier: Modifier = Modifier,
) {
Row(
modifier = modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(MainTheme.spacings.half),
) {
Icon(
imageVector = Icons.Filled.Dot,
modifier = Modifier.size(MainTheme.sizes.small),
)
TextBodyMedium(
text = benefit,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package app.k9mail.feature.funding.googleplay.ui.contribution

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import app.k9mail.feature.funding.googleplay.R
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList

// Ids need to be kept in sync with ContributionIdProvider.kt
internal object ContributionIdStringMapper {

@Composable
fun mapToContributionTitle(contributionId: String): String {
return when (contributionId) {
"contribution_tfa_onetime_xs" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_xs_title,
)

"contribution_tfa_onetime_s" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_s_title,
)

"contribution_tfa_onetime_m" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_m_title,
)

"contribution_tfa_onetime_l" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_l_title,
)

"contribution_tfa_onetime_xl" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_xl_title,
)

"contribution_tfa_onetime_xxl" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_xxl_title,
)

"contribution_tfa_monthly_xs" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_xs_title,
)

"contribution_tfa_monthly_s" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_s_title,
)

"contribution_tfa_monthly_m" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_m_title,
)

"contribution_tfa_monthly_l" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_l_title,
)

"contribution_tfa_monthly_xl" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_xl_title,
)

"contribution_tfa_monthly_xxl" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_xxl_title,
)

else -> throw IllegalArgumentException("Unknown contribution ID: $contributionId")
}
}

@Composable
fun mapToContributionDescription(contributionId: String): String {
return when (contributionId) {
"contribution_tfa_onetime_xs" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_xs_description,
)

"contribution_tfa_onetime_s" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_s_description,
)

"contribution_tfa_onetime_m" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_m_description,
)

"contribution_tfa_onetime_l" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_l_description,
)

"contribution_tfa_onetime_xl" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_xl_description,
)

"contribution_tfa_onetime_xxl" -> stringResource(
R.string.funding_googleplay_contribution_tfa_onetime_xxl_description,
)

"contribution_tfa_monthly_xs" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_xs_description,
)

"contribution_tfa_monthly_s" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_s_description,
)

"contribution_tfa_monthly_m" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_m_description,
)

"contribution_tfa_monthly_l" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_l_description,
)

"contribution_tfa_monthly_xl" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_xl_description,
)

"contribution_tfa_monthly_xxl" -> stringResource(
R.string.funding_googleplay_contribution_tfa_recurring_xxl_description,
)

else -> throw IllegalArgumentException("Unknown contribution ID: $contributionId")
}
}

@Composable
fun mapToContributionBenefits(contributionId: String): ImmutableList<String> {
return when (contributionId) {
"contribution_tfa_monthly_xs" -> stringArrayResource(
R.array.funding_googleplay_contribution_tfa_recurring_xs_benefits,
).toImmutableList()

"contribution_tfa_monthly_s" -> stringArrayResource(
R.array.funding_googleplay_contribution_tfa_recurring_s_benefits,
).toImmutableList()

"contribution_tfa_monthly_m" -> stringArrayResource(
R.array.funding_googleplay_contribution_tfa_recurring_m_benefits,
).toImmutableList()

"contribution_tfa_monthly_l" -> stringArrayResource(
R.array.funding_googleplay_contribution_tfa_recurring_l_benefits,
).toImmutableList()

"contribution_tfa_monthly_xl" -> stringArrayResource(
R.array.funding_googleplay_contribution_tfa_recurring_xl_benefits,
).toImmutableList()

"contribution_tfa_monthly_xxl" -> stringArrayResource(
R.array.funding_googleplay_contribution_tfa_recurring_xxl_benefits,
).toImmutableList()

else -> persistentListOf()
}
}
}
Loading

0 comments on commit f4f38be

Please sign in to comment.