Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit c42541b9 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Add contribution title, description and benefit texts

(cherry picked from commit bce5220219cb35ae5f66151c00930f152871ad0f)
parent 67ad2bfd
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -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,
@@ -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,
@@ -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,
@@ -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,
+42 −2
Original line number Diff line number Diff line
@@ -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
@@ -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(
@@ -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,
@@ -59,6 +67,7 @@ private fun ContributionHeaderView(
    title: String,
    description: String,
    modifier: Modifier = Modifier,
    benefits: ImmutableList<String> = persistentListOf(),
) {
    Column(
        modifier = modifier,
@@ -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,
        )
    }
}
+154 −0
Original line number Diff line number Diff line
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()
        }
    }
}
+65 −0
Original line number Diff line number Diff line
@@ -25,4 +25,69 @@
    <string name="funding_googleplay_contribution_error_unknown">Unknown error</string>
    <string name="funding_googleplay_contribution_error_purchase_failed">Purchase failed.</string>
    <string name="funding_googleplay_contribution_error_service_disconnected">Contributions are currently unavailable.</string>

    <string name="funding_googleplay_contribution_tfa_onetime_xs_title">Essential Contribution</string>
    <string name="funding_googleplay_contribution_tfa_onetime_s_title">Valued Contribution</string>
    <string name="funding_googleplay_contribution_tfa_onetime_m_title">Significant Contribution</string>
    <string name="funding_googleplay_contribution_tfa_onetime_l_title">Major Contribution</string>
    <string name="funding_googleplay_contribution_tfa_onetime_xl_title">Outstanding Contribution</string>
    <string name="funding_googleplay_contribution_tfa_onetime_xxl_title">Exceptional Contribution</string>

    <string name="funding_googleplay_contribution_tfa_onetime_xs_description">Your support keeps us moving forward! Even the smallest contributions create ripples of change, and we’re so grateful to have you on board.</string>
    <string name="funding_googleplay_contribution_tfa_onetime_s_description">You’re helping us make great things happen! By contributing at this level, you’re helping us take meaningful steps forward allowing us to continue growing.</string>
    <string name="funding_googleplay_contribution_tfa_onetime_m_description">Your contribution really shines! You’re playing a major role in advancing our mission, helping us reach important milestones and achieve a greater impact.</string>
    <string name="funding_googleplay_contribution_tfa_onetime_l_description">You’re a big reason we’re able to do what we do! Thanks to your generosity, we can take on bigger projects and reach new milestones together.</string>
    <string name="funding_googleplay_contribution_tfa_onetime_xl_description">Your support is truly inspiring! Thanks to your substantial contribution, we’re able to push boundaries, innovate, and make significant strides toward our goals.</string>
    <string name="funding_googleplay_contribution_tfa_onetime_xxl_description">You’re really helping us dream big!  Your incredible support empowers us to achieve the extraordinary, leaving a lasting impact on everything we do.</string>

    <string name="funding_googleplay_contribution_tfa_recurring_xs_title">Essential Monthly Contribution</string>
    <string name="funding_googleplay_contribution_tfa_recurring_s_title">Valued Monthly Contribution</string>
    <string name="funding_googleplay_contribution_tfa_recurring_m_title">Significant Monthly Contribution</string>
    <string name="funding_googleplay_contribution_tfa_recurring_l_title">Major Monthly Contribution</string>
    <string name="funding_googleplay_contribution_tfa_recurring_xl_title">Outstanding Monthly Contribution</string>
    <string name="funding_googleplay_contribution_tfa_recurring_xxl_title">Exceptional Monthly Contribution</string>

    <string name="funding_googleplay_contribution_tfa_recurring_xs_description">Your support drives us forward! Every contribution creates change—thank you!</string>
    <string name="funding_googleplay_contribution_tfa_recurring_s_description">Your contribution helps us grow and take meaningful steps forward—thank you!</string>
    <string name="funding_googleplay_contribution_tfa_recurring_m_description">Your contribution shines! You’re key to advancing our mission and achieving impact.</string>
    <string name="funding_googleplay_contribution_tfa_recurring_l_description">You’re a big reason we can do what we do! Your generosity helps us reach new milestones.</string>
    <string name="funding_googleplay_contribution_tfa_recurring_xl_description">Your support is inspiring! Your contribution helps us push boundaries and achieve our goals.</string>
    <string name="funding_googleplay_contribution_tfa_recurring_xxl_description">You’re helping us dream big! Your support empowers us to achieve extraordinary things.</string>

    <array name="funding_googleplay_contribution_tfa_recurring_xs_benefits">
        <item>A monthly, voluntary contribution</item>
        <item>Support the backbone of our efforts</item>
        <item>Keep us moving forward</item>
        <item>Contributions are not tax-deductible</item>
    </array>
    <array name="funding_googleplay_contribution_tfa_recurring_s_benefits">
        <item>A monthly, voluntary contribution</item>
        <item>Enable us to build new features</item>
        <item>Help us take meaningful steps forward</item>
        <item>Contributions are not tax-deductible</item>
    </array>
    <array name="funding_googleplay_contribution_tfa_recurring_m_benefits">
        <item>A monthly, voluntary contribution</item>
        <item>Play a major role in aiding our mission</item>
        <item>Support key improvements</item>
        <item>Contributions are not tax-deductible</item>
    </array>
    <array name="funding_googleplay_contribution_tfa_recurring_l_benefits">
        <item>A monthly, voluntary contribution</item>
        <item>Be a driving force behind our success</item>
        <item>Enable us to take on larger projects</item>
        <item>Contributions are not tax-deductible</item>
    </array>
    <array name="funding_googleplay_contribution_tfa_recurring_xl_benefits">
        <item>A monthly, voluntary contribution</item>
        <item>Enable us to make significant strides</item>
        <item>Help us push boundaries</item>
        <item>Contributions are not tax-deductible</item>
    </array>
    <array name="funding_googleplay_contribution_tfa_recurring_xxl_benefits">
        <item>A monthly, voluntary contribution</item>
        <item>Empower us to dream bigger</item>
        <item>Make our boldest ideas a reality</item>
        <item>Contributions are not tax-deductible</item>
    </array>
</resources>