Modern Apps git

← Modern-Apps.git

travel: fix all lint findings

Commit
c8bf71e05abf999c217574c42e2aa2bde7d3f5f7
Author
Vayun Mathur <[email protected]>
When
2026-11-17 04:21 UTC (19 days ago)
Parents
6c4d225
Fix every lint error and warning reported for the travel module's own sources by :travel:lintDev, now 0 errors / 0 warnings for travel/** (remaining report entries are transitive library findings owned by other clusters). Booking price/confirm semantics untouched.

PackageStructure: moved all of util/ (TravelViewModel, TravelUiContract/State, TravelSearch/Booking/Order/Customer/StayOps, ContactAutofill) to platform/, including the test util/ tree. Route extracted from MainActivity into Route.kt and MainGraph renamed to Navigation in Navigation.kt. OneComposablePerFile splits: Common.kt became StatusBox.kt, AirlineLogo.kt and RememberSecondsUntil.kt; FlightResultsScreen, OrderDetailScreen, FareSelectPage and SeatMapScreen extracted with their private helpers. Converted boxed Int/Long Compose state to mutableIntStateOf/mutableLongStateOf and added POST_NOTIFICATIONS to the manifest.

Resources: deleted 28 verified-unused strings (the car-rental set and Estonian step/explore strings) with no dynamic lookup in the module.

No @SuppressLint added; no lint config or baseline changed; no rule-bug categories.

Verified: ./gradlew :travel:lintDev (0 own-module errors/warnings) and :travel:testDevUnitTest green.

Diff

