globalesim: Purchase/Pricing tabs, expandable carriers
- Commit
562c6d6d49fb9076de7c4bdae9c77504c689db83- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-24 18:44 UTC (1 month ago)
- Parents
f445616
Diff
globalesim/src/main/java/com/vayunmathur/globalesim/Navigation.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/Navigation.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/Navigation.ktindex e78510ad34..cf78499843 100644--- a/globalesim/src/main/java/com/vayunmathur/globalesim/Navigation.kt+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/Navigation.kt@@ -1,59 +1,37 @@ package com.vayunmathur.globalesim import android.content.Intent+import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.runtime.Composable+import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.platform.LocalContext import androidx.core.net.toUri import com.vayunmathur.globalesim.platform.EsimViewModel import com.vayunmathur.globalesim.ui.BudgetScreen import com.vayunmathur.globalesim.ui.HomeScreen import com.vayunmathur.globalesim.ui.InstallScreen-import com.vayunmathur.globalesim.ui.RatesScreen+import com.vayunmathur.globalesim.ui.PricingScreen import com.vayunmathur.globalesim.ui.TransferScreen+import com.vayunmathur.library.ui.IconGlobe+import com.vayunmathur.library.ui.IconSim+import com.vayunmathur.library.ui.PagerTab+import com.vayunmathur.library.ui.TabStyle+import com.vayunmathur.library.ui.TabbedPagerScaffold import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.rememberNavBackStack+import kotlinx.coroutines.launch @Composable fun Navigation(viewModel: EsimViewModel) {- val backStack = rememberNavBackStack<Route>(Route.Home)- val context = LocalContext.current+ val backStack = rememberNavBackStack<Route>(Route.Tabs) MainNavigation(backStack) {- entry<Route.Home> {- HomeScreen(- state = viewModel.state,- onTopUp = viewModel::topUp,- onCreateEsim = viewModel::createEsim,- onStartCardPurchase = viewModel::startCardPurchase,- onCardPurchaseDone = {- viewModel.clearPendingPurchase()- viewModel.refreshAll()- },- onStartCryptoPurchase = { cents ->- viewModel.startCryptoPurchase(cents) { url ->- context.startActivity(Intent(Intent.ACTION_VIEW, url.toUri()))- }- },- onCheckCryptoStatus = {- viewModel.checkCryptoStatus { status ->- if (status == "finished") viewModel.refreshAll()- }- },- onClearCryptoInvoice = viewModel::clearPendingInvoice,+ entry<Route.Tabs> {+ EsimTabs(+ viewModel = viewModel, onOpenInstall = { backStack.add(Route.Install) },- onOpenRates = { backStack.add(Route.Rates) }, onOpenBudget = { backStack.add(Route.Budget) }, onOpenTransfer = { backStack.add(Route.Transfer) },- onRefresh = viewModel::refreshAll,- onDismissError = viewModel::dismissError,- )- }- entry<Route.Rates> {- RatesScreen(- state = viewModel.state,- onNavigateBack = { backStack.pop() },- onRefresh = viewModel::refreshRates,- onDismissError = viewModel::dismissError, ) } entry<Route.Install> {@@ -68,7 +46,7 @@ fun Navigation(viewModel: EsimViewModel) { state = viewModel.state, onTransferOut = viewModel::transferOut, onTransferIn = { oldId, code ->- viewModel.transferIn(oldId, code) { backStack.reset(Route.Home) }+ viewModel.transferIn(oldId, code) { backStack.reset(Route.Tabs) } }, onNavigateBack = { backStack.pop() }, )@@ -83,3 +61,55 @@ fun Navigation(viewModel: EsimViewModel) { } } }++/**+ * The two bottom-nav tabs: Purchase (your eSIM + top-ups) and Pricing+ * (searchable per-country rates). Install, Transfer, and Budget push on+ * top as ordinary routes.+ */+@Composable+private fun EsimTabs(+ viewModel: EsimViewModel,+ onOpenInstall: () -> Unit,+ onOpenBudget: () -> Unit,+ onOpenTransfer: () -> Unit,+) {+ val context = LocalContext.current+ val pagerState = rememberPagerState(pageCount = { 2 })+ val tabs = listOf(+ PagerTab("Purchase", { IconSim() }) {+ HomeScreen(+ state = viewModel.state,+ onTopUp = viewModel::topUp,+ onCreateEsim = viewModel::createEsim,+ onStartCardPurchase = viewModel::startCardPurchase,+ onCardPurchaseDone = {+ viewModel.clearPendingPurchase()+ viewModel.refreshAll()+ },+ onStartCryptoPurchase = { cents ->+ viewModel.startCryptoPurchase(cents) { url ->+ context.startActivity(Intent(Intent.ACTION_VIEW, url.toUri()))+ }+ },+ onCheckCryptoStatus = {+ viewModel.checkCryptoStatus { status ->+ if (status == "finished") viewModel.refreshAll()+ }+ },+ onClearCryptoInvoice = viewModel::clearPendingInvoice,+ onOpenInstall = onOpenInstall,+ onOpenBudget = onOpenBudget,+ onOpenTransfer = onOpenTransfer,+ onDismissError = viewModel::dismissError,+ )+ },+ PagerTab("Pricing", { IconGlobe() }) {+ PricingScreen(+ state = viewModel.state,+ onDismissError = viewModel::dismissError,+ )+ },+ )+ TabbedPagerScaffold(tabs = tabs, pagerState = pagerState, tabStyle = TabStyle.BottomNav)+}
globalesim/src/main/java/com/vayunmathur/globalesim/Route.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/Route.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/Route.ktindex ca59eede52..fef45cfa5b 100644--- a/globalesim/src/main/java/com/vayunmathur/globalesim/Route.kt+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/Route.kt@@ -5,15 +5,11 @@ import kotlinx.serialization.Serializable @Serializable sealed interface Route : NavKey {- /** Home: your eSIM status + wallet + top-up. */+ /** Tab host: Purchase + Pricing. */ @Serializable- data object Home : Route+ data object Tabs : Route - /** Per-country rate list (what each GB deducts where you travel). */- @Serializable- data object Rates : Route-- /** Install detail: QR + handoff (reissues the same activation code). */+ /** Install: direct LPA handoff (reissues the same activation code). */ @Serializable data object Install : Route
globalesim/src/main/java/com/vayunmathur/globalesim/data/api/EsimDtos.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/data/api/EsimDtos.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/data/api/EsimDtos.ktindex c9a0fe662e..026893a32e 100644--- a/globalesim/src/main/java/com/vayunmathur/globalesim/data/api/EsimDtos.kt+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/data/api/EsimDtos.kt@@ -1,5 +1,6 @@ package com.vayunmathur.globalesim.data.api +import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable /**@@ -10,106 +11,141 @@ import kotlinx.serialization.Serializable * Product model: one global eSIM per anonymous account. The user tops up * USD credit; data deducts from the on-SIM wallet at the local per-country * rate. Credit never expires.+ *+ * Wire format is snake_case (server convention) — every field carries an+ * explicit @SerialName so client renames can never silently break the+ * contract (kotlinx.serialization drops unknown keys, so a missing+ * SerialName decodes to defaults with no error). */ @Serializable-data class RegisterRequest(val accountId: String)+data class RegisterRequest(@SerialName("account_id") val accountId: String) @Serializable-data class RegisterResponse(val ok: Boolean = false)+data class RegisterResponse(+ @SerialName("ok") val ok: Boolean = false,+ @SerialName("profile") val profile: ProfileDto? = null,+) @Serializable data class RateDto(- val countryCode: String,- val countryName: String,+ @SerialName("country_code") val countryCode: String,+ @SerialName("country_name") val countryName: String, /** Integer USD cents per GB. Integer math only — no float money. */- val pricePerGbUsdCents: Long,+ @SerialName("price_per_gb_usd_cents") val pricePerGbUsdCents: Long,+ /** Per-carrier breakdown, cheapest first. */+ @SerialName("networks") val networks: List<NetworkDto> = emptyList(),+)++@Serializable+data class NetworkDto(+ @SerialName("operator") val operator: String,+ @SerialName("price_per_gb_usd_cents") val pricePerGbUsdCents: Long, ) @Serializable-data class RatesResponse(val rates: List<RateDto> = emptyList())+data class RatesResponse(@SerialName("rates") val rates: List<RateDto> = emptyList()) @Serializable-data class AccountRequest(val accountId: String)+data class AccountRequest(@SerialName("account_id") val accountId: String) /** The account's single global eSIM (null when not yet provisioned). */ @Serializable data class ProfileDto(- val iccid: String,- val status: String,- val activationCode: String = "",- val smdpAddress: String = "",+ @SerialName("iccid") val iccid: String,+ @SerialName("status") val status: String,+ @SerialName("activation_code") val activationCode: String = "",+ @SerialName("smdp_address") val smdpAddress: String = "", /** On-SIM wallet balance in USD cents. */- val walletUsdCents: Long = 0,+ @SerialName("wallet_usd_cents") val walletUsdCents: Long = 0, ) @Serializable-data class StatusResponse(val profile: ProfileDto? = null)+data class StatusResponse(@SerialName("profile") val profile: ProfileDto? = null) @Serializable data class TopUpRequest(- val accountId: String,+ @SerialName("account_id") val accountId: String, /** USD cents to move from budget to the on-SIM wallet. */- val amountCents: Long,+ @SerialName("amount_cents") val amountCents: Long, /** Client-minted UUIDv4 per tap; the server dedupes replays. */- val idempotencyKey: String,+ @SerialName("idempotency_key") val idempotencyKey: String, ) @Serializable data class TopUpResponse(- val walletUsdCents: Long = 0,- val budgetUsdCents: Long = 0,+ @SerialName("wallet_usd_cents") val walletUsdCents: Long = 0,+ @SerialName("budget_usd_cents") val budgetUsdCents: Long = 0, ) @Serializable-data class ManageRequest(val accountId: String, val iccid: String)+data class ManageRequest(+ @SerialName("account_id") val accountId: String,+ @SerialName("iccid") val iccid: String,+) @Serializable-data class ManageResponse(val ok: Boolean = false)+data class ManageResponse(@SerialName("ok") val ok: Boolean = false) @Serializable-data class TransferOutRequest(val accountId: String)+data class TransferOutRequest(@SerialName("account_id") val accountId: String) @Serializable-data class TransferOutResponse(val transferCode: String = "")+data class TransferOutResponse(@SerialName("transfer_code") val transferCode: String = "") @Serializable-data class TransferInRequest(val oldAccountId: String, val code: String, val newAccountId: String)+data class TransferInRequest(+ @SerialName("old_account_id") val oldAccountId: String,+ @SerialName("code") val code: String,+ @SerialName("new_account_id") val newAccountId: String,+) @Serializable-data class TransferInResponse(val ok: Boolean = false)+data class TransferInResponse(@SerialName("ok") val ok: Boolean = false) @Serializable data class BudgetResponse( /** User-paid credit pool in USD cents. */- val budgetUsdCents: Long = 0,+ @SerialName("budget_usd_cents") val budgetUsdCents: Long = 0, ) @Serializable-data class StripeKeyResponse(val publishableKey: String = "")+data class StripeKeyResponse(@SerialName("publishable_key") val publishableKey: String = "") @Serializable-data class StripeIntentRequest(val accountId: String, val amountCents: Long)+data class StripeIntentRequest(+ @SerialName("account_id") val accountId: String,+ @SerialName("amount_cents") val amountCents: Long,+) @Serializable-data class StripeIntentResponse(val clientSecret: String = "")+data class StripeIntentResponse(@SerialName("client_secret") val clientSecret: String = "") @Serializable-data class NowPayInvoiceRequest(val accountId: String, val amountCents: Long)+data class NowPayInvoiceRequest(+ @SerialName("account_id") val accountId: String,+ @SerialName("amount_cents") val amountCents: Long,+) @Serializable data class NowPayInvoiceResponse(- val invoiceUrl: String = "",- val invoiceId: String = "",+ @SerialName("invoice_url") val invoiceUrl: String = "",+ @SerialName("invoice_id") val invoiceId: String = "", /** Extra credit the 5% crypto bonus adds, in USD cents. */- val bonusUsdCents: Long = 0,+ @SerialName("bonus_usd_cents") val bonusUsdCents: Long = 0, ) @Serializable-data class NowPayStatusRequest(val accountId: String, val invoiceId: String)+data class NowPayStatusRequest(+ @SerialName("account_id") val accountId: String,+ @SerialName("invoice_id") val invoiceId: String,+) @Serializable-data class NowPayStatusResponse(val status: String = "waiting")+data class NowPayStatusResponse(@SerialName("status") val status: String = "waiting") @Serializable-data class ErrorBody(val error: String = "", val message: String = "")+data class ErrorBody(+ @SerialName("error") val error: String = "",+ @SerialName("message") val message: String = "",+)
globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.ktindex 4f3ba5dcba..c4df265cb1 100644--- a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt@@ -25,8 +25,6 @@ import com.vayunmathur.globalesim.platform.EsimUiState import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.IconRefresh-import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.LoadingIndicator import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.Text@@ -49,10 +47,8 @@ fun HomeScreen( onCheckCryptoStatus: () -> Unit, onClearCryptoInvoice: () -> Unit, onOpenInstall: () -> Unit,- onOpenRates: () -> Unit, onOpenBudget: () -> Unit, onOpenTransfer: () -> Unit,- onRefresh: () -> Unit, onDismissError: () -> Unit, ) { val messenger = rememberMessenger()@@ -94,11 +90,8 @@ fun HomeScreen( } } AppScaffold(- title = "Global eSIM",+ title = "Purchase", scrollBehavior = appBarScrollBehavior(),- actions = {- IconButton(onClick = onRefresh) { IconRefresh() }- }, ) { padding -> Column( Modifier.padding(padding).padding(16.dp).verticalScroll(rememberScrollState()),@@ -109,11 +102,17 @@ fun HomeScreen( if (state.loading && profile == null) { LoadingIndicator() } else if (profile == null) {- Text("One global eSIM for 200+ countries.")+ Text("One global eSIM for 200+ countries") Text(- "Pay as you go (~$1/GB), credit never expires, " +- "no email needed. Creating your eSIM reserves " +- "it on the network.",+ "Pay as you go, credit never expires",+ modifier = Modifier.padding(top = 4.dp),+ )+ Text(+ "No email or phone number or KYC required",+ modifier = Modifier.padding(top = 4.dp),+ )+ Text(+ "Set up your eSIM now", modifier = Modifier.padding(top = 4.dp), ) Button(@@ -164,12 +163,6 @@ fun HomeScreen( ) { Text("Install / reinstall eSIM") }- OutlinedButton(- onClick = onOpenRates,- modifier = Modifier.fillMaxWidth().padding(top = 8.dp),- ) {- Text("Data rates by country")- } OutlinedButton( onClick = onOpenBudget, modifier = Modifier.fillMaxWidth().padding(top = 8.dp),
globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.ktnew file mode 100644index 0000000000..4bb2041f19--- /dev/null+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.kt@@ -0,0 +1,158 @@+package com.vayunmathur.globalesim.ui++import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateListOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import com.vayunmathur.globalesim.domain.QuoteMath+import com.vayunmathur.globalesim.platform.EsimUiState+import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.ExpandVisibility+import com.vayunmathur.library.ui.IconSim+import com.vayunmathur.library.ui.LazyListScaffold+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.ListItemDefaults+import com.vayunmathur.library.ui.LoadingIndicator+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.animatedColor+import com.vayunmathur.library.ui.animatedDp+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.ui.rememberMessenger++/**+ * Pricing: searchable per-country rate list. Tapping a country expands it+ * to show every carrier and its per-GB price (cheapest first), in the same+ * expandable-group style as the contacts groups page. Display-only —+ * the wallet is charged the local rate automatically as you use data.+ */+@Composable+fun PricingScreen(+ state: EsimUiState,+ onDismissError: () -> Unit,+) {+ val messenger = rememberMessenger()+ val error = state.error+ LaunchedEffect(error) {+ if (error != null) {+ messenger.show(error)+ onDismissError()+ }+ }+ var query by remember { mutableStateOf("") }+ val expanded = remember { mutableStateListOf<String>() }+ val filtered = remember(state.rates, query) {+ if (query.isBlank()) state.rates+ else state.rates.filter {+ it.countryName.contains(query, ignoreCase = true) ||+ it.countryCode.contains(query, ignoreCase = true)+ }+ }++ LazyListScaffold(+ title = "Pricing",+ horizontalPadding = 8.dp,+ verticalArrangement = Arrangement.spacedBy(4.dp),+ scrollBehavior = appBarScrollBehavior(),+ ) {+ item(key = "pricing-search") {+ CommonSearchBar(+ value = query,+ onValueChange = { query = it },+ placeholder = "Search countries",+ )+ }+ if (filtered.isEmpty()) {+ item(key = "pricing-empty") {+ if (state.loading) {+ LoadingIndicator(Modifier.padding(16.dp))+ } else {+ EmptyState(+ title = if (query.isBlank()) "No rates yet" else "No matches",+ message = if (query.isBlank()) "Pull down or reopen to refresh."+ else "Try another country name or code.",+ icon = { IconSim() },+ )+ }+ }+ }+ filtered.forEach { rate ->+ val isExpanded = rate.countryCode in expanded+ val showNetworks = isExpanded && rate.networks.isNotEmpty()+ item(key = "country-${rate.countryCode}") {+ val collapsedColor = MaterialTheme.colorScheme.surfaceVariant+ val expandedColor = MaterialTheme.colorScheme.secondaryContainer+ val headerColor = animatedColor(if (showNetworks) expandedColor else collapsedColor)+ val bottomRadius = animatedDp(if (showNetworks) 4.dp else 16.dp)+ Column {+ Surface(+ onClick = {+ if (isExpanded) expanded.remove(rate.countryCode)+ else expanded.add(rate.countryCode)+ },+ modifier = Modifier.fillMaxWidth(),+ shape = RoundedCornerShape(+ topStart = 16.dp, topEnd = 16.dp,+ bottomStart = bottomRadius, bottomEnd = bottomRadius,+ ),+ color = headerColor,+ ) {+ ListItem(+ content = {+ Text(+ text = rate.countryName,+ style = MaterialTheme.typography.bodyLarge,+ fontWeight = FontWeight.Medium,+ )+ },+ supportingContent = {+ Text("from ${QuoteMath.formatCents(rate.pricePerGbUsdCents)} / GB")+ },+ colors = ListItemDefaults.colors(containerColor = Color.Transparent),+ )+ }+ ExpandVisibility(visible = showNetworks) {+ Column {+ Spacer(Modifier.height(2.dp))+ Surface(+ modifier = Modifier.fillMaxWidth(),+ shape = RoundedCornerShape(4.dp),+ color = MaterialTheme.colorScheme.surfaceContainerHighest,+ ) {+ Column(Modifier.padding(vertical = 4.dp)) {+ rate.networks.forEach { net ->+ ListItem(+ modifier = Modifier.clickable {},+ content = { Text(net.operator) },+ supportingContent = {+ Text(QuoteMath.formatCents(net.pricePerGbUsdCents) + " / GB")+ },+ colors = ListItemDefaults.colors(containerColor = Color.Transparent),+ )+ }+ }+ }+ }+ }+ }+ }+ }+ }+}
globalesim/src/main/java/com/vayunmathur/globalesim/ui/RatesScreen.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/RatesScreen.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/RatesScreen.ktdeleted file mode 100644index fbd76a6402..0000000000--- a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/RatesScreen.kt+++ /dev/null@@ -1,72 +0,0 @@-package com.vayunmathur.globalesim.ui--import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items-import androidx.compose.runtime.Composable-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.ui.Modifier-import androidx.compose.ui.unit.dp-import com.vayunmathur.globalesim.domain.QuoteMath-import com.vayunmathur.globalesim.platform.EsimUiState-import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.IconRefresh-import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.ListItem-import com.vayunmathur.library.ui.LoadingIndicator-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior-import com.vayunmathur.library.ui.rememberMessenger--/**- * Rate list: what one GB deducts in each country. Display-only — your- * wallet is charged the local rate automatically as you use data.- */-@Composable-fun RatesScreen(- state: EsimUiState,- onNavigateBack: () -> Unit,- onRefresh: () -> Unit,- onDismissError: () -> Unit,-) {- val messenger = rememberMessenger()- val error = state.error- LaunchedEffect(error) {- if (error != null) {- messenger.show(error)- onDismissError()- }- }- AppScaffold(- title = "Data rates",- scrollBehavior = appBarScrollBehavior(),- onNavigateBack = onNavigateBack,- actions = {- IconButton(onClick = onRefresh) { IconRefresh() }- },- ) { padding ->- if (state.loading && state.rates.isEmpty()) {- LoadingIndicator(Modifier.padding(padding))- return@AppScaffold- }- if (state.rates.isEmpty()) {- Text("Rates unavailable — pull to refresh.", Modifier.padding(padding).padding(16.dp))- return@AppScaffold- }- LazyColumn(Modifier.fillMaxSize().padding(padding)) {- items(state.rates, key = { it.countryCode }) { rate ->- Card(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 6.dp)) {- ListItem(- headlineContent = { Text(rate.countryName) },- supportingContent = {- Text("${QuoteMath.formatCents(rate.pricePerGbUsdCents)} / GB")- },- )- }- }- }- }-}
globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.kt
diff --git a/globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.kt b/globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.ktindex 9a6516cbfd..8e159cfd1d 100644--- a/globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.kt+++ b/globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.kt@@ -3,6 +3,7 @@ package com.vayunmathur.globalesim.ui import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.Preview import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.globalesim.data.api.NetworkDto import com.vayunmathur.globalesim.data.api.ProfileDto import com.vayunmathur.globalesim.data.api.RateDto import com.vayunmathur.globalesim.platform.EsimUiState@@ -26,16 +27,29 @@ class MetadataPreviews { walletUsdCents = 1250, ) private val demoRates = listOf(- RateDto("US", "United States", 100),- RateDto("JP", "Japan", 138),+ RateDto(+ "US", "United States", 87,+ networks = listOf(+ NetworkDto("T-Mobile USA", 87),+ NetworkDto("AT&T", 128),+ NetworkDto("Verizon Wireless", 165),+ ),+ ),+ RateDto(+ "JP", "Japan", 138,+ networks = listOf(+ NetworkDto("KDDI Corporation", 138),+ NetworkDto("Rakuten", 170),+ ),+ ), RateDto("FR", "France", 52), RateDto("GB", "United Kingdom", 95), ) @PreviewTest- @Preview(name = "1-home", device = PHONE, showSystemUi = true)+ @Preview(name = "1-purchase", device = PHONE, showSystemUi = true) @Composable- fun Preview1Home() {+ fun Preview1Purchase() { DynamicTheme(darkTheme = true) { HomeScreen( state = EsimUiState(profile = demoProfile, budgetCents = 2000),@@ -47,24 +61,20 @@ class MetadataPreviews { onCheckCryptoStatus = {}, onClearCryptoInvoice = {}, onOpenInstall = {},- onOpenRates = {}, onOpenBudget = {}, onOpenTransfer = {},- onRefresh = {}, onDismissError = {}, ) } } @PreviewTest- @Preview(name = "2-rates", device = PHONE, showSystemUi = true)+ @Preview(name = "2-pricing", device = PHONE, showSystemUi = true) @Composable- fun Preview2Rates() {+ fun Preview2Pricing() { DynamicTheme(darkTheme = true) {- RatesScreen(+ PricingScreen( state = EsimUiState(rates = demoRates),- onNavigateBack = {},- onRefresh = {}, onDismissError = {}, ) }