mirror of
https://github.com/AdrianKuta/android-challange-adrian-kuta.git
synced 2026-02-03 06:50:40 +01:00
This commit introduces a DatePicker component to the HomeScreen, allowing users to select a departure date for their flight search.
Key changes:
- Created a reusable `DatePicker` composable in `ui/home/src/main/kotlin/dev/adriankuta/flights/ui/home/components/DatePicker.kt`.
- This component uses Material 3 `DatePicker` and `DatePickerDialog`.
- It ensures that only future dates can be selected using a custom `FutureSelectableDates` class.
- The date is displayed in "yyyy-MM-dd" format.
- Clicking the `OutlinedTextField` opens the `DatePickerDialog`.
- Integrated the `DatePicker` into `HomeScreen.kt`.
- The `DatePicker` is placed below the destination airport dropdown.
- It is enabled only after a destination airport is selected.
- The selected date is passed from and updated in the `HomeScreenViewModel`.
- Updated `HomeScreenViewModel.kt`:
- Added a `selectedDate` `MutableStateFlow` initialized with the current date.
- Implemented a `selectDate` function to update `selectedDate`.
- Included `selectedDate` in the `homeUiState` flow and `HomeUiState.Success` data class.
- Updated `HomeScreenPreview` and `HomeScreenPreviewSuccess` to include the new `onDateSelect` parameter and provide a `selectedDate` for the success state.