Skip to content

Commit 669a282

Browse files
authored
Publish v1.0.2
2 parents 223f76a + fd581da commit 669a282

File tree

12 files changed

+143
-67
lines changed

12 files changed

+143
-67
lines changed

domain/src/main/java/com/comit/domain/exception/ThrowUnknownException.kt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.google.firebase.ktx.Firebase
88
*
99
* NoInterNetException, NoConnectivityException 등 모든 경우에 사용되는 Exception은 별도로 처리
1010
* Exception이 발생할 경우 Firebase Crashlytics에 제보합니다.
11-
*
1211
*/
1312
fun throwUnknownException(
1413
e: Throwable,
@@ -27,3 +26,28 @@ fun throwUnknownException(
2726
}
2827
}
2928
}
29+
30+
/**
31+
* 심통에서 예상 밖에 예외를 toast 방식으로 처리할 때 사용하는 함수
32+
*
33+
* NoInterNetException, NoConnectivityException 등 모든 경우에 사용되는 Exception은 별도로 처리
34+
* Exception이 발생할 경우 Firebase Crashlytics에 제보합니다.
35+
*/
36+
fun throwUnknownExceptionForToast(
37+
e: Throwable,
38+
throwErrorMessage: (String) -> Unit,
39+
) {
40+
// TODO(limsaehyun): 인터넷 에러가 UnknwonException으로 감지됨 해결 필요
41+
// TODO(limsaehyun): 임시로 message text 로 구분
42+
if (e.message?.contains("NoInternetException") == true) throw NoInternetException()
43+
if (e.message?.contains("NoConnectivityException") == true) throw NoInternetException()
44+
45+
when (e) {
46+
is NoInternetException -> throw NoInternetException()
47+
is NoConnectivityException -> throw NoInternetException()
48+
else -> {
49+
Firebase.crashlytics.recordException(e)
50+
throwErrorMessage(e.message ?: "알 수 없는 에러가 발생했습니다!")
51+
}
52+
}
53+
}

feature/feature-home/src/main/java/com/comit/feature_home/calendar/SimTongCalendar.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ enum class SimTongCalendarStatus(
8080
),
8181
}
8282

83+
private val CalendarLoadingHeight: Dp = 255.dp
8384
private const val Week: Int = 7
8485

