mirror of
https://github.com/AdrianKuta/android-challange-adrian-kuta.git
synced 2025-07-02 05:37:59 +02:00
feat: Implement airport data fetching and display
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 is contained in:
15
model/datasource/airports/build.gradle.kts
Normal file
15
model/datasource/airports/build.gradle.kts
Normal file
@ -0,0 +1,15 @@
|
||||
plugins {
|
||||
alias(libs.plugins.flights.android.library)
|
||||
alias(libs.plugins.flights.android.library.hilt)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "dev.adriankuta.flights.model.datasource.airports"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.model.datasource.shared)
|
||||
implementation(projects.model.data.api)
|
||||
|
||||
implementation(libs.timber)
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package dev.adriankuta.flights.model.datasource.airports
|
||||
|
||||
import dev.adriankuta.flights.model.datasource.airports.entities.AirportInfoModel
|
||||
import dev.adriankuta.flights.model.datasource.shared.Cache
|
||||
import dev.adriankuta.model.data.api.entities.AirportResponse
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
interface AirportsDatasource {
|
||||
|
||||
val airports: StateFlow<Cache<List<AirportInfoModel>>>
|
||||
|
||||
suspend fun setAirportsInfo(airports: List<AirportResponse>, cacheKey: String)
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package dev.adriankuta.flights.model.datasource.airports.entities
|
||||
|
||||
interface AirportInfoModel {
|
||||
val code: String
|
||||
val name: String
|
||||
val seoName: String
|
||||
val isBase: Boolean
|
||||
val timeZone: String
|
||||
|
||||
// City properties
|
||||
val cityCode: String
|
||||
val cityName: String
|
||||
|
||||
// MacCity properties
|
||||
val macCode: String
|
||||
|
||||
// Region properties
|
||||
val regionCode: String
|
||||
val regionName: String
|
||||
|
||||
// Country properties
|
||||
val countryCode: String
|
||||
val countryName: String
|
||||
val countryCurrencyCode: String
|
||||
|
||||
// Coordinates properties
|
||||
val latitude: Double
|
||||
val longitude: Double
|
||||
}
|
12
model/datasource/shared/build.gradle.kts
Normal file
12
model/datasource/shared/build.gradle.kts
Normal file
@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
alias(libs.plugins.flights.android.library)
|
||||
alias(libs.plugins.flights.android.library.hilt)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "dev.adriankuta.flights.model.datasource.shared"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.timber)
|
||||
}
|
10
model/datasource/shared/config/detekt/detekt.yml
Normal file
10
model/datasource/shared/config/detekt/detekt.yml
Normal file
@ -0,0 +1,10 @@
|
||||
# Deviations from defaults
|
||||
formatting:
|
||||
TrailingCommaOnCallSite:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
useTrailingCommaOnCallSite: true
|
||||
TrailingCommaOnDeclarationSite:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
useTrailingCommaOnDeclarationSite: true
|
@ -0,0 +1,6 @@
|
||||
package dev.adriankuta.flights.model.datasource.shared;
|
||||
|
||||
public interface Cache<T> {
|
||||
public val cacheKey: String?
|
||||
public val data: T?
|
||||
}
|
Reference in New Issue
Block a user