Modern Apps git

← Modern-Apps.git

fooddelivery: honor 24-hour setting for order times

Commit
97715eb10efe400cc29001f852d646b590bc1154
Author
Vayun Mathur <[email protected]>
When
2026-08-10 20:00 UTC (3 months ago)
Parents
a4c0029

Diff

fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.ktindex feed24b786..6324053521 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt@@ -65,6 +65,7 @@ import com.vayunmathur.fooddelivery.data.OrderStage import kotlinx.coroutines.delay import kotlin.time.Instant import com.vayunmathur.library.ui.DateString+import com.vayunmathur.library.ui.rememberIs24Hour import kotlin.math.max import kotlin.math.min @@ -256,6 +257,7 @@ private fun MapPin( private fun StageHeader(order: Order) {     val stage = order.stage     val locale = LocalConfiguration.current.locales[0]+    val is24 = rememberIs24Hour()     Column {         Text(stage.label, style = MaterialTheme.typography.headlineSmall,             fontWeight = FontWeight.Bold)@@ -266,7 +268,7 @@ private fun StageHeader(order: Order) {             Spacer(Modifier.height(4.dp))             Text(                 if (minutes > 0) stringResource(R.string.eta_minutes, minutes,-                    DateString.time(Instant.fromEpochMilliseconds(eta), is24Hour = false, locale = locale))+                    DateString.time(Instant.fromEpochMilliseconds(eta), is24Hour = is24, locale = locale))                 else stringResource(R.string.eta_any_moment),                 style = MaterialTheme.typography.bodyLarge,                 color = MaterialTheme.colorScheme.primary,
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.ktindex 744a87b722..30cf0c425d 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.kt@@ -59,6 +59,7 @@ import kotlinx.datetime.TimeZone import kotlinx.datetime.toInstant import kotlinx.datetime.toLocalDateTime import com.vayunmathur.library.ui.DateString+import com.vayunmathur.library.ui.rememberIs24Hour  @Composable fun OrdersScreen(onTrackOrder: (Int) -> Unit = {}) {@@ -162,14 +163,14 @@ fun OrdersScreen(onTrackOrder: (Int) -> Unit = {}) {     } } -private fun formatDate(iso: String?): String {+private fun formatDate(iso: String?, is24Hour: Boolean): String {     if (iso.isNullOrEmpty()) return ""     return try {         val ldt = LocalDateTime.parse(iso.substringBefore(".").substringBefore("Z"))             .toInstant(TimeZone.UTC)             .toLocalDateTime(TimeZone.currentSystemDefault())         DateString.monthDayYear(ldt.date, Locale.US) + ", " +-            DateString.time(ldt.time, is24Hour = false, locale = Locale.US)+            DateString.time(ldt.time, is24Hour = is24Hour, locale = Locale.US)     } catch (_: Exception) { iso } } @@ -182,6 +183,7 @@ private fun OrderCard( ) {     val merchantName = order.merchant?.name ?: ""     val merchantImage = order.merchant?.imageUrl ?: order.merchant?.logoUrl ?: ""+    val is24 = rememberIs24Hour()      Card(modifier = Modifier.fillMaxWidth()) {         Column(Modifier.padding(12.dp)) {@@ -202,7 +204,7 @@ private fun OrderCard(                     Column {                         Text(merchantName, fontWeight = FontWeight.Bold,                             style = MaterialTheme.typography.titleSmall)-                        Text(formatDate(order.createdAt), style = MaterialTheme.typography.bodySmall,+                        Text(formatDate(order.createdAt, is24), style = MaterialTheme.typography.bodySmall,                             color = MaterialTheme.colorScheme.onSurfaceVariant)                     }                 }