@@ -20,6 +20,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
20
20
import feature.home.R
21
21
import kotlinx.coroutines.flow.first
22
22
import kotlinx.coroutines.launch
23
+ import java.time.LocalTime
23
24
import javax.inject.Inject
24
25
25
26
@HiltViewModel
@@ -57,9 +58,23 @@ class AlarmAddEditViewModel @Inject constructor(
57
58
58
59
alarmUseCase.initializeSoundPlayer(defaultSound.uri)
59
60
61
+ val now = LocalTime .now()
62
+ val initialAmPm = if (now.hour < 12 ) " 오전" else " 오후"
63
+ val initialHour = if (now.hour == 0 || now.hour == 12 ) 12 else now.hour % 12
64
+ val initialMinute = now.minute
65
+
60
66
updateState {
61
67
copy(
62
68
initialLoading = false ,
69
+ timeState = timeState.copy(
70
+ initialAmPm = initialAmPm,
71
+ initialHour = " $initialHour " ,
72
+ initialMinute = initialMinute.toString().padStart(2 , ' 0' ),
73
+ currentAmPm = initialAmPm,
74
+ currentHour = initialHour,
75
+ currentMinute = initialMinute,
76
+ alarmMessage = getAlarmMessage(initialAmPm, initialHour, initialMinute, emptySet()),
77
+ ),
63
78
soundState = soundState.copy(sounds = sounds, soundIndex = defaultSoundIndex),
64
79
)
65
80
}
0 commit comments