Composables
Docs Login
Vela

Plans

package com.composables.vela

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.fillMaxWidth
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 com.composables.vela.components.Button
import com.composables.vela.components.ButtonVariant
import com.composables.vela.components.Page
import com.composables.vela.components.PlanCard
import com.composables.vela.components.PlanPrice
import com.composables.vela.components.Text
import com.composables.vela.theme.Icons
import com.composables.vela.theme.Space
import com.composables.vela.theme.Theme
import com.composables.vela.theme.X

@Composable
fun UpgradeScreen(
    navigateBack: () -> Unit,
    navigateToTerms: () -> Unit,
    navigateToPrivacyPolicy: () -> Unit,
    modifier: Modifier = Modifier,
) {
    fun subscribe(plan: String, annual: Boolean) {
        // start the purchase of the plan here
        navigateBack()
    }

    fun restorePurchases() {
        // restore previous purchases here
    }

    var plusAnnual by remember { mutableStateOf(true) }
    var proAnnual by remember { mutableStateOf(true) }
    Page(
        title = "Upgrade",
        onBack = navigateBack,
        backIcon = Icons.X,
        backLabel = "Close",
        modifier = modifier,
    ) {
        Column(verticalArrangement = Arrangement.spacedBy(Space * 2)) {
            Text("Get more from Vela", style = Theme.typography.display)
            Text(
                "You're on the Free plan. Upgrade for more messages, deeper models and projects.",
                color = Theme.colors.onBackgroundMuted,
            )
        }
        PlanCard(
            name = "Plus",
            pitch = "For everyday work and study",
            monthly = PlanPrice("$12", "per month"),
            annual = PlanPrice("$120", "per year", note = "Save 17%"),
            annualSelected = plusAnnual,
            onBillingChange = { plusAnnual = it },
            onSubscribe = { subscribe("Plus", plusAnnual) },
            featuresTitle = "Everything in Free, plus",
            features =
                listOf(
                    "Five times as many messages",
                    "Vela 4 Pro for complex work",
                    "Projects with files and instructions",
                    "Longer voice conversations",
                ),
        )
        PlanCard(
            name = "Pro",
            pitch = "For heavy daily use",
            monthly = PlanPrice("$30", "per month"),
            annual = PlanPrice("$300", "per year", note = "Save 17%"),
            annualSelected = proAnnual,
            onBillingChange = { proAnnual = it },
            onSubscribe = { subscribe("Pro", proAnnual) },
            featuresTitle = "Everything in Plus, plus",
            features =
                listOf(
                    "Twenty times the messages of Free",
                    "Priority when Vela is busy",
                    "Early access to new models",
                ),
        )
        Column(
            Modifier.fillMaxWidth(),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.spacedBy(Space),
        ) {
            Text(
                "Plans renew automatically until cancelled. Limits apply.",
                style = Theme.typography.caption,
                color = Theme.colors.onBackgroundMuted,
            )
            FlowRow(horizontalArrangement = Arrangement.Center) {
                Button(onClick = ::restorePurchases, variant = ButtonVariant.Ghost) {
                    Text("Restore purchases", style = Theme.typography.caption)
                }
                Button(onClick = navigateToTerms, variant = ButtonVariant.Ghost) {
                    Text("Terms", style = Theme.typography.caption)
                }
                Button(onClick = navigateToPrivacyPolicy, variant = ButtonVariant.Ghost) {
                    Text("Privacy Policy", style = Theme.typography.caption)
                }
            }
        }
    }
}

More screens from Vela

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.