mirror of
https://github.com/AdrianKuta/android-challange-adrian-kuta.git
synced 2025-07-02 05:47:59 +02:00
feat: Add passenger counter to home screen
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 is contained in:
@ -2,8 +2,8 @@ package dev.adriankuta.flights.ui.designsystem.theme
|
||||
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
||||
@Preview(name = "phone", device = "spec:shape=Normal,width=360,height=640,unit=dp,dpi=480")
|
||||
@Preview(name = "landscape", device = "spec:shape=Normal,width=640,height=360,unit=dp,dpi=480")
|
||||
@Preview(name = "foldable", device = "spec:shape=Normal,width=673,height=841,unit=dp,dpi=480")
|
||||
@Preview(name = "tablet", device = "spec:shape=Normal,width=1280,height=800,unit=dp,dpi=480")
|
||||
@Preview(name = "phone", device = "spec:shape=Normal,width=360,height=640,unit=dp,dpi=480", showBackground = true)
|
||||
@Preview(name = "landscape", device = "spec:shape=Normal,width=640,height=360,unit=dp,dpi=480", showBackground = true)
|
||||
@Preview(name = "foldable", device = "spec:shape=Normal,width=673,height=841,unit=dp,dpi=480", showBackground = true)
|
||||
@Preview(name = "tablet", device = "spec:shape=Normal,width=1280,height=800,unit=dp,dpi=480", showBackground = true)
|
||||
annotation class PreviewDevices
|
||||
|
Reference in New Issue
Block a user