From 36a53cfbb944eed4342bafa6b89d65c772c09366 Mon Sep 17 00:00:00 2001 From: TaejungKim Date: Sun, 19 Jan 2025 02:28:19 +0900 Subject: [PATCH] =?UTF-8?q?[refactor/#21]=20timepicker=200~59=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/memento/ui/MementoTimePicker.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/memento/ui/MementoTimePicker.kt b/app/src/main/java/org/memento/ui/MementoTimePicker.kt index 889b5f4..cfd06ab 100644 --- a/app/src/main/java/org/memento/ui/MementoTimePicker.kt +++ b/app/src/main/java/org/memento/ui/MementoTimePicker.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -15,6 +16,7 @@ import androidx.compose.ui.unit.dp import com.sd.lib.compose.wheel_picker.FVerticalWheelPicker import com.sd.lib.compose.wheel_picker.FWheelPickerFocusVertical import com.sd.lib.compose.wheel_picker.rememberFWheelPickerState +import kotlinx.coroutines.delay import org.memento.ui.theme.MementoTheme import org.memento.ui.theme.darkModeColors @@ -27,28 +29,27 @@ fun MementoTimePicker( val minuteState = rememberFWheelPickerState(initialIndex = 0) val periodState = rememberFWheelPickerState(initialIndex = 0) - val minuteValues = listOf(0, 30) val periods = listOf("AM", "PM") fun getFormattedTime(): String { val hour = hourState.currentIndex - val minuteIndex = minuteState.currentIndex.takeIf { it in minuteValues.indices } ?: 0 + val minute = minuteState.currentIndex val periodIndex = periodState.currentIndex.takeIf { it in periods.indices } ?: 0 - - val minute = minuteValues[minuteIndex] val period = periods[periodIndex] return "${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')} $period" } LaunchedEffect(hourState.currentIndex, minuteState.currentIndex, periodState.currentIndex) { + delay(100) onTimeSelected(getFormattedTime()) } Row( modifier = Modifier - .fillMaxWidth(), + .fillMaxWidth() + .padding(horizontal = 30.dp), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically, ) { @@ -76,7 +77,7 @@ fun MementoTimePicker( FVerticalWheelPicker( modifier = Modifier.weight(1f), - count = minuteValues.size, + count = 60, state = minuteState, focus = { FWheelPickerFocusVertical( @@ -86,7 +87,7 @@ fun MementoTimePicker( }, ) { index -> Text( - text = minuteValues[index].toString().padStart(2, '0'), + text = index.toString().padStart(2, '0'), style = MementoTheme.typography.body_b_18.copy( color = darkModeColors.white,