This commit introduces several enhancements to the flight search user interface and underlying logic.
Key changes:
- Added an extension function `Flight.hasFlights()` to check if a flight object contains any actual flight data. This is located in `ui/home/src/main/kotlin/dev/adriankuta/flights/ui/home/extensions/FlightExt.kt`.
- In `StationsScreen.kt`:
- The origin airport display now includes a "Origin airport" label.
- The search input field placeholder text dynamically changes based on whether an origin airport has been selected (e.g., "Search origin airport" vs. "Search destination airport").
- In `StationsScreenViewModel.kt`:
- When an airport is selected, the search query is now automatically cleared.
- Added new string resources in `ui/stations/src/main/res/values/strings.xml` for the dynamic placeholder text: `search_origin_airport` and `search_destination_airport`.
- In `SearchResults.kt`:
- Implemented an `EmptyListComponent` to display a user-friendly message with an icon when no flights are found for the given search criteria.
- The `SearchResults` composable now utilizes `itemsIndexed` for better handling of dividers between trip cards.
- Dividers are no longer shown after the last item in the list of trips or trip dates.
- Added previews for the empty list state (`EmptyListPreview` and `SearchResultsEmptyPreview`).
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.
This commit refactors the package structure for Gradle convention plugins and introduces bottom navigation to the application.
Key changes:
- Moved Gradle convention plugin files from `dev.adriankuta.partymania` to `dev.adriankuta.flights`.
- Added `TopLevelDestination.kt` to define top-level navigation destinations with icons, titles, and routes.
- Implemented `FlightsBottomBar` Composable in `FlightsApp.kt` to display a `NavigationBar` with items for each `TopLevelDestination`.
- Updated `FlightsNavGraph.kt`:
- Renamed from `FlightsNavGraph.kt` to `navigation/FlightsNavGraph.kt`.
- Added `navigateToTopLevelDestination` extension function for `NavController` to handle navigation to top-level destinations with appropriate `NavOptions`.
- Updated `HomeNavigation.kt`:
- Added `navigateToHome` extension function for `NavController`.
- Added `strings.xml` for `ui:home` module with `home_screen_title`.
- Ensured Kotlin serialization plugin is correctly applied in `app/build.gradle.kts`.
This commit migrates date handling from `java.time` to `kotlinx-datetime` across various modules. It also introduces the display of flight search results on the home screen.
Key changes:
- Replaced `java.time.LocalDate` and related classes with `kotlinx.datetime.LocalDate` in:
- `ui/home/src/main/kotlin/dev/adriankuta/flights/ui/home/components/DatePicker.kt`
- `model/repository/src/main/kotlin/dev/adriankuta/flights/model/repository/usecases/GetFlightsSearchContentUseCaseImpl.kt`
- `ui/home/src/main/kotlin/dev/adriankuta/flights/ui/home/HomeScreen.kt`
- `ui/home/src/main/kotlin/dev/adriankuta/flights/ui/home/HomeScreenViewModel.kt`
- `domain/types/src/main/kotlin/dev/adriankuta/flights/domain/types/TripDate.kt`
- `ui/home/src/main/kotlin/dev/adriankuta/flights/ui/home/components/PassengersOptions.kt`
- `ui/home/src/main/kotlin/dev/adriankuta/flights/ui/home/components/SearchForm.kt`
- `domain/search/src/main/kotlin/dev/adriankuta/flights/domain/search/entities/SearchOptions.kt`
- Added `kotlinx-datetime` dependency to `build-logic/convention/src/main/kotlin/dev/adriankuta/partymania/ConfigureKotlinAndroid.kt`.
- Implemented `SearchResults.kt` composable to display flight search results.
- Updated `HomeScreen.kt` to show `SearchResults` when results are available and handle back navigation.
- Modified `HomeScreenViewModel.kt`:
- Introduced `SearchResultUiState` to manage search result states (Loading, Success, Error, Idle).
- Updated `search()` function to fetch and expose flight results.
- Adjusted initial airport list in `homeUiState` to filter for "DUB" and "STN" and ensure destination isn't the same as origin.
- Updated `FlightDomainMapper.kt` to parse date strings into `kotlinx.datetime.LocalDate`.
- Added `HomeUiStatePreviewParameterProvider.kt` and `FlightPreviewParameterProvider.kt` for Compose previews.
- Removed Timber dependency from `ui/home`, `domain/search`, and `domain/types` modules as it's now provided via convention plugin.
This commit introduces the ability to search for flights based on user-defined criteria.
Key changes:
- Added `GetFlightsSearchContentUseCase` interface in the domain layer and its implementation `GetFlightsSearchContentUseCaseImpl` in the repository layer to handle flight search logic.
- Implemented `FlightDomainMapper` to map `FlightResponse` from the API to the domain `Flight` model.
- Updated `NetworkModule`:
- Introduced `ServicesAPI` and `NativeAppsAPI` qualifiers to differentiate between Retrofit instances for different Ryanair APIs.
- Configured a new Retrofit instance for the `nativeapps.ryanair.com` base URL.
- Modified `FlightService` to use the `nativeapps.ryanair.com` base URL.
- Updated `FlightService` endpoint to `api/v4/en-gb/Availability`.
- Integrated `GetFlightsSearchContentUseCase` into `HomeScreenViewModel` to trigger flight searches.
- Created `SearchOptions` data class in the domain layer to encapsulate search parameters.
- Added `GetFlightsSearchContentUseCaseModule` to provide the use case implementation via Hilt.
This commit adds Jetpack Compose `@Preview` annotations to several UI components in the `ui:home` module. This allows developers to visualize these components in Android Studio without needing to run the full application.
Key changes:
- Added `@PreviewDevices` and `FlightsTheme` to `PassengersOptions.kt` and created a `PassengersOptionsPreview` composable function with sample data.
- Added `@PreviewDevices` and `FlightsTheme` to `DatePicker.kt` and created a `DatePickerPreview` composable function with sample data.
- Added `@PreviewDevices` and `FlightsTheme` to `SearchForm.kt` and created a `SearchFormPreview` composable function with sample airport and passenger data.
- Added `@PreviewDevices` and `FlightsTheme` to `AirportDropdown.kt` and created an `AirportDropdownPreview` composable function with sample airport data.
This commit refactors the HomeScreen by extracting the search form logic into a new `SearchForm` composable and the passenger selection into a `PassengersOptions` composable.
Key changes:
- Created `PassengersOptions.kt` with a composable function to handle adult, teen, and child passenger counts.
- Created `SearchForm.kt` with a composable function that encapsulates airport selection, date picking, passenger options, and the search button.
- Updated `HomeScreen.kt`:
- Replaced the previous inline form layout with the new `SearchForm` composable.
- Made the screen content vertically scrollable using `Box` and `verticalScroll`.
- Passed a new `onSearch` lambda to the `HomeScreenContent`.
- Updated `HomeScreenViewModel.kt`:
- Modified `updateAdultCount`, `updateTeenCount`, and `updateChildCount` to accept the new count directly instead of a diff.
- Added a `search()` function (currently logs to Timber).
- Ensured child count does not exceed adult count when adult count changes.
- Updated `Counter.kt` in `ui/sharedui`:
- Changed `onCountChange` parameter to `onValueChange` which now receives the new absolute value.
- Added a `maxVal` parameter to limit the maximum value of the counter.
This commit introduces a passenger counter component to the home screen, allowing users to specify the number of adults, teens, and children for their flight search.
Key changes:
- Added `ui:sharedui` module dependency to `ui:home`.
- Updated `PreviewDevices` annotation to include `showBackground = true`.
- Modified `HomeScreen`:
- Added parameters to `HomeContent` and `SearchForm` for passenger count change callbacks.
- Integrated the `Counter` composable from `ui:sharedui` for adults, teens, and children.
- Added `VerticalDivider` between counters.
- Updated previews to reflect passenger counter integration.
- Updated `HomeScreenViewModel`:
- Introduced `MutableStateFlow` for `adultCount`, `teenCount`, and `childCount`.
- Created `passengersState` flow by combining individual passenger count flows.
- Updated `homeUiState` to include `passengersState`.
- Added public functions `updateAdultCount`, `updateTeenCount`, and `updateChildCount` to modify passenger counts with validation.
- Added `PassengersState` data class to hold passenger counts.
- Updated `Counter` composable in `ui:sharedui`:
- Added an optional `minVal` parameter (defaulting to 0) to define the minimum allowed value for the counter.
- Ensured the decrement button is disabled when the counter value reaches `minVal`.
- Centered text in increment and decrement buttons.
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.
This commit introduces functionality for selecting origin and destination airports on the home screen.
Key changes:
- Modified `HomeScreen` to use `Column` instead of `LazyColumn` for layout.
- Added `AirportDropdown` composable component for selecting airports.
- Updated `HomeScreen` to include two `AirportDropdown` instances: one for origin and one for destination.
- Enhanced `HomeScreenViewModel`:
- Added `selectedOriginAirport` and `selectedDestinationAirport` state flows.
- Implemented `selectOriginAirport` and `selectDestinationAirport` functions to update selected airports.
- Added `clearOriginAirport` and `clearDestinationAirport` functions.
- Updated `homeUiState` to combine airport data with selected airports and filter destination airports to exclude the selected origin.
- Updated `HomeUiState.Success` to include `originAirports`, `destinationAirports`, `selectedOriginAirport`, and `selectedDestinationAirport`.
- Added new preview functions for `HomeScreen` in loading and success states with mock data.
This commit applies code formatting changes across multiple files and updates lint baseline files.
Key changes:
- Added trailing commas to data classes in the `domain/types` module and related files.
- Formatted `HomeScreenViewModel.kt`, `Result.kt`, `ObserveAirportsUseCase.kt`, `AirportService.kt`, `ObserveAirportsUseCaseModule.kt`, `AirportInfoDomainMapper.kt`, `AirportInfoModelMapper.kt`, `AirportsDatasourceModule.kt`, `AirportsDatasourceImpl.kt`, `FlightService.kt`, `Cache.kt`, and `CacheImpl.kt`.
- Updated `README.md` and `LICENCE.md` with minor formatting adjustments.
- Updated various `lint-baseline.xml` files due to changes in cached dependencies or formatting.
- Added new `lint-baseline.xml` files for `model/datasource/airports`, `model/datasource/shared`, `domain/search`, and `model/data/api`.
- Removed unused imports from `app/build.gradle.kts`.
- Reformatted XML files: `ic_launcher_round.xml`, `ic_launcher.xml`, `strings.xml`, `ic_launcher_background.xml`.
- Added project code style configuration files: `.idea/codeStyles/codeStyleConfig.xml` and `.idea/codeStyles/Project.xml`.
- Reformatted `characters.json`.
- Updated response data classes in `model/data/api/entities` with trailing commas and minor formatting.
This commit introduces a generic `Result` sealed interface to represent success, error, and loading states for asynchronous operations. It also updates the home screen UI and ViewModel to utilize this `Result` type for displaying different states.
Key changes:
- Added `Result.kt` in `core:util` defining the `Result` sealed interface and an `asResult()` Flow extension.
- Updated `HomeScreenViewModel` to use `asResult()` and map the `ObserveAirportsUseCase` output to `HomeUiState` (Loading, Success, Error).
- Modified `HomeUiState` to be a sealed interface with `Loading`, `Success`, and `Error` subtypes.
- Updated `HomeScreen` to handle different `HomeUiState` values and display appropriate UI (Loading text, Error text, or list of airports).
- Added `core.util` dependency to `ui:home`.
- Updated Moshi and Retrofit Moshi converter dependencies in `model/data/api/build.gradle.kts` and `gradle/libs.versions.toml`.
- Added `moshi` and `moshiKotlinCodegen` versions to `gradle/libs.versions.toml`.
- Removed `converter-moshi` and added `retrofit-converter-moshi` in `gradle/libs.versions.toml`.
- Added `ksp(libs.moshi.kotlin.codegen)` to `model/data/api/build.gradle.kts`.
- Added `INTERNET` permission to `app/src/main/AndroidManifest.xml`.
- Updated `ObserveAirportsUseCaseImpl` to use `cacheKey` when setting airports info and to fetch airports for "pl" (lowercase).
- Added `.editorconfig` file with Kotlin trailing comma settings.
This commit introduces the functionality to fetch airport data from the Ryanair API and display it in the UI.
Key changes:
- Added `AirportInfoModel` interface and its implementation `AirportInfoModelImpl` to represent airport data in the data layer.
- Created `AirportInfoModelMapper` to map `AirportResponse` to `AirportInfoModel`.
- Set the base URL for Retrofit in `NetworkModule` to `https://services-api.ryanair.com`.
- Added new Gradle modules: `model:data:shared`, `model:datasource:airports`, `model:datasource:shared`, and `domain:search`.
- Implemented `CacheImpl` in `model:data:shared` for generic caching.
- Defined `ObserveAirportsUseCase` interface in `domain:search` to observe airport data.
- Added Detekt configuration for the `domain:search` and `model:datasource:shared` modules.
- Created `AirportsDatasource` interface and its implementation `AirportsDatasourceImpl` to manage airport data.
- Implemented `AirportInfoDomainMapper` to map `AirportInfoModel` to the domain `AirportInfo`.
- Updated `HomeScreen` to display a list of airports using `LazyColumn`.
- Updated `HomeScreenViewModel` to fetch and expose airport data via `ObserveAirportsUseCase`.
- Added `ObserveAirportsUseCaseModule` to provide the `ObserveAirportsUseCase` implementation.
- Implemented `ObserveAirportsUseCaseImpl` in the repository layer to fetch data from the API and update the datasource.
- Added `kotlinx-datetime` dependency.
- Created `AirportsDatasourceModule` to provide `AirportsDatasource` and its implementation.
- Added `CacheObservers.kt` with a utility function `loadData` to handle cache observation and data loading logic.
- Updated dependencies in `model:data:simple`, `model:repository`, and `ui:home` build files.
- Updated `settings.gradle.kts` to include new modules.
- Defined `Cache` interface in `model:datasource:shared`.