mirror of
https://github.com/AdrianKuta/android-challange-adrian-kuta.git
synced 2025-07-01 23:47:59 +02:00
feat: Implement stations screen with grouped airports
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 is contained in:
@ -60,6 +60,7 @@ dependencies {
|
||||
|
||||
implementation(projects.ui.designsystem)
|
||||
implementation(projects.ui.home)
|
||||
implementation(projects.ui.stations)
|
||||
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(libs.androidx.core.splashscreen)
|
||||
|
@ -12,6 +12,8 @@ import androidx.navigation.navOptions
|
||||
import dev.adriankuta.flights.ui.home.navigation.HomeRoute
|
||||
import dev.adriankuta.flights.ui.home.navigation.homeScreen
|
||||
import dev.adriankuta.flights.ui.home.navigation.navigateToHome
|
||||
import dev.adriankuta.flights.ui.home.navigation.navigateToStations
|
||||
import dev.adriankuta.flights.ui.home.navigation.stationsScreen
|
||||
|
||||
@Composable
|
||||
fun FlightsNavGraph(
|
||||
@ -24,6 +26,7 @@ fun FlightsNavGraph(
|
||||
modifier = modifier,
|
||||
) {
|
||||
homeScreen()
|
||||
stationsScreen()
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +48,7 @@ fun NavController.navigateToTopLevelDestination(topLevelDestination: TopLevelDes
|
||||
|
||||
when (topLevelDestination) {
|
||||
TopLevelDestination.HOME -> navigateToHome(topLevelNavOptions)
|
||||
TopLevelDestination.STATIONS -> navigateToHome(topLevelNavOptions)
|
||||
TopLevelDestination.STATIONS -> navigateToStations(topLevelNavOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,10 @@ import androidx.compose.material.icons.outlined.Place
|
||||
import androidx.compose.material.icons.outlined.Search
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import dev.adriankuta.flights.ui.home.navigation.HomeRoute
|
||||
import dev.adriankuta.flights.ui.home.navigation.StationsRoute
|
||||
import kotlin.reflect.KClass
|
||||
import dev.adriankuta.flights.ui.home.R as homeR
|
||||
import dev.adriankuta.flights.ui.stations.R as stationsR
|
||||
|
||||
enum class TopLevelDestination(
|
||||
val icon: ImageVector,
|
||||
@ -22,7 +24,7 @@ enum class TopLevelDestination(
|
||||
),
|
||||
STATIONS(
|
||||
icon = Icons.Outlined.Place,
|
||||
titleTextId = homeR.string.home_screen_title,
|
||||
route = HomeRoute::class,
|
||||
titleTextId = stationsR.string.stations_screen_title,
|
||||
route = StationsRoute::class,
|
||||
),
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ internal fun FlightsBottomBar(
|
||||
selected = selectedDestination == index,
|
||||
onClick = {
|
||||
selectedDestination = index
|
||||
navController.navigateToTopLevelDestination(TopLevelDestination.HOME)
|
||||
navController.navigateToTopLevelDestination(destination)
|
||||
},
|
||||
icon = {
|
||||
Icon(
|
||||
|
Reference in New Issue
Block a user