Composables
Docs Login
Tally

Tally Pro

package com.composables.tally

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.composables.tally.components.Button
import com.composables.tally.components.ButtonVariant
import com.composables.tally.components.Icon
import com.composables.tally.components.Page
import com.composables.tally.components.PlanOption
import com.composables.tally.components.Text
import com.composables.tally.theme.CheckCircle
import com.composables.tally.theme.Icons
import com.composables.tally.theme.Space
import com.composables.tally.theme.Theme
import com.composables.tally.theme.X

private enum class ProPlan(
    val label: String,
    val price: String,
    val detail: String,
    val badge: String? = null,
) {
    Monthly("Monthly", "$4.99", "Billed monthly"),
    Annual("Annual", "$29.99", "$2.50 a month, billed yearly", "Save 50%"),
    Lifetime("Lifetime", "$59.99", "Pay once, keep it forever"),
}

private val proFeatures =
    listOf(
        "Unlimited habits",
        "Your full progress history",
        "Notes on every habit",
        "Reminders for every habit",
    )

@Composable
fun ProScreen(
    navigateBack: () -> Unit,
    navigateToTerms: () -> Unit,
    navigateToPrivacyPolicy: () -> Unit,
    modifier: Modifier = Modifier,
) {
    var plan by remember { mutableStateOf(ProPlan.Annual) }

    fun purchase() {
        // start the purchase here
        navigateBack()
    }

    fun restore() {
        // restore purchases here
        navigateBack()
    }

    Page(
        title = "Tally Pro",
        onBack = navigateBack,
        backIcon = Icons.X,
        backLabel = "Close",
        modifier = modifier,
        bottomBar = {
            Column(verticalArrangement = Arrangement.spacedBy(Space * 2)) {
                Button(onClick = ::purchase, modifier = Modifier.fillMaxWidth()) {
                    Text(
                        if (plan == ProPlan.Lifetime) "Buy for ${plan.price}"
                        else "Start 7-day free trial"
                    )
                }
                Text(
                    if (plan == ProPlan.Lifetime) "One payment. No subscription."
                    else
                        "Free for 7 days, then ${plan.price} per ${if (plan == ProPlan.Monthly) "month" else "year"}. Cancel anytime.",
                    style = Theme.typography.caption,
                    color = Theme.colors.onBackgroundMuted,
                    modifier = Modifier.align(Alignment.CenterHorizontally),
                )
            }
        },
    ) {
        Column(verticalArrangement = Arrangement.spacedBy(Space * 2)) {
            Text("Keep every streak going", style = Theme.typography.display)
            Text(
                "Tally Pro unlocks everything for the habits you care about.",
                color = Theme.colors.onBackgroundMuted,
            )
        }
        Column(verticalArrangement = Arrangement.spacedBy(Space * 3)) {
            proFeatures.forEach { feature ->
                Row(
                    verticalAlignment = Alignment.CenterVertically,
                    horizontalArrangement = Arrangement.spacedBy(Space * 3),
                ) {
                    Icon(
                        Icons.CheckCircle,
                        contentDescription = null,
                        modifier = Modifier.size(22.dp),
                        tint = Theme.colors.meadow,
                    )
                    Text(feature)
                }
            }
        }
        Column(
            Modifier.selectableGroup(),
            verticalArrangement = Arrangement.spacedBy(Space * 3),
        ) {
            ProPlan.entries.forEach { option ->
                PlanOption(
                    name = option.label,
                    price = option.price,
                    detail = option.detail,
                    selected = option == plan,
                    onClick = { plan = option },
                    badge = option.badge,
                )
            }
        }
        Row(
            Modifier.fillMaxWidth().padding(bottom = Space * 2),
            horizontalArrangement = Arrangement.Center,
        ) {
            Button(onClick = ::restore, variant = ButtonVariant.Ghost) { Text("Restore") }
            Button(onClick = navigateToTerms, variant = ButtonVariant.Ghost) { Text("Terms") }
            Button(onClick = navigateToPrivacyPolicy, variant = ButtonVariant.Ghost) {
                Text("Privacy")
            }
        }
    }
}

More screens from Tally

by Alex Styl

Search screens and components

Screen flows

Screens

UI Elements

One Android lesson, every Wednesday

Building Android apps?

What Alex learned building Android apps for 14 years, so you don't have to. Reads in under a minute.

Join 3,500+ Android developers. Unsubscribe any time.

You're subscribed

The next lesson lands in on Wednesday.