travel/src/main/AndroidManifest.xml
diff --git a/travel/src/main/AndroidManifest.xml b/travel/src/main/AndroidManifest.xmlindex b783978a90..6f4f6067db 100644--- a/travel/src/main/AndroidManifest.xml+++ b/travel/src/main/AndroidManifest.xml@@ -7,6 +7,7 @@     <uses-permission android:name="com.vayunmathur.permission.SENSORS_OPTOUT" />      <uses-permission android:name="android.permission.INTERNET" />+    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />      <application         android:allowBackup="true"
travel/src/main/java/com/vayunmathur/travel/MainActivity.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/MainActivity.kt b/travel/src/main/java/com/vayunmathur/travel/MainActivity.ktindex dc72bbfd86..30ed3bfaf8 100644--- a/travel/src/main/java/com/vayunmathur/travel/MainActivity.kt+++ b/travel/src/main/java/com/vayunmathur/travel/MainActivity.kt@@ -1,55 +1,24 @@ package com.vayunmathur.travel  import androidx.activity.viewModels-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue-import androidx.compose.ui.Modifier import androidx.lifecycle.lifecycleScope import com.vayunmathur.library.ui.MaActivity-import com.vayunmathur.library.util.ListDetailPage-import com.vayunmathur.library.util.ListPage-import com.vayunmathur.library.util.MainNavigation-import com.vayunmathur.library.util.MorphPage-import com.vayunmathur.library.util.NavKey-import com.vayunmathur.library.util.openSettingsIfRequested-import com.vayunmathur.library.util.SiblingPage-import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.travel.data.TravelRepository-import com.vayunmathur.travel.ui.AncillariesPage-import com.vayunmathur.travel.ui.CancellationPage-import com.vayunmathur.travel.ui.ChangePage-import com.vayunmathur.travel.ui.ConfirmationPage-import com.vayunmathur.travel.ui.FlightResultsPage-import com.vayunmathur.travel.ui.FareSelectPage-import com.vayunmathur.travel.ui.HomePage-import com.vayunmathur.travel.ui.OfferReviewPage-import com.vayunmathur.travel.ui.OrderDetailPage-import com.vayunmathur.travel.ui.OutboundSelectPage-import com.vayunmathur.travel.ui.PassengersPage-import com.vayunmathur.travel.ui.PaymentPage-import com.vayunmathur.travel.ui.SeatMapPage-import com.vayunmathur.travel.ui.SettingsPage-import com.vayunmathur.travel.ui.StayConfirmationPage-import com.vayunmathur.travel.ui.StayDetailPage-import com.vayunmathur.travel.ui.StayGuestsPage-import com.vayunmathur.travel.ui.StayResultsPage-import com.vayunmathur.travel.ui.TripsPage import com.vayunmathur.travel.data.RemoteImageFetchers-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.TravelViewModelFactory-import com.vayunmathur.travel.util.pendingTripIds-import com.vayunmathur.travel.util.pollTrip+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.TravelViewModelFactory+import com.vayunmathur.travel.platform.pendingTripIds+import com.vayunmathur.travel.platform.pollTrip import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import com.vayunmathur.library.image.ImageLoader import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.library.network.TrustBundle-import kotlinx.serialization.Serializable  /** Main Activity: a ma activity implementation for main activity. */ class MainActivity : MaActivity() {@@ -88,146 +57,6 @@ class MainActivity : MaActivity() {      @Composable     override fun Content() {-        if (ready) MainGraph(viewModel)-    }-}--/** Contract for route. */-@Serializable-sealed interface Route : NavKey {-    /** Singleton holding flights-home state and operations. */-    @Serializable-    data object FlightsHome : Route--    /** Singleton holding stays-home state and operations. */-    @Serializable-    data object StaysHome : Route--    /** Immutable value describing flight results. */-    @Serializable-    data class FlightResults(-        val slices: String,-        val adults: Int,-        val children: String,-        val infants: Int,-        val cabin: String,-        val maxConnections: Int,-    ) : Route--    /** Immutable value describing offer review; carries offerId. */-    @Serializable-    data class OfferReview(val offerId: String) : Route--    /** Immutable value describing outbound select. */-    @Serializable-    data class OutboundSelect(-        val slices: String,-        val adults: Int,-        val children: String,-        val infants: Int,-        val cabin: String,-        val maxConnections: Int,-    ) : Route---    /** Immutable value describing fare select; carries outboundSignature, inboundSignature. */-    @Serializable-    data class FareSelect(val outboundSignature: String, val inboundSignature: String) : Route--    /** Immutable value describing ancillaries; carries offerId. */-    @Serializable-    data class Ancillaries(val offerId: String) : Route--    /** Immutable value describing seat map; carries offerId, segmentId. */-    @Serializable-    data class SeatMap(val offerId: String, val segmentId: String) : Route--    /** Immutable value describing passengers; carries offerId. */-    @Serializable-    data class Passengers(val offerId: String) : Route--    /** Immutable value describing payment; carries offerId. */-    @Serializable-    data class Payment(val offerId: String) : Route--    /** Immutable value describing confirmation; carries orderId. */-    @Serializable-    data class Confirmation(val orderId: String) : Route--    /** Immutable value describing order detail; carries orderId. */-    @Serializable-    data class OrderDetail(val orderId: String) : Route--    /** Immutable value describing cancel; carries orderId. */-    @Serializable-    data class Cancel(val orderId: String) : Route--    /** Immutable value describing change; carries orderId. */-    @Serializable-    data class Change(val orderId: String) : Route--    /** Immutable value describing stay results. */-    @Serializable-    data class StayResults(-        val place: String,-        val checkIn: String,-        val checkOut: String,-        val rooms: Int,-        val adults: Int,-        val latitude: Double = Double.NaN,-        val longitude: Double = Double.NaN,-    ) : Route--    /** Immutable value describing stay detail; carries searchResultId, name. */-    @Serializable-    data class StayDetail(val searchResultId: String, val name: String) : Route--    /** Singleton holding stay guests state and operations. */-    @Serializable-    data object StayGuests : Route--    /** Immutable value describing stay confirmation; carries bookingId. */-    @Serializable-    data class StayConfirmation(val bookingId: String) : Route--    /** Singleton holding trips state and operations. */-    @Serializable-    data object Trips : Route--    /** Singleton holding settings state and operations. */-    @Serializable-    data object Settings : Route-}--@Composable-fun MainGraph(viewModel: TravelViewModel) {-    val backStack = rememberNavBackStack<Route>(Route.FlightsHome)-    // Land on settings when opened from the system App Info page.-    backStack.openSettingsIfRequested(Route.Settings)-    Box(Modifier.fillMaxSize()) {-        MainNavigation(backStack) {-            entry<Route.FlightsHome>(metadata = SiblingPage()) { HomePage(backStack, viewModel, it) }-            entry<Route.StaysHome>(metadata = SiblingPage()) { HomePage(backStack, viewModel, it) }-            entry<Route.FlightResults>(metadata = ListPage()) { FlightResultsPage(backStack, viewModel, it) }-            entry<Route.OutboundSelect> { OutboundSelectPage(backStack, viewModel, it) }-            entry<Route.FareSelect> { FareSelectPage(backStack, viewModel, it) }-            entry<Route.OfferReview>(metadata = ListDetailPage() + MorphPage()) {-                OfferReviewPage(backStack, viewModel, it)-            }-            entry<Route.Ancillaries> { AncillariesPage(backStack, viewModel, it) }-            entry<Route.SeatMap> { SeatMapPage(backStack, viewModel, it) }-            entry<Route.Passengers> { PassengersPage(backStack, viewModel, it) }-            entry<Route.Payment> { PaymentPage(backStack, viewModel, it) }-            entry<Route.Confirmation> { ConfirmationPage(backStack, viewModel, it) }-            entry<Route.OrderDetail>(metadata = ListDetailPage()) { OrderDetailPage(backStack, viewModel, it) }-            entry<Route.Cancel> { CancellationPage(backStack, viewModel, it) }-            entry<Route.Change> { ChangePage(backStack, viewModel, it) }-            entry<Route.StayResults> { StayResultsPage(backStack, viewModel, it) }-            entry<Route.StayDetail>(metadata = MorphPage()) { StayDetailPage(backStack, viewModel, it) }-            entry<Route.StayGuests> { StayGuestsPage(backStack, viewModel) }-            entry<Route.StayConfirmation> { StayConfirmationPage(backStack, viewModel, it) }-            entry<Route.Trips>(metadata = ListPage()) { TripsPage(backStack, viewModel) }-            entry<Route.Settings> { SettingsPage(backStack, viewModel) }-        }+        if (ready) Navigation(viewModel)     } }
travel/src/main/java/com/vayunmathur/travel/Navigation.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/Navigation.kt b/travel/src/main/java/com/vayunmathur/travel/Navigation.ktnew file mode 100644index 0000000000..0632486438--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/Navigation.kt@@ -0,0 +1,66 @@+package com.vayunmathur.travel++import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import com.vayunmathur.library.util.ListDetailPage+import com.vayunmathur.library.util.ListPage+import com.vayunmathur.library.util.MainNavigation+import com.vayunmathur.library.util.MorphPage+import com.vayunmathur.library.util.openSettingsIfRequested+import com.vayunmathur.library.util.SiblingPage+import com.vayunmathur.library.util.rememberNavBackStack+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.ui.AncillariesPage+import com.vayunmathur.travel.ui.CancellationPage+import com.vayunmathur.travel.ui.ChangePage+import com.vayunmathur.travel.ui.ConfirmationPage+import com.vayunmathur.travel.ui.FareSelectPage+import com.vayunmathur.travel.ui.FlightResultsPage+import com.vayunmathur.travel.ui.HomePage+import com.vayunmathur.travel.ui.OfferReviewPage+import com.vayunmathur.travel.ui.OrderDetailPage+import com.vayunmathur.travel.ui.OutboundSelectPage+import com.vayunmathur.travel.ui.PassengersPage+import com.vayunmathur.travel.ui.PaymentPage+import com.vayunmathur.travel.ui.SeatMapPage+import com.vayunmathur.travel.ui.SettingsPage+import com.vayunmathur.travel.ui.StayConfirmationPage+import com.vayunmathur.travel.ui.StayDetailPage+import com.vayunmathur.travel.ui.StayGuestsPage+import com.vayunmathur.travel.ui.StayResultsPage+import com.vayunmathur.travel.ui.TripsPage++@Composable+fun Navigation(viewModel: TravelViewModel) {+    val backStack = rememberNavBackStack<Route>(Route.FlightsHome)+    // Land on settings when opened from the system App Info page.+    backStack.openSettingsIfRequested(Route.Settings)+    Box(Modifier.fillMaxSize()) {+        MainNavigation(backStack) {+            entry<Route.FlightsHome>(metadata = SiblingPage()) { HomePage(backStack, viewModel, it) }+            entry<Route.StaysHome>(metadata = SiblingPage()) { HomePage(backStack, viewModel, it) }+            entry<Route.FlightResults>(metadata = ListPage()) { FlightResultsPage(backStack, viewModel, it) }+            entry<Route.OutboundSelect> { OutboundSelectPage(backStack, viewModel, it) }+            entry<Route.FareSelect> { FareSelectPage(backStack, viewModel, it) }+            entry<Route.OfferReview>(metadata = ListDetailPage() + MorphPage()) {+                OfferReviewPage(backStack, viewModel, it)+            }+            entry<Route.Ancillaries> { AncillariesPage(backStack, viewModel, it) }+            entry<Route.SeatMap> { SeatMapPage(backStack, viewModel, it) }+            entry<Route.Passengers> { PassengersPage(backStack, viewModel, it) }+            entry<Route.Payment> { PaymentPage(backStack, viewModel, it) }+            entry<Route.Confirmation> { ConfirmationPage(backStack, viewModel, it) }+            entry<Route.OrderDetail>(metadata = ListDetailPage()) { OrderDetailPage(backStack, viewModel, it) }+            entry<Route.Cancel> { CancellationPage(backStack, viewModel, it) }+            entry<Route.Change> { ChangePage(backStack, viewModel, it) }+            entry<Route.StayResults> { StayResultsPage(backStack, viewModel, it) }+            entry<Route.StayDetail>(metadata = MorphPage()) { StayDetailPage(backStack, viewModel, it) }+            entry<Route.StayGuests> { StayGuestsPage(backStack, viewModel) }+            entry<Route.StayConfirmation> { StayConfirmationPage(backStack, viewModel, it) }+            entry<Route.Trips>(metadata = ListPage()) { TripsPage(backStack, viewModel) }+            entry<Route.Settings> { SettingsPage(backStack, viewModel) }+        }+    }+}
travel/src/main/java/com/vayunmathur/travel/Route.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/Route.kt b/travel/src/main/java/com/vayunmathur/travel/Route.ktnew file mode 100644index 0000000000..19ef49a382--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/Route.kt@@ -0,0 +1,111 @@+package com.vayunmathur.travel++import com.vayunmathur.library.util.NavKey+import kotlinx.serialization.Serializable++/** Contract for route. */+@Serializable+sealed interface Route : NavKey {+    /** Singleton holding flights-home state and operations. */+    @Serializable+    data object FlightsHome : Route++    /** Singleton holding stays-home state and operations. */+    @Serializable+    data object StaysHome : Route++    /** Immutable value describing flight results. */+    @Serializable+    data class FlightResults(+        val slices: String,+        val adults: Int,+        val children: String,+        val infants: Int,+        val cabin: String,+        val maxConnections: Int,+    ) : Route++    /** Immutable value describing offer review; carries offerId. */+    @Serializable+    data class OfferReview(val offerId: String) : Route++    /** Immutable value describing outbound select. */+    @Serializable+    data class OutboundSelect(+        val slices: String,+        val adults: Int,+        val children: String,+        val infants: Int,+        val cabin: String,+        val maxConnections: Int,+    ) : Route+++    /** Immutable value describing fare select; carries outboundSignature, inboundSignature. */+    @Serializable+    data class FareSelect(val outboundSignature: String, val inboundSignature: String) : Route++    /** Immutable value describing ancillaries; carries offerId. */+    @Serializable+    data class Ancillaries(val offerId: String) : Route++    /** Immutable value describing seat map; carries offerId, segmentId. */+    @Serializable+    data class SeatMap(val offerId: String, val segmentId: String) : Route++    /** Immutable value describing passengers; carries offerId. */+    @Serializable+    data class Passengers(val offerId: String) : Route++    /** Immutable value describing payment; carries offerId. */+    @Serializable+    data class Payment(val offerId: String) : Route++    /** Immutable value describing confirmation; carries orderId. */+    @Serializable+    data class Confirmation(val orderId: String) : Route++    /** Immutable value describing order detail; carries orderId. */+    @Serializable+    data class OrderDetail(val orderId: String) : Route++    /** Immutable value describing cancel; carries orderId. */+    @Serializable+    data class Cancel(val orderId: String) : Route++    /** Immutable value describing change; carries orderId. */+    @Serializable+    data class Change(val orderId: String) : Route++    /** Immutable value describing stay results. */+    @Serializable+    data class StayResults(+        val place: String,+        val checkIn: String,+        val checkOut: String,+        val rooms: Int,+        val adults: Int,+        val latitude: Double = Double.NaN,+        val longitude: Double = Double.NaN,+    ) : Route++    /** Immutable value describing stay detail; carries searchResultId, name. */+    @Serializable+    data class StayDetail(val searchResultId: String, val name: String) : Route++    /** Singleton holding stay guests state and operations. */+    @Serializable+    data object StayGuests : Route++    /** Immutable value describing stay confirmation; carries bookingId. */+    @Serializable+    data class StayConfirmation(val bookingId: String) : Route++    /** Singleton holding trips state and operations. */+    @Serializable+    data object Trips : Route++    /** Singleton holding settings state and operations. */+    @Serializable+    data object Settings : Route+}
travel/src/main/java/com/vayunmathur/travel/domain/OfferGrouping.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/domain/OfferGrouping.kt b/travel/src/main/java/com/vayunmathur/travel/domain/OfferGrouping.ktindex daefbccca9..a8f5328c38 100644--- a/travel/src/main/java/com/vayunmathur/travel/domain/OfferGrouping.kt+++ b/travel/src/main/java/com/vayunmathur/travel/domain/OfferGrouping.kt@@ -2,8 +2,8 @@ package com.vayunmathur.travel.domain  import com.vayunmathur.travel.network.OfferDto import com.vayunmathur.travel.network.SliceDto-import com.vayunmathur.travel.util.FlightFilters-import com.vayunmathur.travel.util.OfferSort+import com.vayunmathur.travel.platform.FlightFilters+import com.vayunmathur.travel.platform.OfferSort  /**  * On-device offer sort + filter (the server returns every offer cheapest
travel/src/main/java/com/vayunmathur/travel/platform/ContactAutofill.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/ContactAutofill.kt b/travel/src/main/java/com/vayunmathur/travel/platform/ContactAutofill.ktsimilarity index 99%rename from travel/src/main/java/com/vayunmathur/travel/util/ContactAutofill.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/ContactAutofill.ktindex 7ec899cab9..fd7b84dfe3 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/ContactAutofill.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/ContactAutofill.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import android.content.Context import android.database.Cursor
travel/src/main/java/com/vayunmathur/travel/platform/TravelBookingOps.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelBookingOps.kt b/travel/src/main/java/com/vayunmathur/travel/platform/TravelBookingOps.ktsimilarity index 99%rename from travel/src/main/java/com/vayunmathur/travel/util/TravelBookingOps.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/TravelBookingOps.ktindex b0d6bffc65..5cf05bd5d3 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelBookingOps.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/TravelBookingOps.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import androidx.lifecycle.viewModelScope import com.vayunmathur.travel.data.AirportCatalog
travel/src/main/java/com/vayunmathur/travel/platform/TravelCustomerOps.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelCustomerOps.kt b/travel/src/main/java/com/vayunmathur/travel/platform/TravelCustomerOps.ktsimilarity index 97%rename from travel/src/main/java/com/vayunmathur/travel/util/TravelCustomerOps.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/TravelCustomerOps.ktindex 1f14185caa..b4ced502af 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelCustomerOps.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/TravelCustomerOps.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import androidx.lifecycle.viewModelScope import com.vayunmathur.travel.data.Customer
travel/src/main/java/com/vayunmathur/travel/platform/TravelOrderOps.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelOrderOps.kt b/travel/src/main/java/com/vayunmathur/travel/platform/TravelOrderOps.ktsimilarity index 99%rename from travel/src/main/java/com/vayunmathur/travel/util/TravelOrderOps.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/TravelOrderOps.ktindex 4abdaf58f2..bd55f6a6ca 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelOrderOps.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/TravelOrderOps.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import androidx.lifecycle.viewModelScope import com.vayunmathur.travel.data.BookedTrip
travel/src/main/java/com/vayunmathur/travel/platform/TravelSearchOps.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelSearchOps.kt b/travel/src/main/java/com/vayunmathur/travel/platform/TravelSearchOps.ktsimilarity index 99%rename from travel/src/main/java/com/vayunmathur/travel/util/TravelSearchOps.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/TravelSearchOps.ktindex 79f08e382a..18568c22da 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelSearchOps.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/TravelSearchOps.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import androidx.lifecycle.viewModelScope import com.vayunmathur.travel.data.AirportCatalog
travel/src/main/java/com/vayunmathur/travel/platform/TravelStayOps.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelStayOps.kt b/travel/src/main/java/com/vayunmathur/travel/platform/TravelStayOps.ktsimilarity index 99%rename from travel/src/main/java/com/vayunmathur/travel/util/TravelStayOps.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/TravelStayOps.ktindex abe2f9bd57..534c1dc53b 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelStayOps.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/TravelStayOps.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import androidx.lifecycle.viewModelScope import com.vayunmathur.travel.data.AirportCatalog
travel/src/main/java/com/vayunmathur/travel/platform/TravelUiContract.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelUiContract.kt b/travel/src/main/java/com/vayunmathur/travel/platform/TravelUiContract.ktsimilarity index 98%rename from travel/src/main/java/com/vayunmathur/travel/util/TravelUiContract.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/TravelUiContract.ktindex 6036a33575..5ed611d07f 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelUiContract.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/TravelUiContract.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import com.vayunmathur.travel.network.OfferDto import com.vayunmathur.travel.network.OrderDetailDto
travel/src/main/java/com/vayunmathur/travel/platform/TravelUiState.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelUiState.kt b/travel/src/main/java/com/vayunmathur/travel/platform/TravelUiState.ktsimilarity index 99%rename from travel/src/main/java/com/vayunmathur/travel/util/TravelUiState.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/TravelUiState.ktindex d784df2b27..151a1e2316 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelUiState.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/TravelUiState.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import com.vayunmathur.travel.network.CancellationDto import com.vayunmathur.travel.network.ChangeOfferDto
travel/src/main/java/com/vayunmathur/travel/platform/TravelViewModel.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelViewModel.kt b/travel/src/main/java/com/vayunmathur/travel/platform/TravelViewModel.ktsimilarity index 99%rename from travel/src/main/java/com/vayunmathur/travel/util/TravelViewModel.ktrename to travel/src/main/java/com/vayunmathur/travel/platform/TravelViewModel.ktindex 198316b88b..83bf78170a 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelViewModel.kt+++ b/travel/src/main/java/com/vayunmathur/travel/platform/TravelViewModel.kt@@ -1,4 +1,4 @@-package com.vayunmathur.travel.util+package com.vayunmathur.travel.platform  import android.app.Application import androidx.lifecycle.AndroidViewModel
travel/src/main/java/com/vayunmathur/travel/ui/AirlineLogo.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/AirlineLogo.kt b/travel/src/main/java/com/vayunmathur/travel/ui/AirlineLogo.ktnew file mode 100644index 0000000000..3d460d2ac6--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/AirlineLogo.kt@@ -0,0 +1,81 @@+package com.vayunmathur.travel.ui++import kotlin.time.Clock+import kotlin.time.Instant+import kotlinx.datetime.LocalDateTime+import com.vayunmathur.library.ui.DateString+import kotlinx.datetime.TimeZone+import kotlinx.datetime.toLocalDateTime+import androidx.compose.foundation.background+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.heightIn+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+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.draw.clip+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import androidx.lifecycle.Lifecycle+import androidx.lifecycle.compose.LocalLifecycleOwner+import androidx.lifecycle.repeatOnLifecycle+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text++// --- Formatting helpers ------------------------------------------------------++/**+ * An airline logo loaded from an SVG URL via Coil, falling back to a round+ * badge with the [iata] code while loading or on error / when no URL is set.+ */+@Composable+fun AirlineLogo(+    logoUrl: String,+    iata: String,+    modifier: Modifier = Modifier,+    size: androidx.compose.ui.unit.Dp = 32.dp,+) {+    if (logoUrl.isBlank()) {+        IataBadge(iata, size, modifier)+        return+    }+    // library:image includes SVG decoding (internal Android stdlib) built-in.+    com.vayunmathur.library.image.compose.AsyncImage(+        model = logoUrl,+        contentDescription = iata,+        modifier = modifier.size(size),+    )+}++@Composable+private fun IataBadge(+    iata: String,+    size: androidx.compose.ui.unit.Dp,+    modifier: Modifier = Modifier,+) {+    Box(+        modifier+            .size(size)+            .clip(androidx.compose.foundation.shape.CircleShape)+            .background(MaterialTheme.colorScheme.primaryContainer),+        contentAlignment = Alignment.Center,+    ) {+        Text(+            iata.take(2),+            style = MaterialTheme.typography.labelSmall,+            fontWeight = FontWeight.SemiBold,+            color = MaterialTheme.colorScheme.onPrimaryContainer,+        )+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.ktindex dae0934932..15a2c3a8dd 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.kt@@ -32,13 +32,13 @@ import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.travel.Route import com.vayunmathur.travel.network.ServiceDto-import com.vayunmathur.travel.util.AncillariesState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.initPassengers-import com.vayunmathur.travel.util.retrySeatMaps-import com.vayunmathur.travel.util.saveAncillaries-import com.vayunmathur.travel.util.setBaggageQuantity-import com.vayunmathur.travel.util.setExtraQuantity+import com.vayunmathur.travel.platform.AncillariesState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.initPassengers+import com.vayunmathur.travel.platform.retrySeatMaps+import com.vayunmathur.travel.platform.saveAncillaries+import com.vayunmathur.travel.platform.setBaggageQuantity+import com.vayunmathur.travel.platform.setExtraQuantity import androidx.compose.ui.res.stringResource  /**
travel/src/main/java/com/vayunmathur/travel/ui/CancellationPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/CancellationPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/CancellationPage.ktindex afa0f4ea6e..64b868b5d1 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/CancellationPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/CancellationPage.kt@@ -27,10 +27,10 @@ import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.travel.Route-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.confirmCancellation-import com.vayunmathur.travel.util.quoteCancellation-import com.vayunmathur.travel.util.resetCancellation+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.confirmCancellation+import com.vayunmathur.travel.platform.quoteCancellation+import com.vayunmathur.travel.platform.resetCancellation import androidx.compose.ui.res.stringResource  /**
travel/src/main/java/com/vayunmathur/travel/ui/ChangePage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/ChangePage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/ChangePage.ktindex 1256b12ff5..9df398a663 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/ChangePage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/ChangePage.kt@@ -14,6 +14,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue@@ -37,12 +38,12 @@ import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.travel.Route import com.vayunmathur.travel.network.ChangeOfferDto import com.vayunmathur.travel.network.SliceDto-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.confirmChange-import com.vayunmathur.travel.util.loadBookingDetail-import com.vayunmathur.travel.util.priceChange-import com.vayunmathur.travel.util.requestChange-import com.vayunmathur.travel.util.resetChange+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.confirmChange+import com.vayunmathur.travel.platform.loadBookingDetail+import com.vayunmathur.travel.platform.priceChange+import com.vayunmathur.travel.platform.requestChange+import com.vayunmathur.travel.platform.resetChange import androidx.compose.ui.res.stringResource  @OptIn(ExperimentalMaterial3Api::class)@@ -60,7 +61,7 @@ fun ChangePage(         viewModel.loadBookingDetail(route.orderId)     } -    var selectedSliceIndex by remember { mutableStateOf(0) }+    var selectedSliceIndex by remember { mutableIntStateOf(0) }     var newDate by remember { mutableStateOf("") }      AppScaffold(
travel/src/main/java/com/vayunmathur/travel/ui/Common.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/Common.kt b/travel/src/main/java/com/vayunmathur/travel/ui/Common.ktindex c1a5a05c15..86cd57b47b 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/Common.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/Common.kt@@ -43,79 +43,6 @@ fun SectionHeader(text: String, modifier: Modifier = Modifier) {         modifier = modifier.padding(horizontal = 16.dp, vertical = 8.dp),     ) }--/** Centered loading/error/empty state used by results pages. */-@Composable-fun StatusBox(-    loading: Boolean,-    error: String?,-    isEmpty: Boolean,-    modifier: Modifier = Modifier,-    emptyMessage: String = "No flights found. Try different dates or airports.",-) {-    Box(modifier.fillMaxWidth().heightIn(min = 200.dp), contentAlignment = Alignment.Center) {-        when {-            loading -> CircularProgressIndicator()-            error != null -> Text(-                error,-                color = MaterialTheme.colorScheme.error,-                modifier = Modifier.padding(24.dp),-            )-            isEmpty -> Text(-                emptyMessage,-                color = MaterialTheme.colorScheme.onSurfaceVariant,-                modifier = Modifier.padding(24.dp),-            )-        }-    }-}--// --- Formatting helpers --------------------------------------------------------/**- * An airline logo loaded from an SVG URL via Coil, falling back to a round- * badge with the [iata] code while loading or on error / when no URL is set.- */-@Composable-fun AirlineLogo(-    logoUrl: String,-    iata: String,-    modifier: Modifier = Modifier,-    size: androidx.compose.ui.unit.Dp = 32.dp,-) {-    if (logoUrl.isBlank()) {-        IataBadge(iata, size, modifier)-        return-    }-    // library:image includes SVG decoding (internal Android stdlib) built-in.-    com.vayunmathur.library.image.compose.AsyncImage(-        model = logoUrl,-        contentDescription = iata,-        modifier = modifier.size(size),-    )-}--@Composable-private fun IataBadge(-    iata: String,-    size: androidx.compose.ui.unit.Dp,-    modifier: Modifier = Modifier,-) {-    Box(-        modifier-            .size(size)-            .clip(androidx.compose.foundation.shape.CircleShape)-            .background(MaterialTheme.colorScheme.primaryContainer),-        contentAlignment = Alignment.Center,-    ) {-        Text(-            iata.take(2),-            style = MaterialTheme.typography.labelSmall,-            fontWeight = FontWeight.SemiBold,-            color = MaterialTheme.colorScheme.onPrimaryContainer,-        )-    }-} // --- Formatting helpers ------------------------------------------------------ // (fare/money/duration/countdown labels now live in TravelFormat.kt) @@ -128,24 +55,3 @@ fun formatTime(iso: String, is24Hour: Boolean): String = runCatching { fun secondsUntil(iso: String): Long = runCatching {     (Instant.parse(iso) - Clock.System.now()).inWholeSeconds }.getOrDefault(Long.MAX_VALUE)--/**- * Seconds remaining until [expiresAtIso], ticking once per second **only while- * the app is in the foreground** (`RESUMED`). Backgrounding pauses the ticker;- * returning resumes it (and reports 0 immediately if it already lapsed).- */-@Composable-fun rememberSecondsUntil(expiresAtIso: String): Long {-    val lifecycleOwner = LocalLifecycleOwner.current-    var remaining by remember(expiresAtIso) { mutableStateOf(secondsUntil(expiresAtIso)) }-    LaunchedEffect(expiresAtIso, lifecycleOwner) {-        lifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {-            while (true) {-                remaining = secondsUntil(expiresAtIso)-                if (remaining <= 0) break-                kotlinx.coroutines.delay(1000)-            }-        }-    }-    return remaining-}
travel/src/main/java/com/vayunmathur/travel/ui/ConfirmationPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/ConfirmationPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/ConfirmationPage.ktindex d25fc94c75..dd8eeedde5 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/ConfirmationPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/ConfirmationPage.kt@@ -42,12 +42,12 @@ import com.vayunmathur.travel.domain.isTripPollingStatus import com.vayunmathur.travel.domain.tripStatusLabel import com.vayunmathur.travel.platform.CardPaymentResult import com.vayunmathur.travel.platform.rememberCardPayment-import com.vayunmathur.travel.util.CheckoutState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.TripPollState-import com.vayunmathur.travel.util.confirmPaidTrip-import com.vayunmathur.travel.util.pollTrip-import com.vayunmathur.travel.util.recheckoutForStoredTrip+import com.vayunmathur.travel.platform.CheckoutState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.TripPollState+import com.vayunmathur.travel.platform.confirmPaidTrip+import com.vayunmathur.travel.platform.pollTrip+import com.vayunmathur.travel.platform.recheckoutForStoredTrip import androidx.compose.ui.res.stringResource  /**
travel/src/main/java/com/vayunmathur/travel/ui/FareSelectPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/FareSelectPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/FareSelectPage.ktnew file mode 100644index 0000000000..e061d9fdbd--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/FareSelectPage.kt@@ -0,0 +1,70 @@+package com.vayunmathur.travel.ui+import com.vayunmathur.travel.R++import androidx.compose.foundation.clickable+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.lazy.LazyListScope+import androidx.compose.foundation.lazy.items+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateListOf+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp+import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.library.ui.AssistChip+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.ElevatedCard+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.LazyListScaffold+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TopAppBar+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.travel.Route+import com.vayunmathur.travel.domain.groupInboundSlices+import com.vayunmathur.travel.domain.groupOutboundSlices+import com.vayunmathur.travel.domain.sliceSignature+import com.vayunmathur.travel.network.OfferDto+import com.vayunmathur.travel.platform.FlightQuery+import com.vayunmathur.travel.platform.PartialFlowState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.loadPartialFares+import com.vayunmathur.travel.platform.selectOffer+import com.vayunmathur.travel.platform.startPartialSearch+import androidx.compose.ui.res.stringResource++@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun FareSelectPage(+    backStack: NavBackStack<Route>,+    viewModel: TravelViewModel,+    route: Route.FareSelect,+) {+    LaunchedEffect(route.outboundSignature, route.inboundSignature) {+        viewModel.loadPartialFares(route.outboundSignature, route.inboundSignature)+    }+    val state by viewModel.partialFlow.collectAsStateWithLifecycle()+    PartialScaffold(+        title = stringResource(R.string.choose_fare),+        subtitle = stringResource(R.string.step_2_of_2),+        backStack = backStack,+        state = state,+        isEmpty = state.offers.isEmpty(),+    ) {+        items(state.offers) { offer ->+            FareCard(offer) {+                viewModel.selectOffer(offer)+                backStack.add(Route.OfferReview(offer.offerId))+            }+        }+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsPage.ktindex a88b658ce8..478c599a18 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsPage.kt@@ -40,17 +40,17 @@ import com.vayunmathur.travel.Route import com.vayunmathur.travel.R import com.vayunmathur.travel.network.OfferDto import com.vayunmathur.travel.network.SliceDto-import com.vayunmathur.travel.util.FlightQuery-import com.vayunmathur.travel.util.FlightResultsActions-import com.vayunmathur.travel.util.FlightResultsState-import com.vayunmathur.travel.util.OfferSort-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.searchFlights-import com.vayunmathur.travel.util.selectOffer-import com.vayunmathur.travel.util.setFareBrandFilter-import com.vayunmathur.travel.util.setMaxStopsFilter-import com.vayunmathur.travel.util.setSort-import com.vayunmathur.travel.util.toggleAirlineFilter+import com.vayunmathur.travel.platform.FlightQuery+import com.vayunmathur.travel.platform.FlightResultsActions+import com.vayunmathur.travel.platform.FlightResultsState+import com.vayunmathur.travel.platform.OfferSort+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.searchFlights+import com.vayunmathur.travel.platform.selectOffer+import com.vayunmathur.travel.platform.setFareBrandFilter+import com.vayunmathur.travel.platform.setMaxStopsFilter+import com.vayunmathur.travel.platform.setSort+import com.vayunmathur.travel.platform.toggleAirlineFilter import androidx.compose.ui.res.stringResource  /** Binds [TravelViewModel] and the back stack to the stateless [FlightResultsScreen]. */@@ -94,232 +94,3 @@ fun FlightResultsPage(      FlightResultsScreen(title = title, state = state, actions = actions) }--/**- * The offer list, with no dependency on the ViewModel or the back stack so it can be- * rendered from a `@Preview` — see `src/screenshotTest`, which is where the store listing- * images come from.- */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun FlightResultsScreen(-    title: String,-    state: FlightResultsState,-    actions: FlightResultsActions,-) {-    LazyListScaffold(-        topBar = {-            TopAppBar(-                title = { Text(title) },-                navigationIcon = { IconNavigation { actions.back() } },-            )-        },-        scrollBehavior = appBarScrollBehavior(),-    ) {-        val visible = state.visibleOffers-        val expiry = visible.mapNotNull { it.expiresAt.ifBlank { null } }.minOrNull()-        if (state.allOffers.isNotEmpty()) {-            item { SortRow(state.sort) { actions.setSort(it) } }-            item {-                FilterRow(-                    maxStops = state.filters.maxStops,-                    airlines = state.availableAirlines,-                    selectedAirlines = state.filters.airlines,-                    fareBrands = state.availableFareBrands,-                    selectedFareBrand = state.filters.fareBrand,-                    onMaxStops = { actions.setMaxStopsFilter(it) },-                    onToggleAirline = { actions.toggleAirlineFilter(it) },-                    onSelectFareBrand = { actions.setFareBrandFilter(it) },-                )-            }-        }-        if (expiry != null && visible.isNotEmpty()) {-            item { OfferExpiryBanner(expiry) { actions.refreshOffers() } }-        }-        items(visible) { offer ->-            OfferCard(offer) { actions.openOffer(offer) }-        }-        if (state.loading || state.error != null || (state.hasSearched && visible.isEmpty())) {-            item {-                StatusBox(-                    loading = state.loading,-                    error = state.error,-                    isEmpty = state.hasSearched && visible.isEmpty(),-                )-            }-        }-    }-}--@Composable-private fun SortRow(current: OfferSort, onSort: (OfferSort) -> Unit) {-    Row(-        Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp, vertical = 4.dp),-        horizontalArrangement = Arrangement.spacedBy(8.dp),-    ) {-        OfferSort.entries.forEach { sort ->-            FilterChip(-                selected = current == sort,-                onClick = { onSort(sort) },-                label = { Text(stringResource(sort.label)) },-            )-        }-    }-}--@Composable-private fun FilterRow(-    maxStops: Int?,-    airlines: List<String>,-    selectedAirlines: Set<String>,-    fareBrands: List<String>,-    selectedFareBrand: String?,-    onMaxStops: (Int?) -> Unit,-    onToggleAirline: (String) -> Unit,-    onSelectFareBrand: (String?) -> Unit,-) {-    Row(-        Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp, vertical = 4.dp),-        horizontalArrangement = Arrangement.spacedBy(8.dp),-    ) {-        FilterChip(selected = maxStops == null, onClick = { onMaxStops(null) }, label = { Text(stringResource(R.string.any_stops)) })-        FilterChip(selected = maxStops == 0, onClick = { onMaxStops(0) }, label = { Text(stringResource(R.string.nonstop)) })-        FilterChip(selected = maxStops == 1, onClick = { onMaxStops(1) }, label = { Text(stringResource(R.string.n_1_stop)) })-        fareBrands.forEach { brand ->-            FilterChip(-                selected = brand == selectedFareBrand,-                onClick = { onSelectFareBrand(if (brand == selectedFareBrand) null else brand) },-                label = { Text(brand) },-            )-        }-        airlines.forEach { iata ->-            FilterChip(-                selected = iata in selectedAirlines,-                onClick = { onToggleAirline(iata) },-                label = { Text(iata) },-            )-        }-    }-}--/**- * A slim banner showing how long the current prices are held. When the hold- * lapses (only tracked while the app is in the foreground) it calls [onExpired]- * to reload fresh offers.- */-@Composable-private fun OfferExpiryBanner(expiresAt: String, onExpired: () -> Unit) {-    val remaining = rememberSecondsUntil(expiresAt)-    LaunchedEffect(remaining <= 0L) { if (remaining <= 0L) onExpired() }-    val expired = remaining <= 0L-    Surface(-        color = MaterialTheme.colorScheme.secondaryContainer,-        modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 4.dp),-        shape = androidx.compose.foundation.shape.RoundedCornerShape(8.dp),-    ) {-        Row(-            Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 8.dp),-            verticalAlignment = Alignment.CenterVertically,-            horizontalArrangement = Arrangement.spacedBy(8.dp),-        ) {-            if (expired) {-                CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp)-                Text(stringResource(R.string.refreshing_prices), style = MaterialTheme.typography.bodySmall)-            } else {-                Text(-                    stringResource(R.string.prices_held, formatCountdown(remaining)),-                    style = MaterialTheme.typography.bodySmall,-                    color = MaterialTheme.colorScheme.onSecondaryContainer,-                )-            }-        }-    }-}--/** A single bookable offer row. */-@Composable-internal fun OfferCard(offer: OfferDto, onClick: () -> Unit) {-    ElevatedCard(-        modifier = Modifier-            .fillMaxWidth()-            .padding(horizontal = 16.dp, vertical = 4.dp)-            .clickable { onClick() },-    ) {-        Row(-            Modifier.fillMaxWidth().padding(16.dp),-            verticalAlignment = Alignment.Top,-            horizontalArrangement = Arrangement.spacedBy(12.dp),-        ) {-            AirlineLogo(-                offer.ownerLogoUrl,-                offer.ownerIata,-                modifier = Modifier.sharedContainer("travel-offer-logo-${offer.offerId}"),-            )-            Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(6.dp)) {-                Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {-                    Text(-                        offer.owner.ifBlank { stringResource(R.string.flight) },-                        style = MaterialTheme.typography.titleMedium,-                        modifier = Modifier.sharedText("travel-offer-owner-${offer.offerId}"),-                    )-                    if (offer.fareBrand.isNotBlank()) {-                        FareBrandBadge(offer.fareBrand)-                    }-                }-                offer.slices.forEach { slice -> SliceRow(slice) }-                val chips = conditionsLabels(offer.conditions)-                val bags = offer.baggageSummary-                if (chips.isNotEmpty() || bags.isNotEmpty()) {-                    Row(-                        Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),-                        horizontalArrangement = Arrangement.spacedBy(6.dp),-                    ) {-                        chips.forEach { AssistChip(onClick = {}, label = { Text(it) }) }-                        if (bags.isNotEmpty()) AssistChip(onClick = {}, label = { Text(bags) })-                    }-                }-            }-            Text(-                formatMoney(offer.totalAmount, offer.currency),-                style = MaterialTheme.typography.titleMedium,-                color = MaterialTheme.colorScheme.primary,-                fontWeight = FontWeight.SemiBold,-            )-        }-    }-}--@Composable-private fun FareBrandBadge(brand: String) {-    Surface(-        color = MaterialTheme.colorScheme.tertiaryContainer,-        shape = androidx.compose.foundation.shape.RoundedCornerShape(6.dp),-    ) {-        Text(-            brand,-            style = MaterialTheme.typography.labelSmall,-            color = MaterialTheme.colorScheme.onTertiaryContainer,-            modifier = Modifier.padding(horizontal = 8.dp, vertical = 2.dp),-        )-    }-}--@Composable-private fun SliceRow(slice: SliceDto) {-    val is24 = rememberIs24Hour()-    val times = "${formatTime(slice.departureAt, is24)} – ${formatTime(slice.arrivalAt, is24)}"-    val meta = listOf(stopsLabel(slice.stops), formatDuration(slice.durationMinutes))-        .filter { it.isNotBlank() }-        .joinToString(" · ")-    Column {-        Text(-            "${slice.origin} → ${slice.destination}  ·  $times",-            style = MaterialTheme.typography.bodyMedium,-        )-        Text(-            meta,-            style = MaterialTheme.typography.bodySmall,-            color = MaterialTheme.colorScheme.onSurfaceVariant,-        )-    }-}
travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsScreen.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsScreen.kt b/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsScreen.ktnew file mode 100644index 0000000000..65f27604df--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsScreen.kt@@ -0,0 +1,283 @@+package com.vayunmathur.travel.ui++import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+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.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.rememberScrollState+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.library.ui.AssistChip+import com.vayunmathur.library.ui.rememberIs24Hour+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.ElevatedCard+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.FilterChip+import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.LazyListScaffold+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TopAppBar+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.util.sharedContainer+import com.vayunmathur.library.util.sharedText+import com.vayunmathur.travel.Route+import com.vayunmathur.travel.R+import com.vayunmathur.travel.network.OfferDto+import com.vayunmathur.travel.network.SliceDto+import com.vayunmathur.travel.platform.FlightQuery+import com.vayunmathur.travel.platform.FlightResultsActions+import com.vayunmathur.travel.platform.FlightResultsState+import com.vayunmathur.travel.platform.OfferSort+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.searchFlights+import com.vayunmathur.travel.platform.selectOffer+import com.vayunmathur.travel.platform.setFareBrandFilter+import com.vayunmathur.travel.platform.setMaxStopsFilter+import com.vayunmathur.travel.platform.setSort+import com.vayunmathur.travel.platform.toggleAirlineFilter+import androidx.compose.ui.res.stringResource++/**+ * The offer list, with no dependency on the ViewModel or the back stack so it can be+ * rendered from a `@Preview` — see `src/screenshotTest`, which is where the store listing+ * images come from.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun FlightResultsScreen(+    title: String,+    state: FlightResultsState,+    actions: FlightResultsActions,+) {+    LazyListScaffold(+        topBar = {+            TopAppBar(+                title = { Text(title) },+                navigationIcon = { IconNavigation { actions.back() } },+            )+        },+        scrollBehavior = appBarScrollBehavior(),+    ) {+        val visible = state.visibleOffers+        val expiry = visible.mapNotNull { it.expiresAt.ifBlank { null } }.minOrNull()+        if (state.allOffers.isNotEmpty()) {+            item { SortRow(state.sort) { actions.setSort(it) } }+            item {+                FilterRow(+                    maxStops = state.filters.maxStops,+                    airlines = state.availableAirlines,+                    selectedAirlines = state.filters.airlines,+                    fareBrands = state.availableFareBrands,+                    selectedFareBrand = state.filters.fareBrand,+                    onMaxStops = { actions.setMaxStopsFilter(it) },+                    onToggleAirline = { actions.toggleAirlineFilter(it) },+                    onSelectFareBrand = { actions.setFareBrandFilter(it) },+                )+            }+        }+        if (expiry != null && visible.isNotEmpty()) {+            item { OfferExpiryBanner(expiry) { actions.refreshOffers() } }+        }+        items(visible) { offer ->+            OfferCard(offer) { actions.openOffer(offer) }+        }+        if (state.loading || state.error != null || (state.hasSearched && visible.isEmpty())) {+            item {+                StatusBox(+                    loading = state.loading,+                    error = state.error,+                    isEmpty = state.hasSearched && visible.isEmpty(),+                )+            }+        }+    }+}++@Composable+private fun SortRow(current: OfferSort, onSort: (OfferSort) -> Unit) {+    Row(+        Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp, vertical = 4.dp),+        horizontalArrangement = Arrangement.spacedBy(8.dp),+    ) {+        OfferSort.entries.forEach { sort ->+            FilterChip(+                selected = current == sort,+                onClick = { onSort(sort) },+                label = { Text(stringResource(sort.label)) },+            )+        }+    }+}++@Composable+private fun FilterRow(+    maxStops: Int?,+    airlines: List<String>,+    selectedAirlines: Set<String>,+    fareBrands: List<String>,+    selectedFareBrand: String?,+    onMaxStops: (Int?) -> Unit,+    onToggleAirline: (String) -> Unit,+    onSelectFareBrand: (String?) -> Unit,+) {+    Row(+        Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp, vertical = 4.dp),+        horizontalArrangement = Arrangement.spacedBy(8.dp),+    ) {+        FilterChip(selected = maxStops == null, onClick = { onMaxStops(null) }, label = { Text(stringResource(R.string.any_stops)) })+        FilterChip(selected = maxStops == 0, onClick = { onMaxStops(0) }, label = { Text(stringResource(R.string.nonstop)) })+        FilterChip(selected = maxStops == 1, onClick = { onMaxStops(1) }, label = { Text(stringResource(R.string.n_1_stop)) })+        fareBrands.forEach { brand ->+            FilterChip(+                selected = brand == selectedFareBrand,+                onClick = { onSelectFareBrand(if (brand == selectedFareBrand) null else brand) },+                label = { Text(brand) },+            )+        }+        airlines.forEach { iata ->+            FilterChip(+                selected = iata in selectedAirlines,+                onClick = { onToggleAirline(iata) },+                label = { Text(iata) },+            )+        }+    }+}++/**+ * A slim banner showing how long the current prices are held. When the hold+ * lapses (only tracked while the app is in the foreground) it calls [onExpired]+ * to reload fresh offers.+ */+@Composable+private fun OfferExpiryBanner(expiresAt: String, onExpired: () -> Unit) {+    val remaining = rememberSecondsUntil(expiresAt)+    LaunchedEffect(remaining <= 0L) { if (remaining <= 0L) onExpired() }+    val expired = remaining <= 0L+    Surface(+        color = MaterialTheme.colorScheme.secondaryContainer,+        modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 4.dp),+        shape = androidx.compose.foundation.shape.RoundedCornerShape(8.dp),+    ) {+        Row(+            Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 8.dp),+            verticalAlignment = Alignment.CenterVertically,+            horizontalArrangement = Arrangement.spacedBy(8.dp),+        ) {+            if (expired) {+                CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp)+                Text(stringResource(R.string.refreshing_prices), style = MaterialTheme.typography.bodySmall)+            } else {+                Text(+                    stringResource(R.string.prices_held, formatCountdown(remaining)),+                    style = MaterialTheme.typography.bodySmall,+                    color = MaterialTheme.colorScheme.onSecondaryContainer,+                )+            }+        }+    }+}++/** A single bookable offer row. */+@Composable+internal fun OfferCard(offer: OfferDto, onClick: () -> Unit) {+    ElevatedCard(+        modifier = Modifier+            .fillMaxWidth()+            .padding(horizontal = 16.dp, vertical = 4.dp)+            .clickable { onClick() },+    ) {+        Row(+            Modifier.fillMaxWidth().padding(16.dp),+            verticalAlignment = Alignment.Top,+            horizontalArrangement = Arrangement.spacedBy(12.dp),+        ) {+            AirlineLogo(+                offer.ownerLogoUrl,+                offer.ownerIata,+                modifier = Modifier.sharedContainer("travel-offer-logo-${offer.offerId}"),+            )+            Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(6.dp)) {+                Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {+                    Text(+                        offer.owner.ifBlank { stringResource(R.string.flight) },+                        style = MaterialTheme.typography.titleMedium,+                        modifier = Modifier.sharedText("travel-offer-owner-${offer.offerId}"),+                    )+                    if (offer.fareBrand.isNotBlank()) {+                        FareBrandBadge(offer.fareBrand)+                    }+                }+                offer.slices.forEach { slice -> SliceRow(slice) }+                val chips = conditionsLabels(offer.conditions)+                val bags = offer.baggageSummary+                if (chips.isNotEmpty() || bags.isNotEmpty()) {+                    Row(+                        Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),+                        horizontalArrangement = Arrangement.spacedBy(6.dp),+                    ) {+                        chips.forEach { AssistChip(onClick = {}, label = { Text(it) }) }+                        if (bags.isNotEmpty()) AssistChip(onClick = {}, label = { Text(bags) })+                    }+                }+            }+            Text(+                formatMoney(offer.totalAmount, offer.currency),+                style = MaterialTheme.typography.titleMedium,+                color = MaterialTheme.colorScheme.primary,+                fontWeight = FontWeight.SemiBold,+            )+        }+    }+}++@Composable+private fun FareBrandBadge(brand: String) {+    Surface(+        color = MaterialTheme.colorScheme.tertiaryContainer,+        shape = androidx.compose.foundation.shape.RoundedCornerShape(6.dp),+    ) {+        Text(+            brand,+            style = MaterialTheme.typography.labelSmall,+            color = MaterialTheme.colorScheme.onTertiaryContainer,+            modifier = Modifier.padding(horizontal = 8.dp, vertical = 2.dp),+        )+    }+}++@Composable+private fun SliceRow(slice: SliceDto) {+    val is24 = rememberIs24Hour()+    val times = "${formatTime(slice.departureAt, is24)} – ${formatTime(slice.arrivalAt, is24)}"+    val meta = listOf(stopsLabel(slice.stops), formatDuration(slice.durationMinutes))+        .filter { it.isNotBlank() }+        .joinToString(" · ")+    Column {+        Text(+            "${slice.origin} → ${slice.destination}  ·  $times",+            style = MaterialTheme.typography.bodyMedium,+        )+        Text(+            meta,+            style = MaterialTheme.typography.bodySmall,+            color = MaterialTheme.colorScheme.onSurfaceVariant,+        )+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/FlightSearchForm.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/FlightSearchForm.kt b/travel/src/main/java/com/vayunmathur/travel/ui/FlightSearchForm.ktindex 08f252a5ce..2852ebc1b9 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/FlightSearchForm.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/FlightSearchForm.kt@@ -19,8 +19,8 @@ import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconSwapLanguages import com.vayunmathur.library.ui.Text-import com.vayunmathur.travel.util.FlightQuery-import com.vayunmathur.travel.util.TravelViewModel+import com.vayunmathur.travel.platform.FlightQuery+import com.vayunmathur.travel.platform.TravelViewModel import androidx.compose.ui.res.stringResource import androidx.annotation.StringRes import com.vayunmathur.travel.R
travel/src/main/java/com/vayunmathur/travel/ui/HomePage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/HomePage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/HomePage.ktindex 49e7475247..78ceaacf67 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/HomePage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/HomePage.kt@@ -40,8 +40,8 @@ import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.travel.Route import com.vayunmathur.travel.data.BookedTrip import com.vayunmathur.travel.data.RecentSearch-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.clearRecents+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.clearRecents import androidx.compose.ui.res.stringResource import com.vayunmathur.travel.R 
travel/src/main/java/com/vayunmathur/travel/ui/OfferReviewPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/OfferReviewPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/OfferReviewPage.ktindex 4a50aa0fa3..ff175f42c5 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/OfferReviewPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/OfferReviewPage.kt@@ -34,12 +34,12 @@ import com.vayunmathur.library.util.sharedText import com.vayunmathur.travel.Route import com.vayunmathur.travel.network.OfferDto import com.vayunmathur.travel.network.SliceDto-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.airlineName-import com.vayunmathur.travel.util.initPassengers-import com.vayunmathur.travel.util.loadAircraft-import com.vayunmathur.travel.util.loadCities-import com.vayunmathur.travel.util.refreshOffer+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.airlineName+import com.vayunmathur.travel.platform.initPassengers+import com.vayunmathur.travel.platform.loadAircraft+import com.vayunmathur.travel.platform.loadCities+import com.vayunmathur.travel.platform.refreshOffer import androidx.compose.ui.res.stringResource  @OptIn(ExperimentalMaterial3Api::class)
travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailPage.ktindex 60cdde0aa7..21ee251354 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailPage.kt@@ -29,13 +29,13 @@ import com.vayunmathur.travel.Route import com.vayunmathur.travel.domain.isCheckoutUnexpired import com.vayunmathur.travel.network.OrderDetailDto import com.vayunmathur.travel.network.SliceDto-import com.vayunmathur.travel.util.CheckoutState-import com.vayunmathur.travel.util.OrderDetailActions-import com.vayunmathur.travel.util.OrderDetailUiState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.acceptNewPrice-import com.vayunmathur.travel.util.loadBookingDetail-import com.vayunmathur.travel.util.refreshBookingDetail+import com.vayunmathur.travel.platform.CheckoutState+import com.vayunmathur.travel.platform.OrderDetailActions+import com.vayunmathur.travel.platform.OrderDetailUiState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.acceptNewPrice+import com.vayunmathur.travel.platform.loadBookingDetail+import com.vayunmathur.travel.platform.refreshBookingDetail import androidx.compose.ui.res.stringResource  /** Binds [TravelViewModel] and the back stack to the stateless [OrderDetailScreen]. */@@ -81,195 +81,3 @@ fun OrderDetailPage(         actions = actions,     ) }--/**- * A booked trip, with no dependency on the ViewModel or the back stack so it can be- * rendered from a `@Preview` — see `src/screenshotTest`, which is where the store listing- * images come from.- */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun OrderDetailScreen(-    state: OrderDetailUiState,-    actions: OrderDetailActions,-    pendingCheckout: Boolean = false,-) {-    DetailScaffold(-        title = stringResource(R.string.order),-        onNavigateBack = { actions.back() },-        scrollBehavior = appBarScrollBehavior(),-    ) {-        val order = state.order-        if (order == null) {-            StatusBox(-                loading = state.loading,-                error = state.error,-                isEmpty = !state.loading && state.error == null,-                emptyMessage = stringResource(R.string.order_not_found),-            )-            return@DetailScaffold-        }--        ElevatedCard(Modifier.fillMaxWidth()) {-                Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {-                    OrderRow(stringResource(R.string.booking_reference), order.bookingReference, emphasize = true)-                    HorizontalDivider()-                    OrderRow(stringResource(R.string.status_label), order.status.replaceFirstChar(Char::uppercase))-                    OrderRow(stringResource(R.string.total), formatMoney(order.totalAmount, order.currency))-                    if (order.passengerNames.isNotEmpty()) {-                        OrderRow(stringResource(R.string.passengers_label), order.passengerNames.joinToString(", "))-                    }-                    if (order.ticketNumbers.isNotEmpty()) {-                        OrderRow(stringResource(R.string.ticket_numbers), order.ticketNumbers.joinToString(", "))-                    }-                }-            }--            order.hotel?.let { hotel ->-                ElevatedCard(Modifier.fillMaxWidth()) {-                    Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {-                        Text(hotel.name, style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary)-                        if (hotel.address.isNotBlank()) {-                            Text(hotel.address, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)-                        }-                        if (hotel.checkIn.isNotBlank() || hotel.checkOut.isNotBlank()) {-                            Text(-                                "${hotel.checkIn} → ${hotel.checkOut}",-                                style = MaterialTheme.typography.bodySmall,-                                color = MaterialTheme.colorScheme.onSurfaceVariant,-                            )-                        }-                        if (hotel.roomName.isNotBlank() || hotel.boardName.isNotBlank()) {-                            Text(-                                listOf(hotel.roomName, hotel.boardName).filter { it.isNotBlank() }.joinToString(" · "),-                                style = MaterialTheme.typography.bodySmall,-                                color = MaterialTheme.colorScheme.onSurfaceVariant,-                            )-                        }-                    }-                }-            }--            order.slices.forEachIndexed { index, slice ->-                OrderSliceCard(-                    title = if (order.slices.size > 1) stringResource(R.string.flight_n, index + 1) else stringResource(R.string.itinerary),-                    slice = slice,-                )-            }--            if (pendingCheckout) {-                val loading = state.checkout is CheckoutState.Loading-                (state.checkout as? CheckoutState.Error)?.let {-                    Text(it.message, color = MaterialTheme.colorScheme.error, style = MaterialTheme.typography.bodySmall)-                }-                val fresh = (state.checkout as? CheckoutState.Ready)-                if (fresh?.checkout?.priceChanged == true) {-                    PriceChangeNotice(-                        original = fresh.checkout.originalAmount.orEmpty(),-                        current = fresh.checkout.totalAmount,-                        currency = fresh.checkout.currency,-                        accepted = fresh.acceptedNewPrice,-                        onAccept = { actions.acceptNewPrice() },-                    )-                }-                Button(-                    onClick = { actions.completePayment() },-                    enabled = !loading && (fresh == null || !fresh.checkout.priceChanged || fresh.acceptedNewPrice),-                    modifier = Modifier.fillMaxWidth(),-                ) { Text(stringResource(R.string.complete_payment)) }-            }--            OutlinedButton(-                onClick = { actions.refresh() },-                enabled = !state.refreshing,-                modifier = Modifier.fillMaxWidth(),-            ) { Text(stringResource(R.string.refresh_status)) }--            if (order.status != "cancelled") {-                if (order.canChange) {-                    OutlinedButton(-                        onClick = { actions.openChange(order.orderId) },-                        modifier = Modifier.fillMaxWidth(),-                    ) { Text(stringResource(R.string.change_flights)) }-                }-                if (order.canCancel) {-                    OutlinedButton(-                        onClick = { actions.openCancel(order.orderId) },-                        modifier = Modifier.fillMaxWidth(),-                    ) { Text(stringResource(R.string.cancel_order)) }-                }-            }-    }-}--@Composable-private fun PriceChangeNotice(-    original: String,-    current: String,-    currency: String,-    accepted: Boolean,-    onAccept: () -> Unit,-) {-    ElevatedCard(Modifier.fillMaxWidth()) {-        Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {-            Text(-                stringResource(R.string.price_changed_title),-                style = MaterialTheme.typography.titleSmall,-                color = MaterialTheme.colorScheme.primary,-            )-            Text(-                stringResource(-                    R.string.price_changed_summary,-                    if (original.isNotBlank()) formatMoney(original, currency) else "—",-                    formatMoney(current, currency)-                ),-                style = MaterialTheme.typography.bodyMedium,-            )-            Row(verticalAlignment = androidx.compose.ui.Alignment.CenterVertically) {-                com.vayunmathur.library.ui.Checkbox(checked = accepted, onCheckedChange = { if (it) onAccept() })-                Text(-                    stringResource(R.string.accept_new_price),-                    style = MaterialTheme.typography.bodyMedium,-                    modifier = Modifier.padding(start = 8.dp),-                )-            }-        }-    }-}--@Composable-private fun OrderSliceCard(title: String, slice: SliceDto) {-    val is24 = rememberIs24Hour()-    ElevatedCard(Modifier.fillMaxWidth()) {-        Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {-            Text(title, style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary)-            slice.segments.forEach { seg ->-                Text(-                    "${seg.origin} ${formatTime(seg.departureAt, is24)}  →  ${seg.destination} ${formatTime(seg.arrivalAt, is24)}",-                    style = MaterialTheme.typography.bodyMedium,-                )-                val carrier = listOf(seg.carrier, seg.flightNumber).filter { it.isNotBlank() }.joinToString(" ")-                if (carrier.isNotBlank()) {-                    Text(-                        carrier,-                        style = MaterialTheme.typography.bodySmall,-                        color = MaterialTheme.colorScheme.onSurfaceVariant,-                    )-                }-            }-        }-    }-}--@Composable-private fun OrderRow(label: String, value: String, emphasize: Boolean = false) {-    Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {-        Text(label, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)-        Text(-            value,-            style = if (emphasize) MaterialTheme.typography.titleMedium else MaterialTheme.typography.bodyLarge,-            color = if (emphasize) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurface,-            fontWeight = if (emphasize) FontWeight.SemiBold else FontWeight.Normal,-        )-    }-}
travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailScreen.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailScreen.kt b/travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailScreen.ktnew file mode 100644index 0000000000..f9fb1ad092--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/OrderDetailScreen.kt@@ -0,0 +1,231 @@+package com.vayunmathur.travel.ui+import com.vayunmathur.travel.R++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.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.rememberIs24Hour+import com.vayunmathur.library.ui.DetailScaffold+import com.vayunmathur.library.ui.ElevatedCard+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.HorizontalDivider+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.travel.Route+import com.vayunmathur.travel.domain.isCheckoutUnexpired+import com.vayunmathur.travel.network.OrderDetailDto+import com.vayunmathur.travel.network.SliceDto+import com.vayunmathur.travel.platform.CheckoutState+import com.vayunmathur.travel.platform.OrderDetailActions+import com.vayunmathur.travel.platform.OrderDetailUiState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.acceptNewPrice+import com.vayunmathur.travel.platform.loadBookingDetail+import com.vayunmathur.travel.platform.refreshBookingDetail+import androidx.compose.ui.res.stringResource++/**+ * A booked trip, with no dependency on the ViewModel or the back stack so it can be+ * rendered from a `@Preview` — see `src/screenshotTest`, which is where the store listing+ * images come from.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun OrderDetailScreen(+    state: OrderDetailUiState,+    actions: OrderDetailActions,+    pendingCheckout: Boolean = false,+) {+    DetailScaffold(+        title = stringResource(R.string.order),+        onNavigateBack = { actions.back() },+        scrollBehavior = appBarScrollBehavior(),+    ) {+        val order = state.order+        if (order == null) {+            StatusBox(+                loading = state.loading,+                error = state.error,+                isEmpty = !state.loading && state.error == null,+                emptyMessage = stringResource(R.string.order_not_found),+            )+            return@DetailScaffold+        }++        ElevatedCard(Modifier.fillMaxWidth()) {+                Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {+                    OrderRow(stringResource(R.string.booking_reference), order.bookingReference, emphasize = true)+                    HorizontalDivider()+                    OrderRow(stringResource(R.string.status_label), order.status.replaceFirstChar(Char::uppercase))+                    OrderRow(stringResource(R.string.total), formatMoney(order.totalAmount, order.currency))+                    if (order.passengerNames.isNotEmpty()) {+                        OrderRow(stringResource(R.string.passengers_label), order.passengerNames.joinToString(", "))+                    }+                    if (order.ticketNumbers.isNotEmpty()) {+                        OrderRow(stringResource(R.string.ticket_numbers), order.ticketNumbers.joinToString(", "))+                    }+                }+            }++            order.hotel?.let { hotel ->+                ElevatedCard(Modifier.fillMaxWidth()) {+                    Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {+                        Text(hotel.name, style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary)+                        if (hotel.address.isNotBlank()) {+                            Text(hotel.address, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)+                        }+                        if (hotel.checkIn.isNotBlank() || hotel.checkOut.isNotBlank()) {+                            Text(+                                "${hotel.checkIn} → ${hotel.checkOut}",+                                style = MaterialTheme.typography.bodySmall,+                                color = MaterialTheme.colorScheme.onSurfaceVariant,+                            )+                        }+                        if (hotel.roomName.isNotBlank() || hotel.boardName.isNotBlank()) {+                            Text(+                                listOf(hotel.roomName, hotel.boardName).filter { it.isNotBlank() }.joinToString(" · "),+                                style = MaterialTheme.typography.bodySmall,+                                color = MaterialTheme.colorScheme.onSurfaceVariant,+                            )+                        }+                    }+                }+            }++            order.slices.forEachIndexed { index, slice ->+                OrderSliceCard(+                    title = if (order.slices.size > 1) stringResource(R.string.flight_n, index + 1) else stringResource(R.string.itinerary),+                    slice = slice,+                )+            }++            if (pendingCheckout) {+                val loading = state.checkout is CheckoutState.Loading+                (state.checkout as? CheckoutState.Error)?.let {+                    Text(it.message, color = MaterialTheme.colorScheme.error, style = MaterialTheme.typography.bodySmall)+                }+                val fresh = (state.checkout as? CheckoutState.Ready)+                if (fresh?.checkout?.priceChanged == true) {+                    PriceChangeNotice(+                        original = fresh.checkout.originalAmount.orEmpty(),+                        current = fresh.checkout.totalAmount,+                        currency = fresh.checkout.currency,+                        accepted = fresh.acceptedNewPrice,+                        onAccept = { actions.acceptNewPrice() },+                    )+                }+                Button(+                    onClick = { actions.completePayment() },+                    enabled = !loading && (fresh == null || !fresh.checkout.priceChanged || fresh.acceptedNewPrice),+                    modifier = Modifier.fillMaxWidth(),+                ) { Text(stringResource(R.string.complete_payment)) }+            }++            OutlinedButton(+                onClick = { actions.refresh() },+                enabled = !state.refreshing,+                modifier = Modifier.fillMaxWidth(),+            ) { Text(stringResource(R.string.refresh_status)) }++            if (order.status != "cancelled") {+                if (order.canChange) {+                    OutlinedButton(+                        onClick = { actions.openChange(order.orderId) },+                        modifier = Modifier.fillMaxWidth(),+                    ) { Text(stringResource(R.string.change_flights)) }+                }+                if (order.canCancel) {+                    OutlinedButton(+                        onClick = { actions.openCancel(order.orderId) },+                        modifier = Modifier.fillMaxWidth(),+                    ) { Text(stringResource(R.string.cancel_order)) }+                }+            }+    }+}++@Composable+private fun PriceChangeNotice(+    original: String,+    current: String,+    currency: String,+    accepted: Boolean,+    onAccept: () -> Unit,+) {+    ElevatedCard(Modifier.fillMaxWidth()) {+        Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {+            Text(+                stringResource(R.string.price_changed_title),+                style = MaterialTheme.typography.titleSmall,+                color = MaterialTheme.colorScheme.primary,+            )+            Text(+                stringResource(+                    R.string.price_changed_summary,+                    if (original.isNotBlank()) formatMoney(original, currency) else "—",+                    formatMoney(current, currency)+                ),+                style = MaterialTheme.typography.bodyMedium,+            )+            Row(verticalAlignment = androidx.compose.ui.Alignment.CenterVertically) {+                com.vayunmathur.library.ui.Checkbox(checked = accepted, onCheckedChange = { if (it) onAccept() })+                Text(+                    stringResource(R.string.accept_new_price),+                    style = MaterialTheme.typography.bodyMedium,+                    modifier = Modifier.padding(start = 8.dp),+                )+            }+        }+    }+}++@Composable+private fun OrderSliceCard(title: String, slice: SliceDto) {+    val is24 = rememberIs24Hour()+    ElevatedCard(Modifier.fillMaxWidth()) {+        Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {+            Text(title, style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary)+            slice.segments.forEach { seg ->+                Text(+                    "${seg.origin} ${formatTime(seg.departureAt, is24)}  →  ${seg.destination} ${formatTime(seg.arrivalAt, is24)}",+                    style = MaterialTheme.typography.bodyMedium,+                )+                val carrier = listOf(seg.carrier, seg.flightNumber).filter { it.isNotBlank() }.joinToString(" ")+                if (carrier.isNotBlank()) {+                    Text(+                        carrier,+                        style = MaterialTheme.typography.bodySmall,+                        color = MaterialTheme.colorScheme.onSurfaceVariant,+                    )+                }+            }+        }+    }+}++@Composable+private fun OrderRow(label: String, value: String, emphasize: Boolean = false) {+    Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {+        Text(label, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)+        Text(+            value,+            style = if (emphasize) MaterialTheme.typography.titleMedium else MaterialTheme.typography.bodyLarge,+            color = if (emphasize) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurface,+            fontWeight = if (emphasize) FontWeight.SemiBold else FontWeight.Normal,+        )+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/PartialOffersPages.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/PartialOffersPages.kt b/travel/src/main/java/com/vayunmathur/travel/ui/PartialOffersPages.ktindex 1428325b16..5b6b9cf780 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/PartialOffersPages.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PartialOffersPages.kt@@ -34,12 +34,12 @@ import com.vayunmathur.travel.domain.groupInboundSlices import com.vayunmathur.travel.domain.groupOutboundSlices import com.vayunmathur.travel.domain.sliceSignature import com.vayunmathur.travel.network.OfferDto-import com.vayunmathur.travel.util.FlightQuery-import com.vayunmathur.travel.util.PartialFlowState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.loadPartialFares-import com.vayunmathur.travel.util.selectOffer-import com.vayunmathur.travel.util.startPartialSearch+import com.vayunmathur.travel.platform.FlightQuery+import com.vayunmathur.travel.platform.PartialFlowState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.loadPartialFares+import com.vayunmathur.travel.platform.selectOffer+import com.vayunmathur.travel.platform.startPartialSearch import androidx.compose.ui.res.stringResource  /**@@ -104,34 +104,7 @@ fun OutboundSelectPage( /** Round-trip step 2: pick the fare for the chosen outbound + return, then review. */ @OptIn(ExperimentalMaterial3Api::class) @Composable-fun FareSelectPage(-    backStack: NavBackStack<Route>,-    viewModel: TravelViewModel,-    route: Route.FareSelect,-) {-    LaunchedEffect(route.outboundSignature, route.inboundSignature) {-        viewModel.loadPartialFares(route.outboundSignature, route.inboundSignature)-    }-    val state by viewModel.partialFlow.collectAsStateWithLifecycle()-    PartialScaffold(-        title = stringResource(R.string.choose_fare),-        subtitle = stringResource(R.string.step_2_of_2),-        backStack = backStack,-        state = state,-        isEmpty = state.offers.isEmpty(),-    ) {-        items(state.offers) { offer ->-            FareCard(offer) {-                viewModel.selectOffer(offer)-                backStack.add(Route.OfferReview(offer.offerId))-            }-        }-    }-}--@OptIn(ExperimentalMaterial3Api::class)-@Composable-private fun PartialScaffold(+internal fun PartialScaffold(     title: String,     subtitle: String,     backStack: NavBackStack<Route>,@@ -176,7 +149,7 @@ private fun PartialScaffold(  /** One fare for a chosen outbound + return: both legs, fare brand, exact total. */ @Composable-private fun FareCard(offer: OfferDto, onClick: () -> Unit) {+internal fun FareCard(offer: OfferDto, onClick: () -> Unit) {     ElevatedCard(         modifier = Modifier             .fillMaxWidth()
travel/src/main/java/com/vayunmathur/travel/ui/PassengerDialog.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/PassengerDialog.kt b/travel/src/main/java/com/vayunmathur/travel/ui/PassengerDialog.ktindex 5c9ea2bb5d..a0cb93316d 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/PassengerDialog.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PassengerDialog.kt@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue@@ -32,10 +33,10 @@ fun PassengerDialog(     onDone: (PassengerMix) -> Unit,     onCancel: () -> Unit, ) {-    var adults by remember(mix) { mutableStateOf(mix.adults) }-    var children by remember(mix) { mutableStateOf(mix.childAges.size) }-    var infantsInSeat by remember(mix) { mutableStateOf(mix.infantsInSeat) }-    var infantsOnLap by remember(mix) { mutableStateOf(mix.infantsOnLap) }+    var adults by remember(mix) { mutableIntStateOf(mix.adults) }+    var children by remember(mix) { mutableIntStateOf(mix.childAges.size) }+    var infantsInSeat by remember(mix) { mutableIntStateOf(mix.infantsInSeat) }+    var infantsOnLap by remember(mix) { mutableIntStateOf(mix.infantsOnLap) }      Dialog(onDismissRequest = onCancel) {         Surface(shape = MaterialTheme.shapes.medium) {
travel/src/main/java/com/vayunmathur/travel/ui/PassengersPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/PassengersPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/PassengersPage.ktindex 98e848662c..bff9b23e4b 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/PassengersPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PassengersPage.kt@@ -41,14 +41,14 @@ import com.vayunmathur.travel.Route import com.vayunmathur.travel.network.AirlineDto import com.vayunmathur.travel.network.OfferPassengerDto import com.vayunmathur.travel.network.PassengerInputDto-import com.vayunmathur.travel.util.BookingState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.createTrip-import com.vayunmathur.travel.util.loadAirlines-import com.vayunmathur.travel.util.prefillFromProfile-import com.vayunmathur.travel.util.updatePassenger-import com.vayunmathur.travel.util.REQUESTED_CONTACT_FIELDS-import com.vayunmathur.travel.util.readSessionContact+import com.vayunmathur.travel.platform.BookingState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.createTrip+import com.vayunmathur.travel.platform.loadAirlines+import com.vayunmathur.travel.platform.prefillFromProfile+import com.vayunmathur.travel.platform.updatePassenger+import com.vayunmathur.travel.platform.REQUESTED_CONTACT_FIELDS+import com.vayunmathur.travel.platform.readSessionContact import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext
travel/src/main/java/com/vayunmathur/travel/ui/PaymentPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/PaymentPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/PaymentPage.ktindex 4d1ab1647b..512e79ce60 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/PaymentPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PaymentPage.kt@@ -35,11 +35,11 @@ import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.travel.Route import com.vayunmathur.travel.platform.CardPaymentResult import com.vayunmathur.travel.platform.rememberCardPayment-import com.vayunmathur.travel.util.CheckoutState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.acceptNewPrice-import com.vayunmathur.travel.util.confirmPaidTrip-import com.vayunmathur.travel.util.startCheckout+import com.vayunmathur.travel.platform.CheckoutState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.acceptNewPrice+import com.vayunmathur.travel.platform.confirmPaidTrip+import com.vayunmathur.travel.platform.startCheckout import androidx.compose.ui.res.stringResource  /**
travel/src/main/java/com/vayunmathur/travel/ui/PlaceAutocompleteField.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/PlaceAutocompleteField.kt b/travel/src/main/java/com/vayunmathur/travel/ui/PlaceAutocompleteField.ktindex 612ada6d26..aeecda098a 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/PlaceAutocompleteField.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PlaceAutocompleteField.kt@@ -25,8 +25,8 @@ import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedTextField import com.vayunmathur.library.ui.Text import com.vayunmathur.travel.network.PlaceDto-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.autocomplete+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.autocomplete  private const val MAX_SUGGESTIONS = 6 
travel/src/main/java/com/vayunmathur/travel/ui/RememberSecondsUntil.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/RememberSecondsUntil.kt b/travel/src/main/java/com/vayunmathur/travel/ui/RememberSecondsUntil.ktnew file mode 100644index 0000000000..b1531f42e9--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/RememberSecondsUntil.kt@@ -0,0 +1,56 @@+package com.vayunmathur.travel.ui++import kotlin.time.Clock+import kotlin.time.Instant+import kotlinx.datetime.LocalDateTime+import com.vayunmathur.library.ui.DateString+import kotlinx.datetime.TimeZone+import kotlinx.datetime.toLocalDateTime+import androidx.compose.foundation.background+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.heightIn+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableLongStateOf+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.draw.clip+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import androidx.lifecycle.Lifecycle+import androidx.lifecycle.compose.LocalLifecycleOwner+import androidx.lifecycle.repeatOnLifecycle+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text++/**+ * Seconds remaining until [expiresAtIso], ticking once per second **only while+ * the app is in the foreground** (`RESUMED`). Backgrounding pauses the ticker;+ * returning resumes it (and reports 0 immediately if it already lapsed).+ */+@Composable+fun rememberSecondsUntil(expiresAtIso: String): Long {+    val lifecycleOwner = LocalLifecycleOwner.current+    var remaining by remember(expiresAtIso) { mutableLongStateOf(secondsUntil(expiresAtIso)) }+    LaunchedEffect(expiresAtIso, lifecycleOwner) {+        lifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {+            while (true) {+                remaining = secondsUntil(expiresAtIso)+                if (remaining <= 0) break+                kotlinx.coroutines.delay(1000)+            }+        }+    }+    return remaining+}
travel/src/main/java/com/vayunmathur/travel/ui/SeatMapPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/SeatMapPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/SeatMapPage.ktindex 653bddc416..07b138e449 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/SeatMapPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/SeatMapPage.kt@@ -50,53 +50,17 @@ import com.vayunmathur.travel.domain.seatedPassengers import com.vayunmathur.travel.network.SeatCabinDto import com.vayunmathur.travel.network.SeatElementDto import com.vayunmathur.travel.network.SeatRowDto-import com.vayunmathur.travel.util.SeatMapActions-import com.vayunmathur.travel.util.SeatMapState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.loadSeatMaps-import com.vayunmathur.travel.util.toggleSeat+import com.vayunmathur.travel.platform.SeatMapActions+import com.vayunmathur.travel.platform.SeatMapState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.loadSeatMaps+import com.vayunmathur.travel.platform.toggleSeat import androidx.compose.ui.res.stringResource -private val CELL = 44.dp-private val GAP = 4.dp-private val AISLE = 22.dp -/**- * Seat maps give variable element counts per section (e.g. a 3-4-3 cabin), and do- * not pad rows to a uniform width, so we can't render elements 1:1 and expect- * columns to line up. Instead we derive a canonical grid per cabin: the ordered- * set of seat-letters in each section. Seats are then placed under their own- * column; amenities (lavatory, galley, exit row…) are rendered as a band that- * spans their whole section block, matching how the aircraft is actually laid out.- */-private class CabinLayout(-    val sectionLetters: List<List<Char>>,-    val sectionWidths: List<Int>,-) -private fun seatLetter(designator: String): Char? = designator.lastOrNull { it.isLetter() } -private fun computeLayout(cabin: SeatCabinDto): CabinLayout {-    val sectionCount = cabin.rows.maxOfOrNull { it.sections.size } ?: 0-    val letters = List(sectionCount) { sortedSetOf<Char>() }-    val maxCounts = IntArray(sectionCount)-    cabin.rows.forEach { row ->-        row.sections.forEachIndexed { s, section ->-            maxCounts[s] = maxOf(maxCounts[s], section.elements.size)-            section.elements.forEach { el ->-                if (el.isSeat) seatLetter(el.designator)?.let { letters[s].add(it) }-            }-        }-    }-    val sectionLetters = letters.map { it.toList() }-    val widths = sectionLetters.mapIndexed { i, l ->-        if (l.isNotEmpty()) l.size else maxCounts[i].coerceAtLeast(1)-    }-    return CabinLayout(sectionLetters, widths)-} -/** Total width a section block occupies (its columns plus the gaps between them). */-private fun blockWidth(columns: Int) = CELL * columns + GAP * (columns - 1).coerceAtLeast(0)  /** Binds [TravelViewModel] and the back stack to the stateless [SeatMapScreen]. */ @Composable@@ -137,208 +101,3 @@ fun SeatMapPage(         passengers = passengers,     ) }---/**- * The seat picker for one segment, with no dependency on the ViewModel or the back stack so- * it can be rendered from a `@Preview` — see `src/screenshotTest`, which is where the store- * listing images come from.- */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun SeatMapScreen(-    segmentId: String,-    state: SeatMapState,-    selectedSeats: Map<String, SeatElementDto>,-    actions: SeatMapActions,-    passengers: List<SeatPassenger> = emptyList(),-) {-    var activePassenger by remember(segmentId, passengers) {-        mutableStateOf(-            passengers.firstOrNull { seatKey(segmentId, it.id) !in selectedSeats }?.id-                ?: passengers.firstOrNull()?.id.orEmpty()-        )-    }-    AppScaffold(-        title = stringResource(R.string.choose_seats),-        onNavigateBack = { actions.back() },-        scrollBehavior = appBarScrollBehavior(),-    ) { padding ->-        val cabins = state.cabins.filter { it.segmentId == segmentId }-        if (state.loading || state.error != null || cabins.isEmpty()) {-            StatusBox(-                loading = state.loading,-                error = state.error,-                isEmpty = !state.loading && state.error == null && cabins.isEmpty(),-                modifier = Modifier.padding(padding),-                emptyMessage = "No seat map available for this flight.",-            )-            return@AppScaffold-        }-        Column(-            Modifier.fillMaxSize().padding(padding).verticalScroll(rememberScrollState()),-        ) {-            SeatLegend()-            if (passengers.size > 1) {-                SeatPassengerPicker(passengers, segmentId, selectedSeats, activePassenger) { activePassenger = it }-            }-            val passengerNumbers = passengers.mapIndexed { i, p -> p.id to i + 1 }.toMap()-            cabins.forEach { cabin ->-                CabinView(cabin, segmentId, selectedSeats, passengerNumbers.takeIf { passengers.size > 1 }) { seat ->-                    actions.toggleSeat(segmentId, activePassenger, seat)-                    // Move on to the next passenger still without a seat.-                    val holder = seatHolder(selectedSeats, segmentId, seat.designator)-                    if (holder == null && passengers.size > 1) {-                        val after = assignSeat(selectedSeats, segmentId, activePassenger, seat)-                        passengers.firstOrNull { seatKey(segmentId, it.id) !in after }?.let { activePassenger = it.id }-                    }-                }-            }-            Button(-                onClick = { actions.done() },-                modifier = Modifier.fillMaxWidth().padding(16.dp),-            ) { Text(stringResource(UiR.string.done)) }-        }-    }-}--@Composable-private fun CabinView(-    cabin: SeatCabinDto,-    segmentId: String,-    selectedSeats: Map<String, SeatElementDto>,-    passengerNumbers: Map<String, Int>?,-    onToggle: (SeatElementDto) -> Unit,-) {-    if (cabin.cabinClass.isNotBlank()) {-        Text(-            cabin.cabinClass.replace('_', ' ').replaceFirstChar { it.uppercase() },-            style = MaterialTheme.typography.titleSmall,-            color = MaterialTheme.colorScheme.primary,-            modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),-        )-    }-    val layout = remember(cabin) { computeLayout(cabin) }-    // Rows share one horizontal scroll so columns stay aligned across the cabin.-    Column(-        Modifier.horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp),-        verticalArrangement = Arrangement.spacedBy(GAP),-    ) {-        cabin.rows.forEach { row -> SeatRowView(row, layout, segmentId, selectedSeats, passengerNumbers, onToggle) }-    }-}--@Composable-private fun SeatRowView(-    row: SeatRowDto,-    layout: CabinLayout,-    segmentId: String,-    selectedSeats: Map<String, SeatElementDto>,-    passengerNumbers: Map<String, Int>?,-    onToggle: (SeatElementDto) -> Unit,-) {-    Row(verticalAlignment = Alignment.CenterVertically) {-        layout.sectionWidths.indices.forEach { s ->-            if (s > 0) Spacer(Modifier.width(AISLE))-            val elements = row.sections.getOrNull(s)?.elements ?: emptyList()-            val letters = layout.sectionLetters[s]-            if (elements.any { it.isSeat } && letters.isNotEmpty()) {-                Row(horizontalArrangement = Arrangement.spacedBy(GAP)) {-                    letters.forEach { letter ->-                        val seat = elements.firstOrNull { it.isSeat && seatLetter(it.designator) == letter }-                        if (seat != null) {-                            val holder = seatHolder(selectedSeats, segmentId, seat.designator)-                            val badge = holder?.let { passengerNumbers?.get(it) }?.let { "P$it" }-                            SeatChip(seat, holder != null, badge) { onToggle(seat) }-                        } else {-                            Spacer(Modifier.size(CELL))-                        }-                    }-                }-            } else {-                val type = elements.firstOrNull { it.type.isNotBlank() && it.type != "empty" }?.type-                AmenityBand(type, layout.sectionWidths[s])-            }-        }-    }-}--@Composable-private fun SeatChip(seat: SeatElementDto, selected: Boolean, badge: String?, onClick: () -> Unit) {-    val bg = when {-        selected -> MaterialTheme.colorScheme.primary-        seat.available -> MaterialTheme.colorScheme.secondaryContainer-        else -> MaterialTheme.colorScheme.surfaceVariant-    }-    val fg = when {-        selected -> MaterialTheme.colorScheme.onPrimary-        seat.available -> MaterialTheme.colorScheme.onSecondaryContainer-        else -> MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f)-    }-    val price = seat.totalAmount?.let { amt ->-        formatMoney(amt, seat.totalCurrency ?: "USD")-    }-    Box(-        Modifier-            .size(CELL)-            .clip(RoundedCornerShape(6.dp))-            .background(bg)-            .let { if (seat.available) it.clickable { onClick() } else it },-        contentAlignment = Alignment.Center,-    ) {-        Column(horizontalAlignment = Alignment.CenterHorizontally) {-            Text(-                seat.designator,-                style = MaterialTheme.typography.labelSmall,-                color = fg,-                textAlign = TextAlign.Center,-                fontWeight = if (selected) FontWeight.Bold else FontWeight.Normal,-            )-            if (badge != null) {-                Text(badge, fontSize = 8.sp, color = fg, textAlign = TextAlign.Center, fontWeight = FontWeight.Bold)-            } else if (seat.available && price != null) {-                Text(price, fontSize = 8.sp, color = fg, textAlign = TextAlign.Center)-            }-        }-    }-}--/** A facility (lavatory, galley, exit row…) drawn as a band spanning its section. */-@Composable-private fun AmenityBand(type: String?, columns: Int) {-    val label = when (type) {-        "lavatory" -> "Lavatory"-        "galley" -> "Galley"-        "closet" -> "Closet"-        "stairs" -> "Stairs"-        "bassinet" -> "Bassinet"-        "exit_row" -> "Exit"-        "restricted_seat_general" -> "" // handled as seat elsewhere-        else -> ""-    }-    val width = blockWidth(columns)-    if (label.isBlank()) {-        Spacer(Modifier.width(width).height(CELL))-        return-    }-    val isExit = type == "exit_row"-    Box(-        Modifier-            .width(width)-            .height(CELL)-            .clip(RoundedCornerShape(6.dp))-            .let {-                if (isExit) it.background(MaterialTheme.colorScheme.tertiaryContainer)-                else it.border(1.dp, MaterialTheme.colorScheme.outlineVariant, RoundedCornerShape(6.dp))-            },-        contentAlignment = Alignment.Center,-    ) {-        Text(-            label,-            style = MaterialTheme.typography.labelSmall,-            fontWeight = if (isExit) FontWeight.Bold else FontWeight.Normal,-            color = if (isExit) MaterialTheme.colorScheme.onTertiaryContainer-            else MaterialTheme.colorScheme.onSurfaceVariant,-        )-    }-}
travel/src/main/java/com/vayunmathur/travel/ui/SeatMapScreen.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/SeatMapScreen.kt b/travel/src/main/java/com/vayunmathur/travel/ui/SeatMapScreen.ktnew file mode 100644index 0000000000..926d957319--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/SeatMapScreen.kt@@ -0,0 +1,303 @@+package com.vayunmathur.travel.ui+import com.vayunmathur.travel.R++import androidx.compose.foundation.background+import androidx.compose.foundation.border+import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+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.Spacer+import androidx.compose.foundation.layout.fillMaxSize+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.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.foundation.verticalScroll+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+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.draw.clip+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.travel.Route+import com.vayunmathur.travel.domain.assignSeat+import com.vayunmathur.travel.domain.seatHolder+import com.vayunmathur.travel.domain.seatKey+import com.vayunmathur.travel.domain.seatedPassengers+import com.vayunmathur.travel.network.SeatCabinDto+import com.vayunmathur.travel.network.SeatElementDto+import com.vayunmathur.travel.network.SeatRowDto+import com.vayunmathur.travel.platform.SeatMapActions+import com.vayunmathur.travel.platform.SeatMapState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.loadSeatMaps+import com.vayunmathur.travel.platform.toggleSeat+import androidx.compose.ui.res.stringResource++/**+ * The seat picker for one segment, with no dependency on the ViewModel or the back stack so+ * it can be rendered from a `@Preview` — see `src/screenshotTest`, which is where the store+ * listing images come from.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun SeatMapScreen(+    segmentId: String,+    state: SeatMapState,+    selectedSeats: Map<String, SeatElementDto>,+    actions: SeatMapActions,+    passengers: List<SeatPassenger> = emptyList(),+) {+    var activePassenger by remember(segmentId, passengers) {+        mutableStateOf(+            passengers.firstOrNull { seatKey(segmentId, it.id) !in selectedSeats }?.id+                ?: passengers.firstOrNull()?.id.orEmpty()+        )+    }+    AppScaffold(+        title = stringResource(R.string.choose_seats),+        onNavigateBack = { actions.back() },+        scrollBehavior = appBarScrollBehavior(),+    ) { padding ->+        val cabins = state.cabins.filter { it.segmentId == segmentId }+        if (state.loading || state.error != null || cabins.isEmpty()) {+            StatusBox(+                loading = state.loading,+                error = state.error,+                isEmpty = !state.loading && state.error == null && cabins.isEmpty(),+                modifier = Modifier.padding(padding),+                emptyMessage = "No seat map available for this flight.",+            )+            return@AppScaffold+        }+        Column(+            Modifier.fillMaxSize().padding(padding).verticalScroll(rememberScrollState()),+        ) {+            SeatLegend()+            if (passengers.size > 1) {+                SeatPassengerPicker(passengers, segmentId, selectedSeats, activePassenger) { activePassenger = it }+            }+            val passengerNumbers = passengers.mapIndexed { i, p -> p.id to i + 1 }.toMap()+            cabins.forEach { cabin ->+                CabinView(cabin, segmentId, selectedSeats, passengerNumbers.takeIf { passengers.size > 1 }) { seat ->+                    actions.toggleSeat(segmentId, activePassenger, seat)+                    // Move on to the next passenger still without a seat.+                    val holder = seatHolder(selectedSeats, segmentId, seat.designator)+                    if (holder == null && passengers.size > 1) {+                        val after = assignSeat(selectedSeats, segmentId, activePassenger, seat)+                        passengers.firstOrNull { seatKey(segmentId, it.id) !in after }?.let { activePassenger = it.id }+                    }+                }+            }+            Button(+                onClick = { actions.done() },+                modifier = Modifier.fillMaxWidth().padding(16.dp),+            ) { Text(stringResource(UiR.string.done)) }+        }+    }+}++@Composable+private fun CabinView(+    cabin: SeatCabinDto,+    segmentId: String,+    selectedSeats: Map<String, SeatElementDto>,+    passengerNumbers: Map<String, Int>?,+    onToggle: (SeatElementDto) -> Unit,+) {+    if (cabin.cabinClass.isNotBlank()) {+        Text(+            cabin.cabinClass.replace('_', ' ').replaceFirstChar { it.uppercase() },+            style = MaterialTheme.typography.titleSmall,+            color = MaterialTheme.colorScheme.primary,+            modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),+        )+    }+    val layout = remember(cabin) { computeLayout(cabin) }+    // Rows share one horizontal scroll so columns stay aligned across the cabin.+    Column(+        Modifier.horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp),+        verticalArrangement = Arrangement.spacedBy(GAP),+    ) {+        cabin.rows.forEach { row -> SeatRowView(row, layout, segmentId, selectedSeats, passengerNumbers, onToggle) }+    }+}++@Composable+private fun SeatRowView(+    row: SeatRowDto,+    layout: CabinLayout,+    segmentId: String,+    selectedSeats: Map<String, SeatElementDto>,+    passengerNumbers: Map<String, Int>?,+    onToggle: (SeatElementDto) -> Unit,+) {+    Row(verticalAlignment = Alignment.CenterVertically) {+        layout.sectionWidths.indices.forEach { s ->+            if (s > 0) Spacer(Modifier.width(AISLE))+            val elements = row.sections.getOrNull(s)?.elements ?: emptyList()+            val letters = layout.sectionLetters[s]+            if (elements.any { it.isSeat } && letters.isNotEmpty()) {+                Row(horizontalArrangement = Arrangement.spacedBy(GAP)) {+                    letters.forEach { letter ->+                        val seat = elements.firstOrNull { it.isSeat && seatLetter(it.designator) == letter }+                        if (seat != null) {+                            val holder = seatHolder(selectedSeats, segmentId, seat.designator)+                            val badge = holder?.let { passengerNumbers?.get(it) }?.let { "P$it" }+                            SeatChip(seat, holder != null, badge) { onToggle(seat) }+                        } else {+                            Spacer(Modifier.size(CELL))+                        }+                    }+                }+            } else {+                val type = elements.firstOrNull { it.type.isNotBlank() && it.type != "empty" }?.type+                AmenityBand(type, layout.sectionWidths[s])+            }+        }+    }+}++@Composable+private fun SeatChip(seat: SeatElementDto, selected: Boolean, badge: String?, onClick: () -> Unit) {+    val bg = when {+        selected -> MaterialTheme.colorScheme.primary+        seat.available -> MaterialTheme.colorScheme.secondaryContainer+        else -> MaterialTheme.colorScheme.surfaceVariant+    }+    val fg = when {+        selected -> MaterialTheme.colorScheme.onPrimary+        seat.available -> MaterialTheme.colorScheme.onSecondaryContainer+        else -> MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f)+    }+    val price = seat.totalAmount?.let { amt ->+        formatMoney(amt, seat.totalCurrency ?: "USD")+    }+    Box(+        Modifier+            .size(CELL)+            .clip(RoundedCornerShape(6.dp))+            .background(bg)+            .let { if (seat.available) it.clickable { onClick() } else it },+        contentAlignment = Alignment.Center,+    ) {+        Column(horizontalAlignment = Alignment.CenterHorizontally) {+            Text(+                seat.designator,+                style = MaterialTheme.typography.labelSmall,+                color = fg,+                textAlign = TextAlign.Center,+                fontWeight = if (selected) FontWeight.Bold else FontWeight.Normal,+            )+            if (badge != null) {+                Text(badge, fontSize = 8.sp, color = fg, textAlign = TextAlign.Center, fontWeight = FontWeight.Bold)+            } else if (seat.available && price != null) {+                Text(price, fontSize = 8.sp, color = fg, textAlign = TextAlign.Center)+            }+        }+    }+}++/** A facility (lavatory, galley, exit row…) drawn as a band spanning its section. */+@Composable+private fun AmenityBand(type: String?, columns: Int) {+    val label = when (type) {+        "lavatory" -> "Lavatory"+        "galley" -> "Galley"+        "closet" -> "Closet"+        "stairs" -> "Stairs"+        "bassinet" -> "Bassinet"+        "exit_row" -> "Exit"+        "restricted_seat_general" -> "" // handled as seat elsewhere+        else -> ""+    }+    val width = blockWidth(columns)+    if (label.isBlank()) {+        Spacer(Modifier.width(width).height(CELL))+        return+    }+    val isExit = type == "exit_row"+    Box(+        Modifier+            .width(width)+            .height(CELL)+            .clip(RoundedCornerShape(6.dp))+            .let {+                if (isExit) it.background(MaterialTheme.colorScheme.tertiaryContainer)+                else it.border(1.dp, MaterialTheme.colorScheme.outlineVariant, RoundedCornerShape(6.dp))+            },+        contentAlignment = Alignment.Center,+    ) {+        Text(+            label,+            style = MaterialTheme.typography.labelSmall,+            fontWeight = if (isExit) FontWeight.Bold else FontWeight.Normal,+            color = if (isExit) MaterialTheme.colorScheme.onTertiaryContainer+            else MaterialTheme.colorScheme.onSurfaceVariant,+        )+    }+}++private val CELL = 44.dp+private val GAP = 4.dp+private val AISLE = 22.dp++/**+ * Seat maps give variable element counts per section (e.g. a 3-4-3 cabin), and do+ * not pad rows to a uniform width, so we can't render elements 1:1 and expect+ * columns to line up. Instead we derive a canonical grid per cabin: the ordered+ * set of seat-letters in each section. Seats are then placed under their own+ * column; amenities (lavatory, galley, exit row…) are rendered as a band that+ * spans their whole section block, matching how the aircraft is actually laid out.+ */+private class CabinLayout(+    val sectionLetters: List<List<Char>>,+    val sectionWidths: List<Int>,+)++private fun seatLetter(designator: String): Char? = designator.lastOrNull { it.isLetter() }++private fun computeLayout(cabin: SeatCabinDto): CabinLayout {+    val sectionCount = cabin.rows.maxOfOrNull { it.sections.size } ?: 0+    val letters = List(sectionCount) { sortedSetOf<Char>() }+    val maxCounts = IntArray(sectionCount)+    cabin.rows.forEach { row ->+        row.sections.forEachIndexed { s, section ->+            maxCounts[s] = maxOf(maxCounts[s], section.elements.size)+            section.elements.forEach { el ->+                if (el.isSeat) seatLetter(el.designator)?.let { letters[s].add(it) }+            }+        }+    }+    val sectionLetters = letters.map { it.toList() }+    val widths = sectionLetters.mapIndexed { i, l ->+        if (l.isNotEmpty()) l.size else maxCounts[i].coerceAtLeast(1)+    }+    return CabinLayout(sectionLetters, widths)+}++/** Total width a section block occupies (its columns plus the gaps between them). */+private fun blockWidth(columns: Int) = CELL * columns + GAP * (columns - 1).coerceAtLeast(0)
travel/src/main/java/com/vayunmathur/travel/ui/SettingsPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/SettingsPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/SettingsPage.ktindex 2cb19be336..429815c206 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/SettingsPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/SettingsPage.kt@@ -35,12 +35,12 @@ import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.travel.Route import com.vayunmathur.travel.data.Customer import com.vayunmathur.travel.data.FrequentFlyer-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.createCustomer-import com.vayunmathur.travel.util.loadAirlines-import com.vayunmathur.travel.util.removeCustomer-import com.vayunmathur.travel.util.removeFrequentFlyer-import com.vayunmathur.travel.util.saveFrequentFlyer+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.createCustomer+import com.vayunmathur.travel.platform.loadAirlines+import com.vayunmathur.travel.platform.removeCustomer+import com.vayunmathur.travel.platform.removeFrequentFlyer+import com.vayunmathur.travel.platform.saveFrequentFlyer import androidx.compose.ui.res.stringResource import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.ui.text.input.KeyboardType
travel/src/main/java/com/vayunmathur/travel/ui/StatusBox.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/StatusBox.kt b/travel/src/main/java/com/vayunmathur/travel/ui/StatusBox.ktnew file mode 100644index 0000000000..5c4662914c--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/StatusBox.kt@@ -0,0 +1,60 @@+package com.vayunmathur.travel.ui++import kotlin.time.Clock+import kotlin.time.Instant+import kotlinx.datetime.LocalDateTime+import com.vayunmathur.library.ui.DateString+import kotlinx.datetime.TimeZone+import kotlinx.datetime.toLocalDateTime+import androidx.compose.foundation.background+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.heightIn+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+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.draw.clip+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import androidx.lifecycle.Lifecycle+import androidx.lifecycle.compose.LocalLifecycleOwner+import androidx.lifecycle.repeatOnLifecycle+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text++/** Centered loading/error/empty state used by results pages. */+@Composable+fun StatusBox(+    loading: Boolean,+    error: String?,+    isEmpty: Boolean,+    modifier: Modifier = Modifier,+    emptyMessage: String = "No flights found. Try different dates or airports.",+) {+    Box(modifier.fillMaxWidth().heightIn(min = 200.dp), contentAlignment = Alignment.Center) {+        when {+            loading -> CircularProgressIndicator()+            error != null -> Text(+                error,+                color = MaterialTheme.colorScheme.error,+                modifier = Modifier.padding(24.dp),+            )+            isEmpty -> Text(+                emptyMessage,+                color = MaterialTheme.colorScheme.onSurfaceVariant,+                modifier = Modifier.padding(24.dp),+            )+        }+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/StayConfirmationPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/StayConfirmationPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/StayConfirmationPage.ktindex 830ec1410e..9bcfabcecf 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/StayConfirmationPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/StayConfirmationPage.kt@@ -38,13 +38,13 @@ import com.vayunmathur.travel.domain.isTripPollingStatus import com.vayunmathur.travel.domain.tripStatusLabel import com.vayunmathur.travel.platform.CardPaymentResult import com.vayunmathur.travel.platform.rememberCardPayment-import com.vayunmathur.travel.util.CheckoutState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.TripPollState-import com.vayunmathur.travel.util.confirmPaidTrip-import com.vayunmathur.travel.util.pollTrip-import com.vayunmathur.travel.util.recheckoutForStoredTrip-import com.vayunmathur.travel.util.refreshStoredTrip+import com.vayunmathur.travel.platform.CheckoutState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.TripPollState+import com.vayunmathur.travel.platform.confirmPaidTrip+import com.vayunmathur.travel.platform.pollTrip+import com.vayunmathur.travel.platform.recheckoutForStoredTrip+import com.vayunmathur.travel.platform.refreshStoredTrip import androidx.compose.ui.res.stringResource  /**
travel/src/main/java/com/vayunmathur/travel/ui/StayDetailPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/StayDetailPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/StayDetailPage.ktindex 4f03d90c84..566f12b28a 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/StayDetailPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/StayDetailPage.kt@@ -31,9 +31,9 @@ import com.vayunmathur.library.util.sharedContainer import com.vayunmathur.library.util.sharedText import com.vayunmathur.travel.Route import com.vayunmathur.travel.network.StayRateDto-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.loadStayRates-import com.vayunmathur.travel.util.selectStayRate+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.loadStayRates+import com.vayunmathur.travel.platform.selectStayRate import androidx.compose.ui.res.stringResource  @OptIn(ExperimentalMaterial3Api::class)
travel/src/main/java/com/vayunmathur/travel/ui/StayGuestsPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/StayGuestsPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/StayGuestsPage.ktindex dc0497b090..c9e26dac7b 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/StayGuestsPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/StayGuestsPage.kt@@ -42,12 +42,12 @@ import com.vayunmathur.travel.Route import com.vayunmathur.travel.network.StayGuestInputDto import com.vayunmathur.travel.platform.CardPaymentResult import com.vayunmathur.travel.platform.rememberCardPayment-import com.vayunmathur.travel.util.StayBookingState-import com.vayunmathur.travel.util.TravelViewModel-import com.vayunmathur.travel.util.bookStay-import com.vayunmathur.travel.util.confirmPaidTrip-import com.vayunmathur.travel.util.resetStayBooking-import com.vayunmathur.travel.util.stayTotal+import com.vayunmathur.travel.platform.StayBookingState+import com.vayunmathur.travel.platform.TravelViewModel+import com.vayunmathur.travel.platform.bookStay+import com.vayunmathur.travel.platform.confirmPaidTrip+import com.vayunmathur.travel.platform.resetStayBooking+import com.vayunmathur.travel.platform.stayTotal import androidx.compose.ui.res.stringResource  @OptIn(ExperimentalMaterial3Api::class)
travel/src/main/java/com/vayunmathur/travel/ui/StayResultsScreen.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/StayResultsScreen.kt b/travel/src/main/java/com/vayunmathur/travel/ui/StayResultsScreen.ktindex c126139ce1..e1feaba6f1 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/StayResu

Diff truncated.