feat: Introduce Result type and update UI states

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 is contained in:
2025-06-13 22:12:05 +02:00
parent 9e18987aaf
commit a7f8ca75be
9 changed files with 63 additions and 26 deletions

View File

@ -33,6 +33,8 @@ kotlinxSerializationJson = "1.8.1"
ksp = "2.1.21-2.0.1" # https://github.com/google/ksp/releases
material = "1.12.0"
mockk = "1.14.2" # https://github.com/mockk/mockk/releases
moshi = "1.15.2"
moshiKotlinCodegen = "1.15.2"
okhttpBom = "4.12.0"
retrofit = "3.0.0"
secrets = "2.0.1"
@ -73,7 +75,6 @@ androidx-test-uiautomator = { module = "androidx.test.uiautomator:uiautomator",
androidx-ui-text-google-fonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "uiTextGoogleFonts" }
app-update-ktx = { module = "com.google.android.play:app-update-ktx", version.ref = "appUpdateKtx" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
converter-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "converterMoshi" }
detekt-compose = { module = "io.nlopez.compose.rules:detekt", version.ref = "detektCompose" }
detekt-ktlint = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
@ -89,10 +90,13 @@ kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
mockk-android = { module = "io.mockk:mockk-android", version.ref = "mockk" }
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
moshi-kotlin-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshiKotlinCodegen" }
okhttp = { module = "com.squareup.okhttp3:okhttp" }
okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttpBom" }
okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
retrofit-converter-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "converterMoshi" }
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }
truth = { module = "com.google.truth:truth", version.ref = "truth" }