File tree Expand file tree Collapse file tree
data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/dto
domain/src/main/java/com/threegap/bitnagil/domain/writeroutine
src/main/java/com/threegap/bitnagil/presentation/writeroutine Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,16 +21,25 @@ data class RoutineDto(
2121 val subRoutineInfos : List <SubRoutineDto >,
2222) {
2323 fun toRoutine (): Routine {
24+ val dividedTimeStrings = executionTime.split(" :" )
25+ require(dividedTimeStrings.size >= 2 ) { " Invalid time format: $executionTime Expected format: HH:mm / HH:mm:ss" }
26+
2427 val startTime = Time (
25- hour = executionTime.split( " : " ) [0 ].toInt( ),
26- minute = executionTime.split( " : " ) [1 ].toInt( ),
28+ hour = dividedTimeStrings[ 0 ].toIntOrNull() ? : throw IllegalArgumentException ( " Invalid hour: ${dividedTimeStrings [0 ]} " ),
29+ minute = dividedTimeStrings[ 1 ].toIntOrNull() ? : throw IllegalArgumentException ( " Invalid minute: ${dividedTimeStrings [1 ]} " ),
2730 )
2831
2932 return Routine (
3033 id = routineId,
3134 name = routineName,
3235 subRoutines = subRoutineInfos.map { it.toSubRoutine() },
33- repeatDays = repeatDay.map { RepeatDay .valueOf(it) },
36+ repeatDays = repeatDay.mapNotNull {
37+ try {
38+ RepeatDay .valueOf(it)
39+ } catch (e: IllegalArgumentException ) {
40+ null
41+ }
42+ },
3443 startTime = startTime,
3544 endDate = Date (
3645 year = 2099 ,
Original file line number Diff line number Diff line change @@ -4,4 +4,10 @@ data class Date(
44 val year : Int ,
55 val month : Int ,
66 val day : Int ,
7- )
7+ ) {
8+ init {
9+ require(year in 1970 .. 2099 ) { " Year must be in range 1970..2099, but was $year " }
10+ require(month in 1 .. 12 ) { " Month must be in range 1..12, but was $month " }
11+ require(day in 1 .. 31 ) { " Day must be in range 1..31, but was $day " }
12+ }
13+ }
Original file line number Diff line number Diff line change @@ -3,4 +3,13 @@ package com.threegap.bitnagil.domain.writeroutine.model
33data class Time (
44 val hour : Int ,
55 val minute : Int ,
6- )
6+ ) {
7+ init {
8+ require(hour in 0 .. 23 ) { " Hour must be in range 0..23, but was $hour " }
9+ require(minute in 0 .. 59 ) { " Minute must be in range 0..59, but was $minute " }
10+ }
11+
12+ override fun toString (): String {
13+ return " %02d:%02d" .format(hour, minute)
14+ }
15+ }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import com.threegap.bitnagil.domain.writeroutine.model.Time
66import com.threegap.bitnagil.domain.writeroutine.repository.WriteRoutineRepository
77import javax.inject.Inject
88
9- class EditRoutineUseCse @Inject constructor(
9+ class EditRoutineUseCase @Inject constructor(
1010 private val writeRoutineRepository : WriteRoutineRepository ,
1111) {
1212 suspend operator fun invoke (
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ dependencies {
1717 implementation(libs.bundles.androidx.core)
1818 implementation(libs.bundles.orbit)
1919 implementation(libs.kakao.v2.user)
20+ implementation(libs.kotlinx.serialization.json)
2021
2122 testImplementation(libs.junit)
2223 testImplementation(libs.kotlin.coroutines.test)
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ import com.threegap.bitnagil.presentation.writeroutine.component.atom.strokebutt
3434import com.threegap.bitnagil.presentation.writeroutine.component.atom.textbutton.TextButton
3535import com.threegap.bitnagil.presentation.writeroutine.component.atom.tooltipbutton.TooltipButton
3636import com.threegap.bitnagil.presentation.writeroutine.component.block.labeledcheckbox.LabeledCheckBox
37- import com.threegap.bitnagil.presentation.writeroutine.component.template.TImePickerBottomSheet
37+ import com.threegap.bitnagil.presentation.writeroutine.component.template.TimePickerBottomSheet
3838import com.threegap.bitnagil.presentation.writeroutine.model.Day
3939import com.threegap.bitnagil.presentation.writeroutine.model.RepeatType
4040import com.threegap.bitnagil.presentation.writeroutine.model.SelectableDay
@@ -59,7 +59,7 @@ fun WriteRoutineScreenContainer(
5959 }
6060
6161 if (state.showTimePickerBottomSheet) {
62- TImePickerBottomSheet (
62+ TimePickerBottomSheet (
6363 modifier = Modifier .fillMaxWidth(),
6464 onTimeSelected = viewModel::setStartTime,
6565 hour = state.startTime?.hour ? : Time .Init .hour,
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package com.threegap.bitnagil.presentation.writeroutine
33import androidx.lifecycle.SavedStateHandle
44import androidx.lifecycle.viewModelScope
55import androidx.navigation.toRoute
6- import com.threegap.bitnagil.domain.writeroutine.usecase.EditRoutineUseCse
6+ import com.threegap.bitnagil.domain.writeroutine.usecase.EditRoutineUseCase
77import com.threegap.bitnagil.domain.writeroutine.usecase.GetChangedSubRoutinesUseCase
88import com.threegap.bitnagil.domain.writeroutine.usecase.GetRoutineUseCase
99import com.threegap.bitnagil.domain.writeroutine.usecase.RegisterRoutineUseCase
@@ -29,7 +29,7 @@ class WriteRoutineViewModel @Inject constructor(
2929 savedStateHandle : SavedStateHandle ,
3030 private val getChangedSubRoutinesUseCase : GetChangedSubRoutinesUseCase ,
3131 private val registerRoutineUseCase : RegisterRoutineUseCase ,
32- private val editRoutineUseCase : EditRoutineUseCse ,
32+ private val editRoutineUseCase : EditRoutineUseCase ,
3333 private val getRoutineUseCase : GetRoutineUseCase ,
3434) : MviViewModel<WriteRoutineState, WriteRoutineSideEffect, WriteRoutineIntent>(
3535 initState = WriteRoutineState .Init ,
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ import androidx.compose.material3.Text
1717import androidx.compose.runtime.Composable
1818import androidx.compose.ui.Alignment
1919import androidx.compose.ui.Modifier
20- import androidx.compose.ui.graphics.Color
2120import androidx.compose.ui.unit.dp
2221import com.threegap.bitnagil.designsystem.BitnagilTheme
2322
@@ -60,8 +59,8 @@ fun NameField(
6059 ) {
6160 Icon (
6261 imageVector = Icons .Default .Close ,
63- contentDescription = " 텍스트 전체 삭제 " ,
64- tint = Color . Gray ,
62+ contentDescription = " 제거 " ,
63+ tint = BitnagilTheme .colors.coolGray80 ,
6564 )
6665 }
6766 }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import kotlinx.coroutines.launch
2525
2626@OptIn(ExperimentalMaterial3Api ::class )
2727@Composable
28- fun TImePickerBottomSheet (
28+ fun TimePickerBottomSheet (
2929 modifier : Modifier = Modifier ,
3030 onTimeSelected : (Int , Int ) -> Unit ,
3131 hour : Int ,
Original file line number Diff line number Diff line change 11package com.threegap.bitnagil.presentation.writeroutine.model
22
3- enum class RepeatType {
3+ import android.os.Parcelable
4+ import kotlinx.parcelize.Parcelize
5+
6+ @Parcelize
7+ enum class RepeatType : Parcelable {
48 DAILY , DAY
59}
You can’t perform that action at this time.
0 commit comments