Modern Apps git

← Modern-Apps.git

travel: dropdown search forms, Explore map, remove multi-city

Commit
1a7471abbacb086fd82fb3f5bff70d6383ae9453
Author
vayun-mathur <[email protected]>
When
2026-10-25 07:48 UTC (1 month ago)
Parents
8b5c9ec

Diff

travel/AGENTS.md
diff --git a/travel/AGENTS.md b/travel/AGENTS.mdindex 8b42de1a31..d4863b9473 100644--- a/travel/AGENTS.md+++ b/travel/AGENTS.md@@ -14,8 +14,8 @@ _Install: ./install travel (dev by default)._ ## Overview **Purpose:** Flight + hotel booking — search/comparison, seat maps, ancillaries/offers, trip management with hosted checkout; trips persist on-device so plans stay readable offline. **Key features:**-- Flight search form → results → offer review → passengers → trip → ancillaries → hosted checkout → confirmation; change/cancel/manage on booked trips-- Multi-city (one offer per leg, one trip) and round-trip step-by-step (grouped on-device); stays search → detail → guests → hosted checkout → confirmation; seat-map picker+- Flight search form (one-way / round-trip) → results → offer review → passengers → trip → ancillaries → hosted checkout → confirmation; Explore map (find-destination price pins → live re-search) ; change/cancel/manage on booked trips+- Round-trip step-by-step (grouped on-device); stays search → detail → guests → hosted checkout → confirmation; seat-map picker - `data/` Room (trips, local booking profiles, frequent-flyer, recent searches) + `domain/` on-device grouping/status + `network/` trip/stays DTOs + APIs **Architecture / data-flow:** `ui/` search/results/booking pages → `util/TravelViewModel` (+ `TravelUiContract`/`TravelUiState`, per-area `Travel*Ops`) → `domain/` grouping + `data/TravelRepository` over Room + `network/TravelApi`/`StaysApi`; booked trips stay readable from Room when offline. **Entry points + reading order:** `MainActivity.kt` → `ui/HomePage.kt` → `ui/FlightSearchForm.kt` → `util/TravelViewModel.kt` → `util/TravelSearchOps.kt` → `network/TravelApi.kt`.
travel/build.gradle.kts
diff --git a/travel/build.gradle.kts b/travel/build.gradle.ktsindex da347d1322..373d5bcdf3 100644--- a/travel/build.gradle.kts+++ b/travel/build.gradle.kts@@ -22,5 +22,6 @@ dependencies {     implementation(project(":library:network"))      implementation(project(":library:image"))+    implementation(project(":library:map"))     implementation(libs.androidx.browser) }
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 b7d1356594..4b8eb68904 100644--- a/travel/src/main/java/com/vayunmathur/travel/MainActivity.kt+++ b/travel/src/main/java/com/vayunmathur/travel/MainActivity.kt@@ -22,10 +22,10 @@ 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.ExploreMapPage import com.vayunmathur.travel.ui.FlightResultsPage import com.vayunmathur.travel.ui.FareSelectPage import com.vayunmathur.travel.ui.HomePage-import com.vayunmathur.travel.ui.MultiCityLegPage import com.vayunmathur.travel.ui.OfferReviewPage import com.vayunmathur.travel.ui.OrderDetailPage import com.vayunmathur.travel.ui.OutboundSelectPage@@ -100,6 +100,23 @@ sealed interface Route : NavKey {         val maxConnections: Int,     ) : Route +    /**+     * Explore map: search params only (never the destination list — the page+     * fetches via the ViewModel). [tripType] is `oneway` or `roundtrip`.+     */+    @Serializable+    data class Explore(+        val origin: String,+        val tripType: String,+        val depart: String,+        val returnDate: String? = null,+        val cabin: String = "economy",+        val adults: Int = 1,+        val children: String = "",+        val infants: Int = 0,+        val maxConnections: Int = -1,+    ) : Route+     @Serializable     data class OfferReview(val offerId: String) : Route @@ -113,17 +130,6 @@ sealed interface Route : NavKey {         val maxConnections: Int,     ) : Route -    @Serializable-    data class MultiCityLeg(-        val slices: String,-        val legIndex: Int,-        val adults: Int,-        val children: String,-        val infants: Int,-        val cabin: String,-        val maxConnections: Int,-    ) : Route-     @Serializable     data class ReturnSelect(val outboundSignature: String) : Route @@ -190,8 +196,8 @@ fun MainGraph(viewModel: TravelViewModel) {         MainNavigation(backStack) {             entry<Route.Home> { HomePage(backStack, viewModel) }             entry<Route.FlightResults>(metadata = ListPage()) { FlightResultsPage(backStack, viewModel, it) }+            entry<Route.Explore> { ExploreMapPage(backStack, viewModel, it) }             entry<Route.OutboundSelect> { OutboundSelectPage(backStack, viewModel, it) }-            entry<Route.MultiCityLeg> { MultiCityLegPage(backStack, viewModel, it) }             entry<Route.ReturnSelect> { ReturnSelectPage(backStack, viewModel, it) }             entry<Route.FareSelect> { FareSelectPage(backStack, viewModel, it) }             entry<Route.OfferReview>(metadata = ListDetailPage() + MorphPage()) {
travel/src/main/java/com/vayunmathur/travel/domain/ExploreSlices.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/domain/ExploreSlices.kt b/travel/src/main/java/com/vayunmathur/travel/domain/ExploreSlices.ktnew file mode 100644index 0000000000..265661689e--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/domain/ExploreSlices.kt@@ -0,0 +1,20 @@+package com.vayunmathur.travel.domain++/**+ * Live-search slices for an Explore pin: the tapped destination re-searched+ * through the normal flight flow (explore fares are cached estimates, never+ * booked directly). One-way is a single slice; round-trips reverse it.+ * Pure: covered by unit tests.+ */+fun exploreLiveSlices(+    origin: String,+    destinationCode: String,+    departDate: String,+    returnDate: String,+    isRoundTrip: Boolean,+): String =+    if (isRoundTrip && returnDate.isNotBlank()) {+        "$origin:$destinationCode:$departDate,$destinationCode:$origin:$returnDate"+    } else {+        "$origin:$destinationCode:$departDate"+    }
travel/src/main/java/com/vayunmathur/travel/network/ExploreDto.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/network/ExploreDto.kt b/travel/src/main/java/com/vayunmathur/travel/network/ExploreDto.ktnew file mode 100644index 0000000000..c2a234455b--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/network/ExploreDto.kt@@ -0,0 +1,32 @@+package com.vayunmathur.travel.network++import kotlinx.serialization.Serializable++/**+ * A destination suggestion from `GET /api/travel/explore` (proxied+ * `find_destination`): cached lowest fare + coordinates for the map pins.+ * Fares are exploration-only — the app re-searches live via [TravelApi.flights]+ * before booking.+ */+@Serializable+data class ExploreDestinationDto(+    val cityName: String = "",+    val iataCode: String = "",+    val imageUrl: String = "",+    val latitude: Double? = null,+    val longitude: Double? = null,+    val lowestAmount: String = "",+    val lowestCurrency: String = "",+    /** Airport code of the lowest-fare flight's destination (for live re-search). */+    val destinationCode: String = "",+    /** Departure date of the lowest-fare flight (`YYYY-MM-DD`). */+    val departDate: String = "",+    /** Return date of the lowest-fare flight (`YYYY-MM-DD`, "" when one-way). */+    val returnDate: String = "",+)++/** The result of an explore search: one entry per suggested destination. */+@Serializable+data class ExploreSearchDto(+    val destinations: List<ExploreDestinationDto> = emptyList(),+)
travel/src/main/java/com/vayunmathur/travel/network/TravelApi.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/network/TravelApi.kt b/travel/src/main/java/com/vayunmathur/travel/network/TravelApi.ktindex 1ba1197dab..a7352d4640 100644--- a/travel/src/main/java/com/vayunmathur/travel/network/TravelApi.kt+++ b/travel/src/main/java/com/vayunmathur/travel/network/TravelApi.kt@@ -59,6 +59,40 @@ object TravelApi {         )     ) +    /**+     * Explore destination suggestions with cached lowest fares for the map+     * pins: one entry per suggested destination. Fares are exploration-only;+     * the app re-searches live via [flights] before booking.+     */+    suspend fun explore(+        origins: String,+        tripType: String,+        depart: String,+        returnDate: String? = null,+        cabin: String = "economy",+        adults: Int = 1,+        children: String = "",+        infants: Int = 0,+        maxConnections: Int = -1,+        maxTotal: Double? = null,+        currency: String = "",+    ): ExploreSearchDto = NetworkClient.getJson(+        buildString {+            append(BASE).append("/explore")+            append("?origins=").append(enc(origins))+            append("&trip_type=").append(enc(tripType))+            append("&depart=").append(enc(depart))+            if (!returnDate.isNullOrBlank()) append("&return_date=").append(enc(returnDate))+            append("&cabin=").append(enc(cabin))+            append("&adults=").append(adults)+            if (children.isNotBlank()) append("&children=").append(enc(children))+            if (infants > 0) append("&infants=").append(infants)+            if (maxConnections >= 0) append("&max_connections=").append(maxConnections)+            if (maxTotal != null) append("&max_total=").append(maxTotal)+            if (currency.isNotBlank()) append("&currency=").append(enc(currency))+        }+    )+     private fun flightsUrl(         path: String,         origin: String,
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 9f5be374e6..6c4e143828 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/Common.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/Common.kt@@ -1,13 +1,10 @@ package com.vayunmathur.travel.ui -import com.vayunmathur.library.ui.R as UiR import kotlin.time.Clock import kotlin.time.Instant-import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import com.vayunmathur.library.ui.DateString import kotlinx.datetime.TimeZone-import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.toLocalDateTime import androidx.compose.foundation.background import androidx.compose.foundation.clickable@@ -19,9 +16,7 @@ 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 com.vayunmathur.library.ui.IconAdd-import com.vayunmathur.library.ui.IconCalendar-import com.vayunmathur.library.ui.IconRemove+import com.vayunmathur.library.ui.IconCompass import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue@@ -39,17 +34,11 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.repeatOnLifecycle import com.vayunmathur.library.ui.CircularProgressIndicator-import com.vayunmathur.library.ui.DatePicker-import com.vayunmathur.library.ui.DatePickerDialog import com.vayunmathur.library.ui.ElevatedCard-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedTextField import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton-import com.vayunmathur.library.ui.rememberDatePickerState import com.vayunmathur.travel.network.PlaceDto import com.vayunmathur.travel.util.TravelViewModel import com.vayunmathur.travel.util.autocomplete@@ -71,6 +60,10 @@ fun SectionHeader(text: String, modifier: Modifier = Modifier) {  * Airport/city autocomplete field. Owns its own text; reports the chosen code  * back via [onCodeChange] — either an IATA/city code when a suggestion is  * tapped, or the raw typed text as a fallback so power users can type "LON".+ *+ * When [showExploreRow] is true (the flights To field), a pinned "Explore"+ * row is always shown in the dropdown; tapping it calls [onExploreSelected]+ * instead of reporting a code.  */ @Composable fun PlaceAutocompleteField(@@ -79,6 +72,8 @@ fun PlaceAutocompleteField(     onCodeChange: (String) -> Unit,     modifier: Modifier = Modifier,     initialText: String = "",+    showExploreRow: Boolean = false,+    onExploreSelected: () -> Unit = {}, ) {     var text by remember { mutableStateOf(initialText) }     var suggestions by remember { mutableStateOf<List<PlaceDto>>(emptyList()) }@@ -109,9 +104,22 @@ fun PlaceAutocompleteField(             keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii),             modifier = Modifier.fillMaxWidth(),         )-        if (suggestions.isNotEmpty()) {+        if (suggestions.isNotEmpty() || showExploreRow) {+            val exploreLabel = stringResource(R.string.explore)             ElevatedCard(Modifier.fillMaxWidth().padding(top = 4.dp)) {                 Column {+                    if (showExploreRow) {+                        ListItem(+                            modifier = Modifier.clickable {+                                onCodeChange("")+                                text = exploreLabel+                                justSelected = true+                                suggestions = emptyList()+                                onExploreSelected()+                            },+                            leadingContent = { IconCompass() },+                        ) { Text(stringResource(R.string.explore_anywhere)) }+                    }                     suggestions.take(6).forEach { place ->                         ListItem(                             modifier = Modifier.clickable {@@ -128,94 +136,6 @@ fun PlaceAutocompleteField(     } } -/**- * A read-only field that opens a Material date picker on tap. [value] is an ISO- * `YYYY-MM-DD` string (empty when unset); [onDate] receives the picked ISO date.- */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun DateField(-    label: String,-    value: String,-    onDate: (String) -> Unit,-    modifier: Modifier = Modifier,-    dateFormat: (LocalDate) -> String = DateString::dateWeekdayNoYear,-) {-    var show by remember { mutableStateOf(false) }-    val display = if (value.isBlank()) "" else runCatching {-        dateFormat(LocalDate.parse(value))-    }.getOrDefault(value)--    Box(modifier) {-        OutlinedTextField(-            value = display,-            onValueChange = {},-            readOnly = true,-            enabled = false,-            label = { Text(label) },-            leadingIcon = { IconCalendar() },-            modifier = Modifier.fillMaxWidth(),-        )-        Box(-            Modifier-                .matchParentSize()-                .clickable { show = true }-        )-    }--    if (show) {-        val state = rememberDatePickerState(-            initialSelectedDateMillis = runCatching { LocalDate.parse(value) }-                .getOrNull()-                ?.atStartOfDayIn(TimeZone.UTC)-                ?.toEpochMilliseconds(),-        )-        DatePickerDialog(-            onDismissRequest = { show = false },-            confirmButton = {-                TextButton(onClick = {-                    state.selectedDateMillis?.let { ms ->-                        val date = Instant.fromEpochMilliseconds(ms).toLocalDateTime(TimeZone.UTC).date-                        onDate(date.toString())-                    }-                    show = false-                }) { Text(stringResource(UiR.string.ok)) }-            },-            dismissButton = { TextButton(onClick = { show = false }) { Text(stringResource(UiR.string.cancel)) } },-        ) { DatePicker(state) }-    }-}--/** A +/- stepper for a small integer count (passengers). */-@Composable-fun CountStepper(-    label: String,-    count: Int,-    onCount: (Int) -> Unit,-    modifier: Modifier = Modifier,-    min: Int = 1,-    max: Int = 9,-) {-    Row(-        modifier-            .fillMaxWidth()-            .padding(vertical = 4.dp),-        verticalAlignment = Alignment.CenterVertically,-        horizontalArrangement = Arrangement.SpaceBetween,-    ) {-        Text(label, style = MaterialTheme.typography.bodyLarge)-        Row(verticalAlignment = Alignment.CenterVertically) {-            IconButton(onClick = { onCount((count - 1).coerceAtLeast(min)) }, enabled = count > min) {-                IconRemove()-            }-            Text("$count", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(horizontal = 8.dp))-            IconButton(onClick = { onCount((count + 1).coerceAtMost(max)) }, enabled = count < max) {-                IconAdd()-            }-        }-    }-}- /** Centered loading/error/empty state used by results pages. */ @Composable fun StatusBox(
travel/src/main/java/com/vayunmathur/travel/ui/CountStepper.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/CountStepper.kt b/travel/src/main/java/com/vayunmathur/travel/ui/CountStepper.ktnew file mode 100644index 0000000000..6353b2791b--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/CountStepper.kt@@ -0,0 +1,45 @@+package com.vayunmathur.travel.ui++import androidx.compose.foundation.layout.Arrangement+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.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.IconAdd+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconRemove+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text++/** A +/- stepper for a small integer count (passengers). */+@Composable+fun CountStepper(+    label: String,+    count: Int,+    onCount: (Int) -> Unit,+    modifier: Modifier = Modifier,+    min: Int = 1,+    max: Int = 9,+) {+    Row(+        modifier+            .fillMaxWidth()+            .padding(vertical = 4.dp),+        verticalAlignment = Alignment.CenterVertically,+        horizontalArrangement = Arrangement.SpaceBetween,+    ) {+        Text(label, style = MaterialTheme.typography.bodyLarge)+        Row(verticalAlignment = Alignment.CenterVertically) {+            IconButton(onClick = { onCount((count - 1).coerceAtLeast(min)) }, enabled = count > min) {+                IconRemove()+            }+            Text("$count", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(horizontal = 8.dp))+            IconButton(onClick = { onCount((count + 1).coerceAtMost(max)) }, enabled = count < max) {+                IconAdd()+            }+        }+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/DateField.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/DateField.kt b/travel/src/main/java/com/vayunmathur/travel/ui/DateField.ktnew file mode 100644index 0000000000..e547413e58--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/DateField.kt@@ -0,0 +1,101 @@+package com.vayunmathur.travel.ui++import com.vayunmathur.library.ui.R as UiR+import kotlin.time.Clock+import kotlin.time.Instant+import kotlinx.datetime.LocalDate+import com.vayunmathur.library.ui.DateString+import kotlinx.datetime.TimeZone+import kotlinx.datetime.atStartOfDayIn+import kotlinx.datetime.toLocalDateTime+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import com.vayunmathur.library.ui.DatePicker+import com.vayunmathur.library.ui.DatePickerDialog+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.IconCalendar+import com.vayunmathur.library.ui.OutlinedTextField+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.rememberDatePickerState+import androidx.compose.ui.res.stringResource++/**+ * A read-only field that opens a Material date picker on tap. [value] is an ISO+ * `YYYY-MM-DD` string (empty when unset); [onDate] receives the picked ISO date.+ * [minDate]/[maxDate] optionally clamp selection (e.g. no past dates, return not+ * before depart); dates outside the range are disabled in the picker.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun DateField(+    label: String,+    value: String,+    onDate: (String) -> Unit,+    modifier: Modifier = Modifier,+    dateFormat: (LocalDate) -> String = DateString::dateWeekdayNoYear,+    minDate: LocalDate? = null,+    maxDate: LocalDate? = null,+) {+    var show by remember { mutableStateOf(false) }+    val display = if (value.isBlank()) "" else runCatching {+        dateFormat(LocalDate.parse(value))+    }.getOrDefault(value)++    Box(modifier) {+        OutlinedTextField(+            value = display,+            onValueChange = {},+            readOnly = true,+            enabled = false,+            label = { Text(label) },+            leadingIcon = { IconCalendar() },+            modifier = Modifier.fillMaxWidth(),+        )+        Box(+            Modifier+                .matchParentSize()+                .clickable { show = true }+        )+    }++    if (show) {+        val minMillis = minDate?.atStartOfDayIn(TimeZone.UTC)?.toEpochMilliseconds()+        val maxMillis = maxDate?.atStartOfDayIn(TimeZone.UTC)?.toEpochMilliseconds()+        val selectable = object : com.vayunmathur.library.ui.SelectableDates {+            override fun isSelectableDate(utcTimeMillis: Long): Boolean =+                (minMillis == null || utcTimeMillis >= minMillis) &&+                    (maxMillis == null || utcTimeMillis <= maxMillis)+        }+        val state = rememberDatePickerState(+            initialSelectedDateMillis = runCatching { LocalDate.parse(value) }+                .getOrNull()+                ?.atStartOfDayIn(TimeZone.UTC)+                ?.toEpochMilliseconds(),+            selectableDates = selectable,+        )+        DatePickerDialog(+            onDismissRequest = { show = false },+            confirmButton = {+                TextButton(onClick = {+                    state.selectedDateMillis?.let { ms ->+                        val date = Instant.fromEpochMilliseconds(ms).toLocalDateTime(TimeZone.UTC).date+                        onDate(date.toString())+                    }+                    show = false+                }) { Text(stringResource(UiR.string.ok)) }+            },+            dismissButton = { TextButton(onClick = { show = false }) { Text(stringResource(UiR.string.cancel)) } },+        ) { DatePicker(state) }+    }+}++/** Today in UTC as a [LocalDate], for clamping pickers to no-past-dates. */+fun todayUtc(): LocalDate = Clock.System.now().toLocalDateTime(TimeZone.UTC).date
travel/src/main/java/com/vayunmathur/travel/ui/ExploreBottomSheet.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/ExploreBottomSheet.kt b/travel/src/main/java/com/vayunmathur/travel/ui/ExploreBottomSheet.ktnew file mode 100644index 0000000000..b53a4bed0b--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/ExploreBottomSheet.kt@@ -0,0 +1,124 @@+package com.vayunmathur.travel.ui++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.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.library.image.compose.AsyncImage+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.ModalBottomSheet+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.rememberModalBottomSheetState+import com.vayunmathur.travel.R+import com.vayunmathur.travel.domain.exploreLiveSlices+import com.vayunmathur.travel.network.ExploreDestinationDto+import com.vayunmathur.travel.util.FlightQuery+import com.vayunmathur.travel.util.TravelViewModel+import com.vayunmathur.travel.util.searchFlights++/**+ * Bottom sheet for an Explore map pin: destination header (photo, city,+ * cached "from" fare with a disclaimer) then LIVE flights to that place.+ * The cached explore fare is never booked; tapping a live offer reports it+ * via [onOffer] (the caller runs `selectOffer` + navigates to review).+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun ExploreBottomSheet(+    destination: ExploreDestinationDto,+    request: ExploreRequest,+    viewModel: TravelViewModel,+    onDismiss: () -> Unit,+    onOffer: (com.vayunmathur.travel.network.OfferDto) -> Unit,+) {+    val flights by viewModel.flights.collectAsStateWithLifecycle()++    LaunchedEffect(destination) {+        val destCode = destination.destinationCode.ifBlank { destination.iataCode }+        val depart = destination.departDate.ifBlank { request.depart }+        val slices = exploreLiveSlices(+            origin = request.origin,+            destinationCode = destCode,+            departDate = depart,+            returnDate = destination.returnDate,+            isRoundTrip = request.tripType == "roundtrip",+        )+        viewModel.searchFlights(+            FlightQuery(+                slices = slices,+                adults = request.adults,+                children = request.children,+                infants = request.infants,+                cabin = request.cabin,+                maxConnections = request.maxConnections,+                isRoundTrip = request.tripType == "roundtrip",+            )+        )+    }++    ModalBottomSheet(+        onDismissRequest = onDismiss,+        sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true),+    ) {+        LazyColumn(Modifier.fillMaxWidth().padding(bottom = 24.dp)) {+            item {+                Column(Modifier.padding(horizontal = 16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {+                    Row(+                        Modifier.fillMaxWidth(),+                        verticalAlignment = Alignment.CenterVertically,+                        horizontalArrangement = Arrangement.spacedBy(12.dp),+                    ) {+                        if (destination.imageUrl.isNotBlank()) {+                            AsyncImage(+                                model = destination.imageUrl,+                                contentDescription = destination.cityName,+                                contentScale = ContentScale.Crop,+                                modifier = Modifier.size(64.dp),+                            )+                        }+                        Column(Modifier.weight(1f)) {+                            Text(destination.cityName, style = MaterialTheme.typography.titleLarge)+                            Text(+                                "${stringResource(R.string.from)} ${formatMoney(destination.lowestAmount, destination.lowestCurrency)}",+                                style = MaterialTheme.typography.titleMedium,+                                color = MaterialTheme.colorScheme.primary,+                            )+                        }+                    }+                    Text(+                        stringResource(R.string.explore_fare_note),+                        style = MaterialTheme.typography.bodySmall,+                        color = MaterialTheme.colorScheme.onSurfaceVariant,+                    )+                    Text(stringResource(R.string.explore_live_fares), style = MaterialTheme.typography.titleSmall)+                }+            }+            items(flights.visibleOffers) { offer ->+                OfferCard(offer) { onOffer(offer) }+            }+            if (flights.loading || flights.error != null || (flights.hasSearched && flights.visibleOffers.isEmpty())) {+                item {+                    StatusBox(+                        loading = flights.loading,+                        error = flights.error,+                        isEmpty = flights.hasSearched && flights.visibleOffers.isEmpty(),+                    )+                }+            }+        }+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/ExploreMapPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/ExploreMapPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/ExploreMapPage.ktnew file mode 100644index 0000000000..fff5e41b55--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/ExploreMapPage.kt@@ -0,0 +1,135 @@+package com.vayunmathur.travel.ui++import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxSize+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.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.library.map.CameraPosition+import com.vayunmathur.library.map.GeoPoint+import com.vayunmathur.library.map.VectorMap+import com.vayunmathur.library.map.rememberCameraState+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.travel.R+import com.vayunmathur.travel.Route+import com.vayunmathur.travel.network.ExploreDestinationDto+import com.vayunmathur.travel.util.TravelViewModel+import com.vayunmathur.travel.util.searchExplore+import com.vayunmathur.travel.util.selectOffer++/**+ * Explore map: destination suggestions from `find_destination` as price pins.+ * Tapping a pin opens [ExploreBottomSheet] with live flights to that place;+ * tapping a live offer reports it via the normal review flow.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun ExploreMapPage(+    backStack: NavBackStack<Route>,+    viewModel: TravelViewModel,+    route: Route.Explore,+) {+    val state by viewModel.explore.collectAsStateWithLifecycle()+    var selected by remember { mutableStateOf<ExploreDestinationDto?>(null) }++    LaunchedEffect(route) {+        viewModel.searchExplore(+            origin = route.origin,+            tripType = route.tripType,+            depart = route.depart,+            returnDate = route.returnDate,+            cabin = route.cabin,+            adults = route.adults,+            children = route.children,+            infants = route.infants,+            maxConnections = route.maxConnections,+        )+    }++    val camera = rememberCameraState(+        CameraPosition(target = GeoPoint(0.0, 20.0), zoom = 1.5)+    )+    // Fit the camera on the pins once loaded.+    LaunchedEffect(state.destinations) {+        val pins = state.destinations.mapNotNull { d ->+            val lat = d.latitude+            val lng = d.longitude+            if (lat == null || lng == null) null else GeoPoint(lng, lat)+        }+        if (pins.isNotEmpty()) {+            val avgLng = pins.map { it.longitude }.average()+            val avgLat = pins.map { it.latitude }.average()+            camera.animateTo(CameraPosition(target = GeoPoint(avgLng, avgLat), zoom = 2.5))+        }+    }++    val request = remember(route) {+        ExploreRequest(+            origin = route.origin,+            tripType = route.tripType,+            depart = route.depart,+            returnDate = route.returnDate,+            cabin = route.cabin,+            adults = route.adults,+            children = route.children,+            infants = route.infants,+            maxConnections = route.maxConnections,+        )+    }++    AppScaffold(+        title = stringResource(R.string.explore_title, route.origin),+        backStack = backStack,+        scrollBehavior = appBarScrollBehavior(),+    ) { padding ->+        Box(Modifier.fillMaxSize().padding(padding)) {+            if (state.loading || state.error != null || (state.hasSearched && state.destinations.isEmpty())) {+                StatusBox(+                    loading = state.loading,+                    error = state.error,+                    isEmpty = state.hasSearched && state.destinations.isEmpty(),+                    emptyMessage = stringResource(R.string.explore_empty),+                )+            } else {+                VectorMap(cameraState = camera) {+                    state.destinations.forEach { dest ->+                        val lat = dest.latitude ?: return@forEach+                        val lng = dest.longitude ?: return@forEach+                        MapMarker(position = GeoPoint(lng, lat)) {+                            ExplorePricePill(+                                amount = dest.lowestAmount,+                                currency = dest.lowestCurrency,+                                modifier = Modifier.clickable { selected = dest },+                            )+                        }+                    }+                }+            }+        }+    }++    selected?.let { dest ->+        ExploreBottomSheet(+            destination = dest,+            request = request,+            viewModel = viewModel,+            onDismiss = { selected = null },+            onOffer = { offer ->+                viewModel.selectOffer(offer)+                selected = null+                backStack.add(Route.OfferReview(offer.offerId))+            },+        )+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/ExplorePricePill.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/ExplorePricePill.kt b/travel/src/main/java/com/vayunmathur/travel/ui/ExplorePricePill.ktnew file mode 100644index 0000000000..8837584e44--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/ExplorePricePill.kt@@ -0,0 +1,37 @@+package com.vayunmathur.travel.ui++import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text++/**+ * Price pill drawn on the Explore map at a destination: the cached lowest+ * fare (e.g. "$412"). Taps are handled by the caller via [Modifier.clickable]+ * on this pill.+ */+@Composable+fun ExplorePricePill(+    amount: String,+    currency: String,+    modifier: Modifier = Modifier,+) {+    Surface(+        shape = MaterialTheme.shapes.small,+        color = MaterialTheme.colorScheme.inverseSurface,+        contentColor = MaterialTheme.colorScheme.inverseOnSurface,+        shadowElevation = 4.dp,+        modifier = modifier,+    ) {+        Text(+            formatMoney(amount, currency),+            style = MaterialTheme.typography.labelLarge,+            fontWeight = FontWeight.SemiBold,+            modifier = Modifier.padding(horizontal = 10.dp, vertical = 6.dp),+        )+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/ExploreRequest.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/ExploreRequest.kt b/travel/src/main/java/com/vayunmathur/travel/ui/ExploreRequest.ktnew file mode 100644index 0000000000..ae0832e118--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/ExploreRequest.kt@@ -0,0 +1,18 @@+package com.vayunmathur.travel.ui++/**+ * Explore search params carried by `Route.Explore`: origin, trip shape,+ * dates, cabin and party. The Explore page fetches destinations via+ * `TravelApi.explore`; nothing here is bookable (pin sheet re-searches live).+ */+data class ExploreRequest(+    val origin: String,+    val tripType: String,+    val depart: String,+    val returnDate: String? = null,+    val cabin: String = "economy",+    val adults: Int = 1,+    val children: String = "",+    val infants: Int = 0,+    val maxConnections: Int = -1,+)
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 97e84d5cbf..f3e56037b9 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/FlightResultsPage.kt@@ -236,8 +236,9 @@ private fun OfferExpiryBanner(expiresAt: String, onExpired: () -> Unit) {     } } +/** A single bookable offer row; shared with the Explore pin sheet. */ @Composable-private fun OfferCard(offer: OfferDto, onClick: () -> Unit) {+internal fun OfferCard(offer: OfferDto, onClick: () -> Unit) {     ElevatedCard(         modifier = Modifier             .fillMaxWidth()
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 e045213065..ad4a84ceed 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/FlightSearchForm.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/FlightSearchForm.kt@@ -10,29 +10,22 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf-import androidx.compose.runtime.mutableStateListOf 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.text.font.FontWeight import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.FilterChip-import com.vayunmathur.library.ui.HorizontalDivider import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.IconClose-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.OutlinedButton-import com.vayunmathur.library.ui.Switch+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 androidx.compose.ui.res.stringResource import androidx.annotation.StringRes import com.vayunmathur.travel.R-import com.vayunmathur.library.ui.R as UiR+import kotlinx.datetime.LocalDate  /** The booking-provider cabin classes, with a display label. */ enum class Cabin(val code: String, @StringRes val label: Int) {@@ -42,177 +35,186 @@ enum class Cabin(val code: String, @StringRes val label: Int) {     FIRST("first", R.string.first), } -/** The three supported trip shapes. */+/** The two supported trip shapes (multi-city was removed). */ enum class TripType(@StringRes val label: Int) {     ONE_WAY(R.string.one_way),     ROUND_TRIP(R.string.round_trip),-    MULTI_CITY(R.string.multi_city), } -/** A single editable leg (origin/destination/date) used by the form. */-private data class Leg(var origin: String = "", var destination: String = "", var date: String = "")+/** Max-stops options for the dropdown, mapped to the API's maxStops values. */+enum class MaxStops(val apiValue: Int, @StringRes val label: Int) {+    NONSTOP(0, R.string.stops_nonstop),+    ONE(1, R.string.stops_1),+    TWO_PLUS(2, R.string.stops_2_plus),+}  /**- * Flight search form: trip type (one-way / round-trip / multi-city), origin /- * destination autocomplete, dates, cabin class, passenger mix (adults, children- * with ages, infants) and a nonstop toggle. Calls [onSearch] with a normalized- * [FlightQuery] when the user taps "Search flights".+ * Flight search form (Google-Flights style): a dropdown row (trip type,+ * passengers, cabin, max stops) above side-by-side From/To fields with a swap+ * button, then dates. Calls [onSearch] with a normalized [FlightQuery] when+ * the user taps "Search flights", or [onExplore] with the explore params when+ * the To field is in Explore mode.+ *+ * Date rules: no date before today; return not before depart.  */ @Composable fun FlightSearchForm(     viewModel: TravelViewModel,     modifier: Modifier = Modifier,     onSearch: (FlightQuery) -> Unit,+    onExplore: (ExploreRequest) -> Unit = {}, ) {-    var tripType by remember { mutableStateOf(TripType.ONE_WAY) }--    // One-way / round-trip fields.+    var tripType by remember { mutableStateOf(TripType.ROUND_TRIP) }     var origin by remember { mutableStateOf("") }     var destination by remember { mutableStateOf("") }     var depart by remember { mutableStateOf("") }     var returnDate by remember { mutableStateOf("") }--    // Multi-city legs.-    val legs = remember { mutableStateListOf(Leg(), Leg()) }--    // Passengers.-    var adults by remember { mutableIntStateOf(1) }-    val childAges = remember { mutableStateListOf<Int>() }-    var infants by remember { mutableIntStateOf(0) }-+    var mix by remember { mutableStateOf(PassengerMix()) }     var cabin by remember { mutableStateOf(Cabin.ECONOMY) }-    var nonstop by remember { mutableStateOf(false) }+    var maxStops by remember { mutableStateOf(MaxStops.TWO_PLUS) }+    var exploreMode by remember { mutableStateOf(false) }+    // Bumped on swap so the autocomplete fields re-init from the swapped codes+    // (they own their display text internally).+    var swapNonce by remember { mutableIntStateOf(0) }++    val today = remember { todayUtc() }+    val departDate = remember(depart) { runCatching { LocalDate.parse(depart) }.getOrNull() }+    val returnLocalDate = remember(returnDate) { runCatching { LocalDate.parse(returnDate) }.getOrNull() }      Column(modifier.fillMaxWidth().padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {         Row(             Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),             horizontalArrangement = Arrangement.spacedBy(8.dp),+            verticalAlignment = Alignment.CenterVertically,         ) {-            TripType.entries.forEach { t ->-                FilterChip(selected = tripType == t, onClick = { tripType = t }, label = { Text(stringResource(t.label)) })-            }-        }--        when (tripType) {-            TripType.MULTI_CITY -> {-                legs.forEachIndexed { index, leg ->-                    MultiCityLeg(-                        index = index,-                        viewModel = viewModel,-                        onOrigin = { legs[index] = leg.copy(origin = it) },-                        onDestination = { legs[index] = leg.copy(destination = it) },-                        date = leg.date,-                        onDate = { legs[index] = leg.copy(date = it) },-                        removable = legs.size > 2,-                        onRemove = { legs.removeAt(index) },-                    )-                }-                if (legs.size < 5) {-                    OutlinedButton(onClick = { legs.add(Leg()) }, modifier = Modifier.fillMaxWidth()) {-                        Text(stringResource(R.string.add_another_flight))-                    }-                }-            }-            else -> {-                PlaceAutocompleteField("From", viewModel, onCodeChange = { origin = it })-                PlaceAutocompleteField("To", viewModel, onCodeChange = { destination = it })-                DateField(stringResource(R.string.depart), depart, onDate = { depart = it })-                if (tripType == TripType.ROUND_TRIP) {-                    DateField(stringResource(R.string.return_label), returnDate, onDate = { returnDate = it })-                }-            }+            SearchDropdown(+                display = stringResource(tripType.label),+                options = TripType.entries.map { it.name to stringResource(it.label) },+                selectedValue = tripType.name,+                onSelect = { name -> tripType = TripType.valueOf(name) },+            )+            PassengerField(mix = mix, onMix = { mix = it })+            SearchDropdown(+                display = stringResource(cabin.label),+                options = Cabin.entries.map { it.name to stringResource(it.label) },+                selectedValue = cabin.name,+                onSelect = { name -> cabin = Cabin.valueOf(name) },+            )+            SearchDropdown(+                display = stringResource(maxStops.label),+                options = MaxStops.entries.map { it.name to stringResource(it.label) },+                selectedValue = maxStops.name,+                onSelect = { name -> maxStops = MaxStops.valueOf(name) },+            )         } -        HorizontalDivider()-         Row(-            Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),-            horizontalArrangement = Arrangement.spacedBy(8.dp),+            Modifier.fillMaxWidth(),+            horizontalArrangement = Arrangement.spacedBy(4.dp),+            verticalAlignment = Alignment.CenterVertically,         ) {-            Cabin.entries.forEach { c ->-                FilterChip(selected = cabin == c, onClick = { cabin = c }, label = { Text(stringResource(c.label)) })+            androidx.compose.runtime.key(swapNonce) {+                PlaceAutocompleteField(+                    "From",+                    viewModel,+                    onCodeChange = { origin = it },+                    modifier = Modifier.weight(1f),+                    initialText = origin,+                )+            }+            IconButton(onClick = {+                val o = origin+                origin = destination+                destination = o+                exploreMode = false+                swapNonce+++            }) { IconSwapLanguages() }+            androidx.compose.runtime.key(swapNonce) {+                PlaceAutocompleteField(+                    "To",+                    viewModel,+                    onCodeChange = {+                        destination = it+                        // Typing a code exits Explore mode.+                        if (it.isNotBlank()) exploreMode = false+                    },+                    modifier = Modifier.weight(1f),+                    initialText = destination,+                    showExploreRow = true,+                    onExploreSelected = {+                        destination = ""+                        exploreMode = true+                    },+                )             }         } -        CountStepper(stringResource(R.string.adults), adults, onCount = { adults = it }, min = 1)-        CountStepper(stringResource(R.string.children), childAges.size, onCount = { count ->-            while (childAges.size < count) childAges.add(8)-            while (childAges.size > count) childAges.removeAt(childAges.size - 1)-        }, min = 0, max = 6)-        childAges.forEachIndexed { index, age ->-            CountStepper(stringResource(R.string.child_age, index + 1), age, onCount = { childAges[index] = it }, min = 0, max = 17)-        }-        CountStepper(stringResource(R.string.infants_on_lap), infants, onCount = { infants = it }, min = 0, max = adults)-         Row(             Modifier.fillMaxWidth(),-            verticalAlignment = Alignment.CenterVertically,-            horizontalArrangement = Arrangement.SpaceBetween,+            horizontalArrangement = Arrangement.spacedBy(8.dp),         ) {-            Text(stringResource(R.string.nonstop_only))-            Switch(checked = nonstop, onCheckedChange = { nonstop = it })+            DateField(+                stringResource(R.string.depart),+                depart,+                onDate = { depart = it },+                modifier = Modifier.weight(1f),+                minDate = today,+            )+            if (tripType == TripType.ROUND_TRIP) {+                DateField(+                    stringResource(R.string.return_label),+                    returnDate,+                    onDate = { returnDate = it },+                    modifier = Modifier.weight(1f),+                    minDate = departDate ?: today,+                )+            }         } -        val valid = when (tripType) {-            TripType.MULTI_CITY -> legs.all { it.origin.isNotBlank() && it.destination.isNotBlank() && it.date.isNotBlank() }-            TripType.ROUND_TRIP -> origin.isNotBlank() && destination.isNotBlank() && depart.isNotBlank() && returnDate.isNotBlank()-            TripType.ONE_WAY -> origin.isNotBlank() && destination.isNotBlank() && depart.isNotBlank()-        }+        val departValid = departDate != null && departDate >= today+        val returnValid = tripType == TripType.ONE_WAY ||+            (returnLocalDate != null && departDate != null && returnLocalDate >= departDate)+        val valid = origin.isNotBlank() && (destination.isNotBlank() || exploreMode) && departValid && returnValid          Button(             onClick = {+                // Infants in seats fly as children (age 1) so they hold a seat;+                // infants on lap use the infant bucket.+                val childAges = mix.childAges + List(mix.infantsInSeat) { 1 }+                if (exploreMode) {+                    onExplore(+                        ExploreRequest(+                            origin = origin,+                            tripType = if (tripType == TripType.ROUND_TRIP) "roundtrip" else "oneway",+                            depart = depart,+                            returnDate = returnDate.takeIf { tripType == TripType.ROUND_TRIP },+                            cabin = cabin.code,+                            adults = mix.adults,+                            children = childAges.joinToString(","),+                            infants = mix.infantsOnLap,+                            maxConnections = maxStops.apiValue,+                        )+                    )+                    return@Button+                }                 val slices = when (tripType) {-                    TripType.MULTI_CITY -> legs.joinToString(",") { "${it.origin}:${it.destination}:${it.date}" }                     TripType.ROUND_TRIP -> "$origin:$destination:$depart,$destination:$origin:$returnDate"                     TripType.ONE_WAY -> "$origin:$destination:$depart"                 }                 onSearch(                     FlightQuery(                         slices = slices,-                        adults = adults,+                        adults = mix.adults,                         children = childAges.joinToString(","),-                        infants = infants,+                        infants = mix.infantsOnLap,                         cabin = cabin.code,-                        maxConnections = if (nonstop) 0 else -1,+                        maxConnections = maxStops.apiValue,                         isRoundTrip = tripType == TripType.ROUND_TRIP,                     )                 )             },             enabled = valid,             modifier = Modifier.fillMaxWidth(),-        ) { Text(stringResource(R.string.search_flights)) }-    }-}--@Composable-private fun MultiCityLeg(-    index: Int,-    viewModel: TravelViewModel,-    onOrigin: (String) -> Unit,-    onDestination: (String) -> Unit,-    date: String,-    onDate: (String) -> Unit,-    removable: Boolean,-    onRemove: () -> Unit,-) {-    Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {-        Row(-            Modifier.fillMaxWidth(),-            verticalAlignment = Alignment.CenterVertically,-            horizontalArrangement = Arrangement.SpaceBetween,-        ) {-            Text(-                stringResource(R.string.flight_1, index + 1),-                style = MaterialTheme.typography.titleSmall,-                fontWeight = FontWeight.SemiBold,-                color = MaterialTheme.colorScheme.primary,-            )-            if (removable) {-                IconButton(onClick = onRemove) { IconClose() }-            }-        }-        PlaceAutocompleteField("From", viewModel, onCodeChange = onOrigin)-        PlaceAutocompleteField("To", viewModel, onCodeChange = onDestination)-        DateField(stringResource(UiR.string.date), date, onDate = onDate)+        ) { Text(stringResource(if (exploreMode) R.string.explore_search else R.string.search_flights)) }     } }
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 9a482aa17b..e2d250d264 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/HomePage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/HomePage.kt@@ -80,44 +80,49 @@ fun HomePage(backStack: NavBackStack<Route>, viewModel: TravelViewModel) {             }              when (product) {-                Product.FLIGHTS -> FlightSearchForm(viewModel) { query ->-                    val legCount = query.legs.size-                    if (query.isRoundTrip) {-                        backStack.add(-                            Route.OutboundSelect(-                                slices = query.slices,-                                adults = query.adults,-                                children = query.children,-                                infants = query.infants,-                                cabin = query.cabin,-                                maxConnections = query.maxConnections,+                Product.FLIGHTS -> FlightSearchForm(+                    viewModel,+                    onSearch = { query ->+                        if (query.isRoundTrip) {+                            backStack.add(+                                Route.OutboundSelect(+                                    slices = query.slices,+                                    adults = query.adults,+                                    children = query.children,+                                    infants = query.infants,+                                    cabin = query.cabin,+                                    maxConnections = query.maxConnections,+                                )                             )-                        )-                    } else if (legCount > 1) {-                        backStack.add(-                            Route.MultiCityLeg(-                                slices = query.slices,-                                legIndex = 0,-                                adults = query.adults,-                                children = query.children,-                                infants = query.infants,-                                cabin = query.cabin,-                                maxConnections = query.maxConnections,+                        } else {+                            backStack.add(+                                Route.FlightResults(+                                    slices = query.slices,+                                    adults = query.adults,+                                    children = query.children,+                                    infants = query.infants,+                                    cabin = query.cabin,+                                    maxConnections = query.maxConnections,+                                )                             )-                        )-                    } else {+                        }+                    },+                    onExplore = { explore ->                         backStack.add(-                            Route.FlightResults(-                                slices = query.slices,-                                adults = query.adults,-                                children = query.children,-                                infants = query.infants,-                                cabin = query.cabin,-                                maxConnections = query.maxConnections,+                            Route.Explore(+                                origin = explore.origin,+                                tripType = explore.tripType,+                                depart = explore.depart,+                                returnDate = explore.returnDate,+                                cabin = explore.cabin,+                                adults = explore.adults,+                                children = explore.children,+                                infants = explore.infants,+                                maxConnections = explore.maxConnections,                             )                         )-                    }-                }+                    },+                )                 Product.STAYS -> StaySearchForm(viewModel) { place, checkIn, checkOut, rooms, adults, lat, lng ->                     backStack.add(                         Route.StayResults(
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 bd63dd6813..eddb8d1e0d 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/PartialOffersPages.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PartialOffersPages.kt@@ -36,12 +36,8 @@ import com.vayunmathur.travel.util.FlightQuery import com.vayunmathur.travel.util.TravelViewModel import com.vayunmathur.travel.util.loadPartialFares import com.vayunmathur.travel.util.loadPartialReturn-import com.vayunmathur.travel.util.multiCitySelection-import com.vayunmathur.travel.util.searchMultiCityLeg-import com.vayunmathur.travel.util.selectMultiCityOffer import com.vayunmathur.travel.util.selectOffer import com.vayunmathur.travel.util.selectOffers-import com.vayunmathur.travel.util.startMultiCitySearch import com.vayunmathur.travel.util.startPartialSearch import androidx.compose.ui.res.stringResource @@ -119,63 +115,6 @@ fun FareSelectPage(     } } -/**- * Multi-city: pick one offer for leg [Route.MultiCityLeg.legIndex] (each leg- * searched as a one-way). When every leg has a pick, booking posts all ids in- * one trip; otherwise advance to the next leg.- */-@Composable-fun MultiCityLegPage(-    backStack: NavBackStack<Route>,-    viewModel: TravelViewModel,-    route: Route.MultiCityLeg,-) {-    val query = remember(route) {-        FlightQuery(-            slices = route.slices,-            adults = route.adults,-            children = route.children,-            infants = route.infants,-            cabin = route.cabin,-            maxConnections = route.maxConnections,-        )-    }-    val legs = query.legs-    LaunchedEffect(route) {-        if (route.legIndex == 0) viewModel.startMultiCitySearch(query)-        else viewModel.searchMultiCityLeg(query, route.legIndex)-    }-    val state by viewModel.multiCity.collectAsStateWithLifecycle()-    val offers = state.legOffers[route.legIndex].orEmpty()-    val pickedId = state.selectedOfferIds[route.legIndex]-    val picked = offers.find { it.offerId == pickedId }-    val legLabel = legs.getOrNull(route.legIndex).orEmpty()-    val allPicked = (0 until legs.size).all { state.selectedOfferIds[it] != null }--    MultiCityLegScaffold(-        title = stringResource(R.string.choose_flight_leg, route.legIndex + 1, legs.size),-        subtitle = legLabel.replace(':', ' ').trim(),-        backStack = backStack,-        loading = state.loading,-        error = state.error,-        offers = offers,-        pickedId = pickedId,-        allPicked = allPicked,-        onPick = { viewModel.selectMultiCityOffer(route.legIndex, it) },-        onNextLeg = {-            backStack.add(route.copy(legIndex = route.legIndex + 1))-        },-        onFinish = {-            val selection = viewModel.multiCitySelection(legs.size).filterNotNull()-            if (selection.size == legs.size) {-                viewModel.selectOffers(selection)-                backStack.add(Route.OfferReview(selection.first().offerId))-            }-        },-        pickedLabel = picked?.let { formatMoney(it.totalAmount, it.currency) },-    )-}- @OptIn(ExperimentalMaterial3Api::class) @Composable private fun PartialLegScaffold(@@ -218,73 +157,8 @@ private fun PartialLegScaffold(     } } -@OptIn(ExperimentalMaterial3Api::class) @Composable-private fun MultiCityLegScaffold(-    title: String,-    subtitle: String,-    backStack: NavBackStack<Route>,-    loading: Boolean,-    error: String?,-    offers: List<OfferDto>,-    pickedId: String?,-    allPicked: Boolean,-    onPick: (OfferDto) -> Unit,-    onNextLeg: () -> Unit,-    onFinish: () -> Unit,-    pickedLabel: String?,-) {-    LazyListScaffold(-        topBar = {-            TopAppBar(-                title = {-                    Column {-                        Text(title)-                        if (subtitle.isNotBlank()) {-                            Text(-                                subtitle,-                                style = MaterialTheme.typography.bodySmall,-                                color = MaterialTheme.colorScheme.onSurfaceVariant,-                            )-                        }-                    }-                },-                navigationIcon = { IconNavigation(backStack) },-            )-        },-        scrollBehavior = appBarScrollBehavior(),-    ) {-        items(offers) { offer ->-            PartialOfferCard(offer, selected = offer.offerId == pickedId) { onPick(offer) }-        }-        if (loading || error != null || offers.isEmpty()) {-            item {-                StatusBox(-                    loading = loading,-                    error = error,-                    isEmpty = !loading && error == null && offers.isEmpty(),-                    emptyMessage = stringResource(R.string.no_flights_for_leg),-                )-            }-        }-        if (pickedId != null) {-            item {-                Button(-                    onClick = { if (allPicked) onFinish() else onNextLeg() },-                    modifier = Modifier.fillMaxWidth().padding(16.dp),-                ) {-                    Text(-                        if (allPicked) stringResource(R.string.review_picks, pickedLabel.orEmpty())-                        else stringResource(R.string.continue_action)-                    )-                }-            }-        }-    }-}--@Composable-private fun PartialOfferCard(offer: OfferDto, selected: Boolean = false, onClick: () -> Unit) {+private fun PartialOfferCard(offer: OfferDto, onClick: () -> Unit) {     val is24 = rememberIs24Hour()     ElevatedCard(         modifier = Modifier@@ -304,9 +178,6 @@ private fun PartialOfferCard(offer: OfferDto, selected: Boolean = false, onClick                     if (offer.fareBrand.isNotBlank()) {                         AssistChip(onClick = {}, label = { Text(offer.fareBrand) })                     }-                    if (selected) {-                        AssistChip(onClick = {}, label = { Text(stringResource(R.string.picked)) })-                    }                 }                 offer.slices.forEach { slice ->                     val times = "${formatTime(slice.departureAt, is24)} – ${formatTime(slice.arrivalAt, is24)}"
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.ktnew file mode 100644index 0000000000..5c9ea2bb5d--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PassengerDialog.kt@@ -0,0 +1,114 @@+package com.vayunmathur.travel.ui++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.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import androidx.compose.ui.window.Dialog+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.travel.R+import com.vayunmathur.library.ui.R as UiR++/**+ * Google-Flights-style passenger popup: Adults, Children (aged 2-11),+ * Infants in seat, Infants on lap — each a +/- stepper — with Cancel/Done.+ * State is staged locally so Cancel discards edits.+ */+@Composable+fun PassengerDialog(+    mix: PassengerMix,+    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) }++    Dialog(onDismissRequest = onCancel) {+        Surface(shape = MaterialTheme.shapes.medium) {+            Column(+                Modifier.padding(16.dp),+                verticalArrangement = Arrangement.spacedBy(4.dp),+            ) {+                CountStepper(stringResource(R.string.adults), adults, onCount = { adults = it }, min = 1, max = 9)+                Column {+                    CountStepper(+                        stringResource(R.string.children),+                        children,+                        onCount = { children = it },+                        min = 0,+                        max = 6,+                    )+                    Text(+                        stringResource(R.string.children_ages),+                        style = MaterialTheme.typography.bodySmall,+                        color = MaterialTheme.colorScheme.onSurfaceVariant,+                        modifier = Modifier.padding(start = 16.dp),+                    )+                }+                Column {+                    CountStepper(+                        stringResource(R.string.infants_in_seat),+                        infantsInSeat,+                        onCount = { infantsInSeat = it },+                        min = 0,+                        max = adults,+                    )+                    Text(+                        stringResource(R.string.in_seat),+                        style = MaterialTheme.typography.bodySmall,+                        color = MaterialTheme.colorScheme.onSurfaceVariant,+                        modifier = Modifier.padding(start = 16.dp),+                    )+                }+                Column {+                    CountStepper(+                        stringResource(R.string.infants_on_lap),+                        infantsOnLap,+                        onCount = { infantsOnLap = it },+                        min = 0,+                        max = adults,+                    )+                    Text(+                        stringResource(R.string.on_lap),+                        style = MaterialTheme.typography.bodySmall,+                        color = MaterialTheme.colorScheme.onSurfaceVariant,+                        modifier = Modifier.padding(start = 16.dp),+                    )+                }+                Row(+                    Modifier.fillMaxWidth(),+                    horizontalArrangement = Arrangement.End,+                ) {+                    TextButton(onClick = onCancel) { Text(stringResource(UiR.string.cancel)) }+                    TextButton(onClick = {+                        // Preserve existing child ages where possible; new+                        // children default to age 8.+                        val ages = (0 until children).map { mix.childAges.getOrElse(it) { 8 } }+                        onDone(+                            PassengerMix(+                                adults = adults,+                                childAges = ages,+                                infantsInSeat = infantsInSeat,+                                infantsOnLap = infantsOnLap,+                            )+                        )+                    }) { Text(stringResource(UiR.string.done)) }+                }+            }+        }+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/PassengerField.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/PassengerField.kt b/travel/src/main/java/com/vayunmathur/travel/ui/PassengerField.ktnew file mode 100644index 0000000000..ebf232d4d0--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PassengerField.kt@@ -0,0 +1,58 @@+package com.vayunmathur.travel.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.IconPerson+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text++/**+ * Compact passenger field for the dropdown row: shows a person icon + total+ * count, opening the Google-Flights-style passenger popup ([PassengerDialog]).+ */+@Composable+fun PassengerField(+    mix: PassengerMix,+    onMix: (PassengerMix) -> Unit,+    modifier: Modifier = Modifier,+) {+    var show by remember { mutableStateOf(false) }+    Box(modifier) {+        Surface(+            onClick = { show = true },+            shape = MaterialTheme.shapes.small,+            color = MaterialTheme.colorScheme.surfaceContainerHigh,+        ) {+            Row(+                Modifier.padding(horizontal = 12.dp, vertical = 8.dp),+                verticalAlignment = Alignment.CenterVertically,+                horizontalArrangement = Arrangement.spacedBy(4.dp),+            ) {+                IconPerson()+                Text("${mix.total}", style = MaterialTheme.typography.labelLarge)+                Text("▾", style = MaterialTheme.typography.labelLarge)+            }+        }+    }+    if (show) {+        PassengerDialog(+            mix = mix,+            onDone = {+                onMix(it)+                show = false+            },+            onCancel = { show = false },+        )+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/PassengerMix.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/PassengerMix.kt b/travel/src/main/java/com/vayunmathur/travel/ui/PassengerMix.ktnew file mode 100644index 0000000000..bf0dccc239--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/PassengerMix.kt@@ -0,0 +1,12 @@+package com.vayunmathur.travel.ui++/** Passenger mix edited in the popup dialog (mirrors the flight query fields). */+data class PassengerMix(+    val adults: Int = 1,+    val childAges: List<Int> = emptyList(),+    val infantsInSeat: Int = 0,+    val infantsOnLap: Int = 0,+) {+    /** Total headcount label, e.g. "3". */+    val total: Int get() = adults + childAges.size + infantsInSeat + infantsOnLap+}
travel/src/main/java/com/vayunmathur/travel/ui/SearchDropdown.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/SearchDropdown.kt b/travel/src/main/java/com/vayunmathur/travel/ui/SearchDropdown.ktnew file mode 100644index 0000000000..29cca83773--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/ui/SearchDropdown.kt@@ -0,0 +1,67 @@+package com.vayunmathur.travel.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.DropdownMenu+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.SelectableDropdownMenuItem+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text++/**+ * A compact pill-style dropdown used in the search-form dropdown row+ * (Google-Flights style): shows [display] with a caret, opening a+ * [DropdownMenu] of [options] on tap. The selected option renders selected.+ *+ * @param options value → label pairs shown in the menu.+ */+@Composable+fun SearchDropdown(+    display: String,+    options: List<Pair<String, String>>,+    selectedValue: String,+    onSelect: (String) -> Unit,+    modifier: Modifier = Modifier,+    leadingIcon: (@Composable () -> Unit)? = null,+) {+    var expanded by remember { mutableStateOf(false) }+    Box(modifier) {+        Surface(+            onClick = { expanded = true },+            shape = MaterialTheme.shapes.small,+            color = MaterialTheme.colorScheme.surfaceContainerHigh,+        ) {+            Row(+                Modifier.padding(horizontal = 12.dp, vertical = 8.dp),+                verticalAlignment = Alignment.CenterVertically,+                horizontalArrangement = Arrangement.spacedBy(4.dp),+            ) {+                leadingIcon?.invoke()+                Text(display, style = MaterialTheme.typography.labelLarge)+                Text("▾", style = MaterialTheme.typography.labelLarge)+            }+        }+        DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {+            options.forEach { (value, label) ->+                SelectableDropdownMenuItem(+                    selected = value == selectedValue,+                    onClick = {+                        onSelect(value)+                        expanded = false+                    },+                    text = { Text(label) },+                )+            }+        }+    }+}
travel/src/main/java/com/vayunmathur/travel/ui/StaySearchForm.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/StaySearchForm.kt b/travel/src/main/java/com/vayunmathur/travel/ui/StaySearchForm.ktindex bce60bb15f..2ee43fb587 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/StaySearchForm.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/StaySearchForm.kt@@ -2,10 +2,13 @@ package com.vayunmathur.travel.ui import com.vayunmathur.travel.R  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.rememberScrollState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue@@ -13,6 +16,7 @@ import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.Button@@ -22,10 +26,15 @@ import com.vayunmathur.library.ui.Text import com.vayunmathur.travel.util.TravelViewModel import com.vayunmathur.travel.util.staySuggestions import androidx.compose.ui.res.stringResource+import kotlinx.datetime.DatePeriod+import kotlinx.datetime.LocalDate+import kotlinx.datetime.plus  /**  * Hotel search form (used from Home when the "Stays" product is selected):- * location autocomplete, check-in/out dates, rooms and guests.+ * location autocomplete, check-in/out dates, rooms and guests dropdowns.+ *+ * Date rules: check-in not before today; check-out after check-in.  */ @Composable fun StaySearchForm(@@ -39,9 +48,31 @@ fun StaySearchForm(     var checkIn by remember { mutableStateOf("") }     var checkOut by remember { mutableStateOf("") }     var rooms by remember { mutableIntStateOf(1) }-    var adults by remember { mutableIntStateOf(2) }+    var guests by remember { mutableIntStateOf(2) }++    val today = remember { todayUtc() }+    val checkInDate = remember(checkIn) { runCatching { LocalDate.parse(checkIn) }.getOrNull() }+    val checkOutDate = remember(checkOut) { runCatching { LocalDate.parse(checkOut) }.getOrNull() }      Column(modifier.fillMaxWidth().padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {+        Row(+            Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),+            horizontalArrangement = Arrangement.spacedBy(8.dp),+            verticalAlignment = Alignment.CenterVertically,+        ) {+            SearchDropdown(+                display = "$rooms ${stringResource(R.string.rooms)}",+                options = (1..5).map { it.toString() to "$it" },+                selectedValue = rooms.toString(),+                onSelect = { rooms = it.toInt() },+            )+            SearchDropdown(+                display = "$guests ${stringResource(R.string.guests)}",+                options = (1..9).map { it.toString() to "$it" },+                selectedValue = guests.toString(),+                onSelect = { guests = it.toInt() },+            )+        }         StaySuggestField(             label = stringResource(com.vayunmathur.travel.R.string.destination_or_hotel),             viewModel = viewModel,@@ -51,13 +82,27 @@ fun StaySearchForm(                 longitude = lng             },         )-        DateField(stringResource(R.string.check_in), checkIn, onDate = { checkIn = it })-        DateField(stringResource(R.string.check_out), checkOut, onDate = { checkOut = it })-        CountStepper(stringResource(R.string.rooms), rooms, onCount = { rooms = it }, min = 1, max = 5)-        CountStepper(stringResource(R.string.guests), adults, onCount = { adults = it }, min = 1, max = 9)+        Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {+            DateField(+                stringResource(R.string.check_in),+                checkIn,+                onDate = { checkIn = it },+                modifier = Modifier.weight(1f),+                minDate = today,+            )+            DateField(+                stringResource(R.string.check_out),+                checkOut,+                onDate = { checkOut = it },+                modifier = Modifier.weight(1f),+                minDate = checkInDate?.plus(DatePeriod(days = 1)) ?: today,+            )+        }+        val checkInValid = checkInDate != null && checkInDate >= today+        val checkOutValid = checkOutDate != null && checkInDate != null && checkOutDate > checkInDate         Button(-            onClick = { onSearch(place, checkIn, checkOut, rooms, adults, latitude, longitude) },-            enabled = place.isNotBlank() && checkIn.isNotBlank() && checkOut.isNotBlank(),+            onClick = { onSearch(place, checkIn, checkOut, rooms, guests, latitude, longitude) },+            enabled = place.isNotBlank() && checkInValid && checkOutValid,             modifier = Modifier.fillMaxWidth(),         ) { Text(stringResource(R.string.search_hotels)) }     }
travel/src/main/java/com/vayunmathur/travel/util/TravelSearchOps.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelSearchOps.kt b/travel/src/main/java/com/vayunmathur/travel/util/TravelSearchOps.ktindex e4923f206b..4cf13ca41b 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelSearchOps.kt+++ b/travel/src/main/java/com/vayunmathur/travel/util/TravelSearchOps.kt@@ -32,16 +32,10 @@ private fun parseFirstLeg(slices: String): FirstLeg { }  private fun TravelViewModel.recordFlightSearch(query: FlightQuery, leg: FirstLeg) {-    val multiCity = query.legs.size > 2 ||-        (query.legs.size == 2 && !query.isRoundTrip)     recordRecent(         RecentSearch(             vertical = Vertical.FLIGHTS.name,-            label = if (multiCity) {-                "${leg.origin} → … · multi-city"-            } else {-                "${leg.origin} → ${leg.destination} · ${TravelViewModel.prettyDate(leg.depart)}"-            },+            label = "${leg.origin} → ${leg.destination} · ${TravelViewModel.prettyDate(leg.depart)}",             origin = leg.origin,             destination = leg.destination,             depart = leg.depart,@@ -90,6 +84,41 @@ fun TravelViewModel.searchFlights(query: FlightQuery) {     } } +/**+ * Explore destination suggestions for the map pins: cached lowest fares from+ * `find_destination` (exploration-only; the pin sheet re-searches live).+ */+fun TravelViewModel.searchExplore(+    origin: String,+    tripType: String,+    depart: String,+    returnDate: String? = null,+    cabin: String = "economy",+    adults: Int = 1,+    children: String = "",+    infants: Int = 0,+    maxConnections: Int = -1,+) {+    exploreMutable.value = ExploreSearchState(loading = true, hasSearched = true)+    viewModelScope.launch {+        runCatching {+            TravelApi.explore(+                origins = origin,+                tripType = tripType,+                depart = depart,+                returnDate = returnDate,+                cabin = cabin,+                adults = adults,+                children = children,+                infants = infants,+                maxConnections = maxConnections,+            )+        }+            .onSuccess { exploreMutable.value = ExploreSearchState(destinations = it.destinations, hasSearched = true) }+            .onFailure { exploreMutable.value = ExploreSearchState(error = errorMessage(it), hasSearched = true) }+    }+}+ /** Change the on-device sort (no re-fetch). */ fun TravelViewModel.setSort(sort: OfferSort) {     flightsMutable.value = flightsMutable.value.copy(sort = sort)@@ -133,8 +162,8 @@ fun TravelViewModel.selectOffer(offer: OfferDto) { }  /**- * Seed the review screen with several offers (multi-city: one per leg);- * booking posts all ids in one trip.+ * Seed the review screen with several offers (round-trip: outbound + inbound+ * fares); booking posts all ids in one trip.  */ fun TravelViewModel.selectOffers(offers: List<OfferDto>) {     val first = offers.firstOrNull()@@ -235,67 +264,3 @@ fun TravelViewModel.loadPartialFares(outboundSignature: String, inboundSignature fun TravelViewModel.partialOfferById(offerId: String): OfferDto? =     partialFlowMutable.value.allOffers.find { it.offerId == offerId }         ?: partialFlowMutable.value.offers.find { it.offerId == offerId }--// --- Multi-city: one one-way search per leg ----------------------------------/** Start the multi-city flow: search the first leg (each leg is one-way). */-fun TravelViewModel.startMultiCitySearch(query: FlightQuery) {-    multiCityMutable.value = MultiCityState(loading = true)-    searchMultiCityLeg(query, 0)-}--/** Search one leg of a multi-city trip as a one-way. */-fun TravelViewModel.searchMultiCityLeg(query: FlightQuery, legIndex: Int) {-    val legs = query.legs-    val leg = legs.getOrNull(legIndex)-    if (leg == null) {-        multiCityMutable.value = multiCityMutable.value.copy(-            loading = false,-            error = "Unknown leg. Please restart your search."-        )-        return-    }-    currentQuery = query-    multiCityMutable.value = multiCityMutable.value.copy(loading = true, error = null)-    viewModelScope.launch {-        val loyalty = loyaltyParam()-        val parts = leg.split(':')-        runCatching {-            TravelApi.flights(-                slices = leg,-                adults = query.adults,-                children = query.children,-                infants = query.infants,-                cabin = query.cabin,-                maxConnections = query.maxConnections,-                loyalty = loyalty,-            )-        }-            .onSuccess { result ->-                multiCityMutable.value = multiCityMutable.value.copy(-                    loading = false,-                    legOffers = multiCityMutable.value.legOffers + (legIndex to result.offers),-                )-            }-            .onFailure {-                multiCityMutable.value = multiCityMutable.value.copy(-                    loading = false,-                    error = errorMessage(it) + " (${parts.getOrNull(0).orEmpty()} → ${parts.getOrNull(1).orEmpty()})"-                )-            }-    }-}--/** Pick one offer for a multi-city leg. */-fun TravelViewModel.selectMultiCityOffer(legIndex: Int, offer: OfferDto) {-    multiCityMutable.value = multiCityMutable.value.copy(-        selectedOfferIds = multiCityMutable.value.selectedOfferIds + (legIndex to offer.offerId),-    )-}--/** The chosen offer per leg, in leg order (nulls where unpicked). */-fun TravelViewModel.multiCitySelection(legCount: Int): List<OfferDto?> =-    (0 until legCount).map { legIndex ->-        val id = multiCityMutable.value.selectedOfferIds[legIndex] ?: return@map null-        multiCityMutable.value.legOffers[legIndex]?.find { it.offerId == id }-    }
travel/src/main/java/com/vayunmathur/travel/util/TravelUiState.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelUiState.kt b/travel/src/main/java/com/vayunmathur/travel/util/TravelUiState.ktindex c79b1b8c52..c54fabe20a 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelUiState.kt+++ b/travel/src/main/java/com/vayunmathur/travel/util/TravelUiState.kt@@ -13,6 +13,14 @@ import com.vayunmathur.travel.network.StaySearchResultDto import com.vayunmathur.travel.network.TripAncillariesDto import com.vayunmathur.travel.network.TripDto +/** State for the explore map: destination suggestions with cached fares. */+data class ExploreSearchState(+    val loading: Boolean = false,+    val error: String? = null,+    val destinations: List<com.vayunmathur.travel.network.ExploreDestinationDto> = emptyList(),+    val hasSearched: Boolean = false,+)+ /** Search state for the flight results list. */ data class SearchUiState<T>(     val loading: Boolean = false,@@ -100,16 +108,6 @@ data class PartialFlowState(     val offers: List<OfferDto> = emptyList(), ) -/** State for the multi-city flow: one offer picked per searched leg. */-data class MultiCityState(-    val loading: Boolean = false,-    val error: String? = null,-    /** leg index → search results for that leg. */-    val legOffers: Map<Int, List<OfferDto>> = emptyMap(),-    /** leg index → chosen offer id. */-    val selectedOfferIds: Map<Int, String> = emptyMap(),-)- /** State for the trip ancillaries step (bags + seat maps off the trip). */ data class AncillariesState(     val loading: Boolean = false,
travel/src/main/java/com/vayunmathur/travel/util/TravelViewModel.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelViewModel.kt b/travel/src/main/java/com/vayunmathur/travel/util/TravelViewModel.ktindex 4fc8c80ffc..9327695643 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelViewModel.kt+++ b/travel/src/main/java/com/vayunmathur/travel/util/TravelViewModel.kt@@ -50,7 +50,7 @@ class TravelViewModel(     /** The query backing the current results, kept so re-sort can re-fetch. */     internal var currentQuery: FlightQuery? = null -    /** Normal booking flow: one reviewed offer (or several for multi-city). */+    /** Normal booking flow: one reviewed offer. */     internal val selectedOfferIdsMutable = MutableStateFlow<List<String>>(emptyList())     val selectedOfferIds: StateFlow<List<String>> = selectedOfferIdsMutable.asStateFlow() @@ -60,9 +60,6 @@ class TravelViewModel(     internal val partialFlowMutable = MutableStateFlow(PartialFlowState())     val partialFlow: StateFlow<PartialFlowState> = partialFlowMutable.asStateFlow() -    internal val multiCityMutable = MutableStateFlow(MultiCityState())-    val multiCity: StateFlow<MultiCityState> = multiCityMutable.asStateFlow()-     internal val passengersMutable = MutableStateFlow<List<PassengerInputDto>>(emptyList())     val passengers: StateFlow<List<PassengerInputDto>> = passengersMutable.asStateFlow() @@ -135,6 +132,9 @@ class TravelViewModel(     internal val stayBookingMutable = MutableStateFlow<StayBookingState>(StayBookingState.Idle)     val stayBooking: StateFlow<StayBookingState> = stayBookingMutable.asStateFlow() +    internal val exploreMutable = MutableStateFlow(ExploreSearchState())+    val explore: StateFlow<ExploreSearchState> = exploreMutable.asStateFlow()+     /** The rate the user chose to book, plus context for persistence. */     internal var selectedRate: StayRateDto? = null     internal var selectedStayName: String = ""
travel/src/main/res/values/strings.xml
diff --git a/travel/src/main/res/values/strings.xml b/travel/src/main/res/values/strings.xmlindex c2e2cc7aab..ad4aae179e 100644--- a/travel/src/main/res/values/strings.xml+++ b/travel/src/main/res/values/strings.xml@@ -17,8 +17,6 @@     <string name="one_way">One-way</string>     <!-- Trip type enum: round trip. Noun phrase -->     <string name="round_trip">Round trip</string>-    <!-- Trip type enum: multi-city. Noun phrase -->-    <string name="multi_city">Multi-city</string>     <!-- Cabin class enum: economy. Noun -->     <string name="economy">Economy</string>     <!-- Cabin class enum: premium economy. Noun -->@@ -31,26 +29,50 @@     <string name="flights">Flights</string>     <!-- Product tab: hotel stays search. Noun plural -->     <string name="stays">Stays</string>+    <!-- Product tab: car rentals search. Noun plural -->+    <string name="cars">Cars</string>     <!-- Label for departure segment / calendar sheet. Verb/noun departure -->     <string name="depart">Depart</string>     <!-- Label for return segment, avoids keyword 'return'. Noun -->     <string name="return_label">Return</string>-    <!-- Leg header: Flight number in itinerary. %1$s = leg index 1,2,3 -->-    <string name="flight_1">Flight <xliff:g id="number" example="1">%1$s</xliff:g></string>     <!-- Passenger picker: adult count. Noun plural -->     <string name="adults">Adults</string>     <!-- Passenger picker: children count. Noun plural -->     <string name="children">Children</string>-    <!-- Passenger picker: child age row. %1$s = child index 1,2. Leading spaces are layout padding, preserve -->-    <string name="child_age">  Child <xliff:g id="child_number" example="1">%1$s</xliff:g> age</string>+    <!-- Passenger popup subtitle: qualifying ages. Sentence fragment -->+    <string name="children_ages">Aged 2–11</string>+    <!-- Passenger popup: infants occupying a seat. Noun phrase -->+    <string name="infants_in_seat">Infants</string>+    <!-- Subtitle: infant occupies a paid seat. Noun phrase -->+    <string name="in_seat">In seat</string>+    <!-- Subtitle: infant travels on lap. Noun phrase -->+    <string name="on_lap">On lap</string>     <!-- Passenger picker: infants on lap. Noun phrase -->     <string name="infants_on_lap">Infants (on lap)</string>-    <!-- Filter chip: nonstop only toggle. Noun phrase -->-    <string name="nonstop_only">Nonstop only</string>-    <!-- Button: add another flight leg in multi-city. Verb phrase -->-    <string name="add_another_flight">Add another flight</string>+    <!-- Dropdown label: maximum stops. Noun phrase -->+    <string name="max_stops">Max stops</string>+    <!-- Max-stops option: nonstop (0). Noun/adj -->+    <string name="stops_nonstop">Nonstop</string>+    <!-- Max-stops option: up to one stop. Noun phrase -->+    <string name="stops_1">1 stop</string>+    <!-- Max-stops option: up to two stops. Noun phrase -->+    <string name="stops_2_plus">2+ stops</string>     <!-- CTA: search flights submit button. Verb phrase -->     <string name="search_flights">Search flights</string>+    <!-- Pinned row in the To field: open Explore discovery. Verb -->+    <string name="explore">Explore</string>+    <!-- Explore row subtitle: search anywhere. Noun phrase -->+    <string name="explore_anywhere">Explore destinations</string>+    <!-- CTA: search in explore mode. Verb phrase -->+    <string name="explore_search">Explore</string>+    <!-- Explore map title. %1$s = origin code e.g. SFO -->+    <string name="explore_title">Explore from <xliff:g id="origin" example="SFO">%1$s</xliff:g></string>+    <!-- Explore sheet: cached fare disclaimer. Sentence -->+    <string name="explore_fare_note">Explore fares are estimates. Live prices load below.</string>+    <!-- Explore sheet: live fares header. Noun phrase -->+    <string name="explore_live_fares">Live flights</string>+    <!-- Empty state: no explore destinations. Sentence -->+    <string name="explore_empty">No destinations found. Try different dates.</string>     <!-- Date field label: new requested date when changing flight -->     <string name="new_date">New date</string> @@ -110,14 +132,8 @@     <string name="step_2_of_3">Step 2 of 3</string>     <!-- Step indicator 3 of 3. Noun phrase -->     <string name="step_3_of_3">Step 3 of 3</string>-    <!-- Multi-city leg title. %1$d = leg index, %2$d = leg count -->-    <string name="choose_flight_leg">Choose flight <xliff:g id="index" example="1">%1$d</xliff:g> of <xliff:g id="count" example="3">%2$d</xliff:g></string>-    <!-- Empty state: no flights for this leg. Sentence -->-    <string name="no_flights_for_leg">No flights available for this leg.</string>-    <!-- Chip: a picked multi-city leg. Adjective -->-    <string name="picked">Picked</string>-    <!-- CTA: review all picked multi-city flights. %1$s = total e.g. $812 -->-    <string name="review_picks">Review picks · <xliff:g id="total" example="$812">%1$s</xliff:g></string>+    <!-- Empty state: no flights for this step. Sentence -->+    <string name="no_flights_for_leg">No flights available.</string>      <!-- TopAppBar title for extras / ancillaries. Verb phrase -->     <string name="add_extras">Add extras</string>@@ -394,4 +410,47 @@     <string name="continue_to_payment">Continue to payment</string>      <string name="destination_or_hotel">Destination or hotel</string>++    <!-- Field label: car pickup location (airport code or place). Noun -->+    <string name="pickup">Pickup</string>+    <!-- Field label: car drop-off location. Noun -->+    <string name="dropoff">Drop-off</string>+    <!-- Field label: car pickup date and time. Noun phrase -->+    <string name="pickup_datetime">Pickup date</string>+    <!-- Field label: car drop-off date and time. Noun phrase -->+    <string name="dropoff_datetime">Drop-off date</string>+    <!-- Field label: driver age in years. Noun phrase -->+    <string name="driver_age">Driver age</string>+    <!-- CTA: search rental cars submit button. Verb phrase -->+    <string name="search_cars">Search cars</string>+    <!-- Results title: rental cars at place. %1$s = place name -->+    <string name="cars_at">Cars at <xliff:g id="place" example="Lyon">%1$s</xliff:g></string>+    <!-- Fallback label: car when name missing. Noun -->+    <string name="car">Car</string>+    <!-- Empty state: no cars found. Sentence -->+    <string name="no_cars_found">No cars found for those dates.</string>+    <!-- TopAppBar title for reviewing a car offer. Verb phrase -->+    <string name="review_car">Review car</string>+    <!-- CTA: continue from car review to booking. Verb phrase -->+    <string name="book_car">Book car</string>+    <!-- Section header: vehicle details. Noun phrase -->+    <string name="vehicle_details">Vehicle details</string>+    <!-- Section header: rental package / inclusions. Noun -->+    <string name="package_label">Package</string>+    <!-- Row label: transmission type. Noun -->+    <string name="transmission">Transmission</string>+    <!-- Row label: fuel policy. Noun phrase -->+    <string name="fuel_policy">Fuel policy</string>+    <!-- Row label: mileage terms. Noun -->+    <string name="mileage">Mileage</string>+    <!-- Value: unlimited mileage. Adjective phrase -->+    <string name="unlimited">Unlimited</string>+    <!-- Row label: supplier / vendor name. Noun -->+    <string name="supplier">Supplier</string>+    <!-- Row label: amount due at the desk. Noun phrase -->+    <string name="due_at_desk">Due at desk</string>+    <!-- Row label: refundable deposit. Noun -->+    <string name="deposit">Deposit</string>+    <!-- Notice: car booking, price may change at desk. Sentence -->+    <string name="car_price_note">Pay now to lock this price; local fees may apply at the desk.</string> </resources>
travel/src/test/java/com/vayunmathur/travel/pure/ExploreSlicesTest.kt
diff --git a/travel/src/test/java/com/vayunmathur/travel/pure/ExploreSlicesTest.kt b/travel/src/test/java/com/vayunmathur/travel/pure/ExploreSlicesTest.ktnew file mode 100644index 0000000000..028c992497--- /dev/null+++ b/travel/src/test/java/com/vayunmathur/travel/pure/ExploreSlicesTest.kt@@ -0,0 +1,54 @@+package com.vayunmathur.travel.pure++import com.vayunmathur.travel.domain.exploreLiveSlices+import kotlin.test.Test+import kotlin.test.assertEquals++/**+ * Pins the live-search slices built for an Explore pin tap: explore fares+ * are cached estimates, so the sheet re-searches the tapped destination+ * through the normal flight flow before anything is bookable.+ */+class ExploreSlicesTest {+    @Test+    fun oneWayIsSingleSlice() {+        assertEquals(+            "SFO:CDG:2026-09-23",+            exploreLiveSlices(+                origin = "SFO",+                destinationCode = "CDG",+                departDate = "2026-09-23",+                returnDate = "",+                isRoundTrip = false,+            )+        )+    }++    @Test+    fun roundTripReversesSecondSlice() {+        assertEquals(+            "SFO:CDG:2026-09-23,CDG:SFO:2026-09-30",+            exploreLiveSlices(+                origin = "SFO",+                destinationCode = "CDG",+                departDate = "2026-09-23",+                returnDate = "2026-09-30",+                isRoundTrip = true,+            )+        )+    }++    @Test+    fun roundTripWithoutReturnFallsBackToOneWay() {+        assertEquals(+            "SFO:CDG:2026-09-23",+            exploreLiveSlices(+                origin = "SFO",+                destinationCode = "CDG",+                departDate = "2026-09-23",+                returnDate = "",+                isRoundTrip = true,+            )+        )+    }+}