8586
@Stable
@@ -216,14 +217,16 @@ fun SimTongCalendar(
216217
CircularProgressIndicator(
217218
color = SimTongColor.MainColor,
218219
modifier = Modifier
219-
.fillMaxSize()
220+
.fillMaxWidth()
221+
.height(CalendarLoadingHeight)
220222
.wrapContentSize(Alignment.Center),
221223
)
222224
} else {
223225
SimTongCalendarList(
224226
list = calendarList,
225227
onItemClicked = onItemClicked
226228
)
229+
Spacer(modifier = Modifier.height(40.dp))
227230
}
228231
}
229232
}
@@ -327,9 +330,7 @@ fun SimTongCalendarList(
327330
list: List<SimTongCalendarData>,
328331
onItemClicked: (Int, String) -> Unit = { _, _ -> },
329332
) {
330-
Column(
331-
modifier = Modifier.fillMaxSize()
332-
) {
333+
Column {
333334
repeat(list.size / Week) { size ->
334335
val rowList = list.subList(size * Week, size * Week + Week)
335336

feature/feature-home/src/main/java/com/comit/feature_home/mvi/CloseDayContract.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ sealed class CloseDaySideEffect {
1515

1616
object TokenException : CloseDaySideEffect()
1717

18-
object DayOffExcess : CloseDaySideEffect()
18+
object AlreadyHoliday : CloseDaySideEffect()
1919

20-
object AnnualDayChangeFail : CloseDaySideEffect()
20+
object TooManyHoliday : CloseDaySideEffect()
21+
22+
object TooManyAnnualDay : CloseDaySideEffect()
23+
24+
object AlreadyAnnualDay : CloseDaySideEffect()
2125

2226
object AlreadyWork : CloseDaySideEffect()
27+
28+
object CannotChangeWorkState : CloseDaySideEffect()
2329
}

feature/feature-home/src/main/java/com/comit/feature_home/mvi/FetchScheduleContract.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ fun ScheduleList.Schedule.toStateSchedule() = FetchScheduleState.Schedule(
2828

2929
sealed class FetchScheduleSideEffect {
3030

31-
object FetchScheduleFail : FetchScheduleSideEffect()
31+
object DeleteScheduleDateError : FetchScheduleSideEffect()
32+
33+
object DeleteScheduleCannotFound : FetchScheduleSideEffect()
3234

3335
object DeleteScheduleSuccess : FetchScheduleSideEffect()
3436

35-
object DeleteScheduleFail : FetchScheduleSideEffect()
37+
object TokenError : FetchScheduleSideEffect()
3638
}

feature/feature-home/src/main/java/com/comit/feature_home/navigation/HomeNavigation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import androidx.navigation.navArgument
1010
import androidx.navigation.navigation
1111
import com.comit.feature_home.screen.HomeScreen
1212
import com.comit.feature_home.screen.SalaryWebViewScreen
13+
import com.comit.feature_home.screen.WriteClosedDayScreen
1314
import com.comit.feature_home.screen.alarm.AlarmScreen
1415
import com.comit.feature_home.screen.schedule.ShowScheduleScreen
1516
import com.comit.feature_home.screen.schedule.WriteScheduleScreen
16-
import com.comit.feature_home.vm.WriteClosedDayScreen
1717
import com.comit.navigator.SimTongScreen
1818

1919
fun NavGraphBuilder.homeNavigation(

feature/feature-home/src/main/java/com/comit/feature_home/screen/HomeScreen.kt

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@file:OptIn(ExperimentalMaterialApi::class, InternalCoroutinesApi::class,)
1+
@file:OptIn(ExperimentalMaterialApi::class, InternalCoroutinesApi::class)
22

33
package com.comit.feature_home.screen
44

@@ -28,13 +28,15 @@ import androidx.compose.ui.Modifier
2828
import androidx.compose.ui.graphics.painter.Painter
2929
import androidx.compose.ui.res.painterResource
3030
import androidx.compose.ui.res.stringResource
31+
import androidx.compose.ui.text.buildAnnotatedString
3132
import androidx.compose.ui.tooling.preview.Preview
3233
import androidx.compose.ui.unit.Dp
3334
import androidx.compose.ui.unit.dp
3435
import androidx.hilt.navigation.compose.hiltViewModel
3536
import androidx.navigation.NavController
3637
import androidx.navigation.compose.rememberNavController
3738
import com.comit.common.rememberToast
39+
import com.comit.common.utils.string
3840
import com.comit.core.observeWithLifecycle
3941
import com.comit.core_design_system.color.SimTongColor
4042
import com.comit.core_design_system.component.Header
@@ -57,8 +59,6 @@ private val HomeScreenPadding = PaddingValues(
5759
horizontal = 25.dp,
5860
)
5961

60-
private val HomeCalendarHeight: Dp = 343.dp
61-
6262
private const val StartDateAdd = -3
6363
private const val EndDateAdd = 3
6464

@@ -84,23 +84,35 @@ fun HomeScreen(
8484
today.get(Calendar.MONTH),
8585
today.get(Calendar.DATE) + StartDateAdd
8686
)
87-
val startYear = startAt.get(Calendar.YEAR).toString()
88-
val startMonth = (startAt.get(Calendar.MONTH) + 1).toString()
89-
val startDay = startAt.get(Calendar.DATE).toString()
87+
val startYear = startAt.get(Calendar.YEAR)
88+
val startMonth = (startAt.get(Calendar.MONTH) + 1)
89+
val startDay = startAt.get(Calendar.DATE)
9090

9191
val endAt = GregorianCalendar(
9292
today.get(Calendar.YEAR),
9393
today.get(Calendar.MONTH),
9494
today.get(Calendar.DATE) + EndDateAdd
9595
)
96-
val endYear = endAt.get(Calendar.YEAR).toString()
97-
val endMonth = (endAt.get(Calendar.MONTH) + 1).toString()
98-
val endDay = endAt.get(Calendar.DATE).toString()
96+
val endYear = endAt.get(Calendar.YEAR)
97+
val endMonth = (endAt.get(Calendar.MONTH) + 1)
98+
val endDay = endAt.get(Calendar.DATE)
9999

100100
LaunchedEffect(key1 = homeViewModel) {
101101
homeViewModel.fetchMenu(
102-
startAt = "$startYear-$startMonth-$startDay",
103-
endAt = "$endYear-$endMonth-$endDay",
102+
startAt = buildAnnotatedString {
103+
append(startYear.toString())
104+
append("-")
105+
append(string.format("%02d", startMonth))
106+
append("-")
107+
append(string.format("%02d", startDay))
108+
}.toString(),
109+
endAt = buildAnnotatedString {
110+
append(endYear.toString())
111+
append("-")
112+
append(string.format("%02d", endMonth))
113+
append("-")
114+
append(string.format("%02d", endDay))
115+
}.toString()
104116
)
105117
}
106118

@@ -163,7 +175,6 @@ fun HomeScreen(
163175
SimTongCalendar(
164176
modifier = Modifier
165177
.fillMaxWidth()
166-
.height(HomeCalendarHeight)
167178
.simClickable(
168179
rippleEnabled = false,
169180
) {

feature/feature-home/src/main/java/com/comit/feature_home/vm/WriteClosedDayScreen.kt renamed to feature/feature-home/src/main/java/com/comit/feature_home/screen/WriteClosedDayScreen.kt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
)
55
@file:Suppress("OPT_IN_IS_NOT_ENABLED")
66

7-
package com.comit.feature_home.vm
7+
package com.comit.feature_home.screen
88

99
import androidx.compose.foundation.background
1010
import androidx.compose.foundation.layout.Box
@@ -62,6 +62,7 @@ import com.comit.feature_home.calendar.SimTongCalendar
6262
import com.comit.feature_home.calendar.SimTongCalendarStatus
6363
import com.comit.feature_home.mvi.CloseDaySideEffect
6464
import com.comit.feature_home.string
65+
import com.comit.feature_home.vm.CloseDayViewModel
6566
import com.example.feature_home.R
6667
import kotlinx.coroutines.InternalCoroutinesApi
6768
import kotlinx.coroutines.launch
@@ -78,8 +79,12 @@ private val CalendarPadding = PaddingValues(
7879

7980
private const val DateInputWrongMessage = "잘못된 날짜 입력입니다"
8081
private const val TokenExceptionMessage = "토큰 만료. 다시 로그인해주세요"
81-
private const val DayOffExcessMessage = "일주일에 휴무일은 최대 2회입니다"
82+
private const val AlreadyHoliday = "이미 휴무일입니다"
83+
private const val TooManyHoliday = "휴무일은 일주일에 2번만 가능합니다"
84+
private const val AlreadyAnnualDay = "이미 연차입니다"
85+
private const val TooManyAnnualDay = "연차 개수가 부족합니다"
8286
private const val AlreadyWorkMessage = "이미 근무일입니다"
87+
private const val CannotChangeWorkState = "더 이상 변경할 수 없는 일정입니다"
8388

8489
@Composable
8590
fun WriteClosedDayScreen(
@@ -122,15 +127,24 @@ fun WriteClosedDayScreen(
122127
CloseDaySideEffect.TokenException -> {
123128
toast(message = TokenExceptionMessage)
124129
}
125-
CloseDaySideEffect.DayOffExcess -> {
126-
toast(message = DayOffExcessMessage)
130+
CloseDaySideEffect.AlreadyHoliday -> {
131+
toast(message = AlreadyHoliday)
127132
}
128-
CloseDaySideEffect.AnnualDayChangeFail -> {
129-
toast(message = "서비스 준비중입니다")
133+
CloseDaySideEffect.TooManyHoliday -> {
134+
toast(message = TooManyHoliday)
135+
}
136+
CloseDaySideEffect.AlreadyAnnualDay -> {
137+
toast(message = AlreadyAnnualDay)
138+
}
139+
CloseDaySideEffect.TooManyAnnualDay -> {
140+
toast(message = TooManyAnnualDay)
130141
}
131142
CloseDaySideEffect.AlreadyWork -> {
132143
toast(message = AlreadyWorkMessage)
133144
}
145+
CloseDaySideEffect.CannotChangeWorkState -> {
146+
toast(message = CannotChangeWorkState)
147+
}
134148
}
135149
}
136150

feature/feature-home/src/main/java/com/comit/feature_home/screen/schedule/ShowScheduleScreen.kt

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import androidx.compose.ui.Modifier
3636
import androidx.compose.ui.geometry.Offset
3737
import androidx.compose.ui.res.painterResource
3838
import androidx.compose.ui.res.stringResource
39-
import androidx.compose.ui.unit.Dp
4039
import androidx.compose.ui.unit.dp
4140
import androidx.hilt.navigation.compose.hiltViewModel
4241
import androidx.navigation.NavController
@@ -69,16 +68,12 @@ import kotlinx.coroutines.InternalCoroutinesApi
6968
import kotlinx.coroutines.launch
7069
import java.time.LocalDate
7170
import java.time.format.DateTimeFormatter
72-
import java.util.Calendar
73-
import java.util.GregorianCalendar
7471
import java.util.UUID
7572

7673
private val HorizontalPadding = PaddingValues(
7774
horizontal = 30.dp,
7875
)
7976

80-
private val HomeCalendarHeight: Dp = 343.dp
81-
8277
private val CalendarPadding = PaddingValues(
8378
horizontal = 20.dp,
8479
)
@@ -95,25 +90,8 @@ fun ShowScheduleScreen(
9590
val showScheduleState = showScheduleContainer.stateFlow.collectAsState().value
9691
val showScheduleSideEffect = showScheduleContainer.sideEffectFlow
9792

98-
val today = GregorianCalendar()
99-
val calendar = GregorianCalendar(
100-
today.get(Calendar.YEAR),
101-
today.get(Calendar.MONTH),
102-
today.get(Calendar.DATE)
103-
)
10493
var checkMonth by remember { mutableStateOf(0) }
10594

106-
// var date by remember {
107-
// mutableStateOf<Date>(
108-
// Date.valueOf(
109-
// string.format("%02d", calendar.get(Calendar.YEAR)) +
110-
// "-" +
111-
// string.format("%02d", calendar.get(Calendar.MONTH) + 1) +
112-
// "-01"
113-
// )
114-
// )
115-
// }
116-
11795
LaunchedEffect(showScheduleViewModel) {
11896
showScheduleViewModel.showSchedule(
11997
startAt = getStartAt(checkMonth),
@@ -133,9 +111,6 @@ fun ShowScheduleScreen(
133111

134112
showScheduleSideEffect.observeWithLifecycle() {
135113
when (it) {
136-
FetchScheduleSideEffect.FetchScheduleFail -> {
137-
toast(message = "일정을 불러오는데 실패했습니다.")
138-
}
139114
FetchScheduleSideEffect.DeleteScheduleSuccess -> {
140115
coroutineScope.launch {
141116
bottomSheetState.hide()
@@ -145,8 +120,14 @@ fun ShowScheduleScreen(
145120
endAt = getEndAt(checkMonth)
146121
)
147122
}
148-
FetchScheduleSideEffect.DeleteScheduleFail -> {
149-
toast(message = "일정 삭제를 실패했습니다.")
123+
FetchScheduleSideEffect.DeleteScheduleDateError -> {
124+
toast(message = "삭제할 일정을 찾지 못했습니다")
125+
}
126+
FetchScheduleSideEffect.DeleteScheduleCannotFound -> {
127+
toast(message = "일정이 존재하지 않습니다")
128+
}
129+
FetchScheduleSideEffect.TokenError -> {
130+
toast(message = "토큰 만료. 다시 로그인해주세요")
150131
}
151132
}
152133
}
@@ -259,6 +240,9 @@ fun ShowScheduleScreen(
259240
Spacer(modifier = Modifier.height(20.dp))
260241

261242
SimTongCalendar(
243+
modifier = Modifier
244+
.fillMaxWidth()
245+
.padding(CalendarPadding),
262246
onBeforeClicked = { _, _checkMonth ->
263247
checkMonth = _checkMonth
264248
showScheduleViewModel.showSchedule(
@@ -273,10 +257,6 @@ fun ShowScheduleScreen(
273257
endAt = getEndAt(checkMonth)
274258
)
275259
},
276-
modifier = Modifier
277-
.fillMaxWidth()
278-
.height(HomeCalendarHeight)
279-
.padding(CalendarPadding),
280260
)
281261

282262
Spacer(modifier = Modifier.height(7.dp))

0 commit comments

Comments
 (0)