This commit introduces the functionality to fetch available flight connections for a selected origin airport and filter the destination airport list accordingly.
Key changes:
- Added `GetConnectionsForAirportUseCase` interface in `domain/stations` to define the contract for fetching airport connections.
- Implemented `GetConnectionsForAirportUseCaseImpl` in `model/repository` to fetch routes from the `RoutesService` and map them to domain `Airport` types.
- Created `AirportDomainMapper.kt` in `model/repository/mappers` to map `RouteResponse` and its nested types to domain `Airport` and `MacCity` types.
- Added a Hilt module `GetConnectionsForAirportUseCaseModule` to provide the implementation for `GetConnectionsForAirportUseCase`.
- Renamed `OriginAirportsUiState` to `AirportsUiState` in `StationsScreen.kt` and `StationsScreenViewModel.kt` for better generality.
- Updated `StationsScreenViewModel`:
- Injected `GetConnectionsForAirportUseCase`.
- Added `_availableDestinationsCodes` StateFlow to hold the codes of airports reachable from the selected origin.
- Modified `airportsUiState` (previously `originAirportsUiState`) to take `filterDestinations` as a parameter and filter airports based on both search query and available destination codes.
- Added `AirportInfo.toDepartureAirPort()` extension function.
- Updated `StationsScreen.kt` to use the renamed `AirportsUiState`.
This commit introduces search functionality and airport selection to the StationsScreen. Users can now search for airports and select an origin airport, which will be displayed in a compact view.
Key changes:
- Added a search bar (`OutlinedTextField`) to `StationsScreen` to filter the list of airports.
- Implemented `searchQuery` StateFlow in `StationsScreenViewModel` to hold the current search term.
- Updated `originAirportsUiState` to filter airports based on the `searchQuery`.
- Added `selectedOriginAirport` StateFlow in `StationsScreenViewModel` to manage the selected airport.
- Introduced `AirportInfoCompact` composable to display the selected origin airport.
- Implemented `onAirportSelected` and `clearSelectedAirport` functions in `StationsScreenViewModel` to handle airport selection and clearing.
- Added `BackHandler` to clear the selected airport when the back button is pressed.
- Made `AirportInfoItem` clickable to trigger airport selection.
- Added string resource for "Search airports" placeholder.
- Added Detekt configuration files for `domain/stations` and `ui/stations` modules.
- Added Lint baseline files for `domain/stations` and `ui/stations` modules.
- Used `key` and `animateItem` for better performance and animations in `LazyColumn`.
This commit introduces a new "Stations" screen that displays airports grouped by country.
Key changes:
- Added a new Gradle module: `ui:stations`.
- Created `StationsScreen.kt` to display a list of airports grouped by country using `LazyColumn`. Airports within each country are displayed as `AirportInfoItem` and countries as `CountryItem`.
- Implemented `StationsScreenViewModel.kt` to fetch and manage the state of airports grouped by country. It uses `ObserveAirportsGroupedByCountry` use case.
- Defined `ObserveAirportsGroupedByCountry.kt` use case in `domain:stations` module to provide a flow of airports grouped by country.
- Implemented `ObserveAirportsGroupedByCountryImpl.kt` in the repository layer, which fetches data using `AirportService`, stores it in `AirportsDatasource`, and maps it to the domain model.
- Added Hilt module `ObserveAirportsGroupedByCountryModule.kt` to provide the use case implementation.
- Added `stationsScreen()` and `navigateToStations()` to `FlightsNavGraph.kt` and `TopLevelDestination.kt` for navigation.
- Updated `settings.gradle.kts` and `app/build.gradle.kts` to include the new `ui:stations` and `domain:stations` modules.
- Updated `CacheObservers.kt` to make `mapToDomain` a suspend function.
- Added string resources for the stations screen title.