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`.
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`.
This commit refactors the domain types to better represent flight-related data.
Key changes:
- Deleted the unused `Character` data class.
- Introduced new data classes:
- `Airport`: Represents airport information with sealed subtypes for `Departure`, `Arrival`, and `Connecting` airports.
- `AirportInfo`: Contains detailed information about an airport, including `City`, `MacCity`, `Region`, `Country`, and `Coordinates`.
- `City`: Represents city data with code and name.
- `Coordinates`: Represents geographical coordinates.
- `Country`: Represents country data including currency code.
- `Flight`: Top-level data class for flight information, including currency and a list of `Trip` objects.
- `MacCity`: Represents MAC (Multi-Airport City) code.
- `Region`: Represents region data.
- `RegularFare`: Contains a list of `TripFare` objects.
- `Route`: Defines a flight route with departure, arrival, and optional connecting airports.
- `Segment`: Represents a flight segment with origin, destination, flight number, dates, and duration.
- `Trip`: Represents a trip with a list of `TripDate` objects, origin, and destination.
- `TripDate`: Contains a date and a list of `TripFlight` objects for that date.
- `TripFare`: Represents a fare type with amount and count.
- `TripFlight`: Represents a specific flight within a trip, including fare information, segments, and operator.
This commit introduces Retrofit and Moshi to handle network requests and JSON parsing.
Key changes include:
- Added Retrofit, Moshi, OkHttp, and OkHttp Logging Interceptor dependencies to `libs.versions.toml` and `model/data/api/build.gradle.kts`.
- Created data classes for API responses: `AirportResponse`, `RouteResponse`, and `FlightResponse`.
- Defined Retrofit service interfaces: `AirportService`, `RoutesService`, and `FlightService`.
- Implemented a Hilt `NetworkModule` to provide Retrofit, Moshi, and OkHttpClient instances.
- Added a Detekt configuration file for the `model/data/api` module.
- Temporarily commented out `configureFlavors` in `AndroidApplicationConvention.kt` and `ConfigureLibrary.kt`.