@@ -3,12 +3,13 @@ package com.yapp.ndgl.feature.travel.datepicker
33import androidx.compose.foundation.background
44import androidx.compose.foundation.layout.Box
55import androidx.compose.foundation.layout.Column
6- import androidx.compose.foundation.layout.PaddingValues
76import androidx.compose.foundation.layout.Spacer
87import androidx.compose.foundation.layout.fillMaxSize
98import androidx.compose.foundation.layout.fillMaxWidth
109import androidx.compose.foundation.layout.height
1110import androidx.compose.foundation.layout.padding
11+ import androidx.compose.foundation.layout.statusBarsPadding
12+ import androidx.compose.material3.Scaffold
1213import androidx.compose.material3.Text
1314import androidx.compose.runtime.Composable
1415import androidx.compose.runtime.getValue
@@ -31,7 +32,6 @@ import kotlinx.datetime.LocalDate
3132internal fun DatePickerRoute (
3233 viewModel : DatePickerViewModel = hiltViewModel(),
3334 navigateBack : () -> Unit = {},
34- innerPadding : PaddingValues = PaddingValues (),
3535) {
3636 val state by viewModel.collectAsState()
3737
@@ -68,7 +68,6 @@ internal fun DatePickerRoute(
6868 clickBackButton = navigateBack,
6969 dismissDialog = ::dismissDialog,
7070 clickTravelButton = ::clickTravelButton,
71- innerPadding = innerPadding,
7271 )
7372
7473 viewModel.collectSideEffect { sideEffect ->
@@ -90,78 +89,84 @@ private fun DatePickerScreen(
9089 clickBackButton : () -> Unit ,
9190 dismissDialog : () -> Unit ,
9291 clickTravelButton : () -> Unit ,
93- innerPadding : PaddingValues ,
9492) {
95- Box (
96- modifier = Modifier
97- .fillMaxSize()
98- .background(NDGLTheme .colors.white)
99- .padding(innerPadding),
100- ) {
101- Column (
102- modifier = Modifier
103- .fillMaxSize()
104- .padding(bottom = 16 .dp),
105- ) {
93+ Scaffold (
94+ modifier = Modifier .fillMaxSize(),
95+ topBar = {
10696 NDGLNavigationBar (
107- modifier = Modifier .fillMaxWidth(),
97+ modifier = Modifier
98+ .fillMaxWidth()
99+ .statusBarsPadding(),
108100 headline = stringResource(R .string.date_picker_title),
109101 textAlignType = NDGLNavigationBarAttr .TextAlignType .CENTER ,
110102 leadingIcon = R .drawable.ic_28_chevron_left,
111103 onLeadingIconClick = clickBackButton,
112104 )
113- Spacer (Modifier .height(24 .dp))
105+ },
106+ ) { innerPadding ->
107+ Box (
108+ modifier = Modifier
109+ .fillMaxSize()
110+ .background(NDGLTheme .colors.white)
111+ .padding(innerPadding),
112+ ) {
114113 Column (
115114 modifier = Modifier
116115 .fillMaxSize()
117- .padding(horizontal = 24 .dp),
116+ .padding(top = 24 .dp, bottom = 16 .dp),
118117 ) {
119- CalendarView (
120- year = state.currentYear,
121- month = state.currentMonth,
122- startDate = state.startDate,
123- endDate = state.endDate,
124- onDateSelected = selectDate,
125- onPreviousMonth = selectPreviousMonth,
126- onNextMonth = selectNextMonth,
127- )
118+ Column (
119+ modifier = Modifier
120+ .fillMaxSize()
121+ .padding(horizontal = 24 .dp),
122+ ) {
123+ CalendarView (
124+ year = state.currentYear,
125+ month = state.currentMonth,
126+ startDate = state.startDate,
127+ endDate = state.endDate,
128+ onDateSelected = selectDate,
129+ onPreviousMonth = selectPreviousMonth,
130+ onNextMonth = selectNextMonth,
131+ )
128132
129- if (state.isInsufficientDuration) {
130- Spacer (Modifier .height(24 .dp))
131- Text (
132- stringResource(
133- R .string.date_picker_error_insufficient,
134- ),
135- color = NDGLTheme .colors.red500,
136- style = NDGLTheme .typography.bodySmMedium,
133+ if (state.isInsufficientDuration) {
134+ Spacer (Modifier .height(24 .dp))
135+ Text (
136+ stringResource(
137+ R .string.date_picker_error_insufficient,
138+ ),
139+ color = NDGLTheme .colors.red500,
140+ style = NDGLTheme .typography.bodySmMedium,
141+ )
142+ }
143+ Spacer (Modifier .weight(1f ))
144+ NDGLCTAButton (
145+ modifier = Modifier
146+ .fillMaxWidth(),
147+ type = NDGLCTAButtonAttr .Type .PRIMARY ,
148+ size = NDGLCTAButtonAttr .Size .LARGE ,
149+ status = if (state.isDateSelected) {
150+ NDGLCTAButtonAttr .Status .ACTIVE
151+ } else {
152+ NDGLCTAButtonAttr .Status .DISABLED
153+ },
154+ label = stringResource(R .string.date_picker_complete),
155+ onClick = clickCompleteButton,
137156 )
138157 }
139- Spacer (Modifier .weight(1f ))
140- NDGLCTAButton (
141- modifier = Modifier
142- .fillMaxWidth(),
143- type = NDGLCTAButtonAttr .Type .PRIMARY ,
144- size = NDGLCTAButtonAttr .Size .LARGE ,
145- status = if (state.isDateSelected) {
146- NDGLCTAButtonAttr .Status .ACTIVE
147- } else {
148- NDGLCTAButtonAttr .Status .DISABLED
149- },
150- label = stringResource(R .string.date_picker_complete),
151- onClick = clickCompleteButton,
152- )
153158 }
154- }
155159
156- if (state.showDialog) {
157- NDGLModal (
158- onDismissRequest = dismissDialog,
159- title = stringResource(R .string.date_picker_modal_title),
160- body = stringResource(R .string.date_picker_modal_body),
161- negativeButtonText = stringResource(R .string.date_picker_modal_negative),
162- positiveButtonText = stringResource(R .string.date_picker_modal_positive),
163- onPositiveButtonClick = clickTravelButton,
164- )
160+ if (state.showDialog) {
161+ NDGLModal (
162+ onDismissRequest = dismissDialog,
163+ title = stringResource(R .string.date_picker_modal_title),
164+ body = stringResource(R .string.date_picker_modal_body),
165+ negativeButtonText = stringResource(R .string.date_picker_modal_negative),
166+ positiveButtonText = stringResource(R .string.date_picker_modal_positive),
167+ onPositiveButtonClick = clickTravelButton,
168+ )
169+ }
165170 }
166171 }
167172}
@@ -181,7 +186,6 @@ private fun DatePickerScreenPreview() {
181186 clickBackButton = {},
182187 dismissDialog = {},
183188 clickTravelButton = {},
184- innerPadding = PaddingValues (),
185189 )
186190 }
187191}
@@ -206,7 +210,6 @@ private fun DatePickerScreenWithDialogPreview() {
206210 clickBackButton = {},
207211 dismissDialog = {},
208212 clickTravelButton = {},
209- innerPadding = PaddingValues (),
210213 )
211214 }
212215}
0 commit comments