Skip to content

Commit

Permalink
Publish v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
limsaehyun authored Dec 29, 2022
2 parents 223f76a + fd581da commit 669a282
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.google.firebase.ktx.Firebase
*
* NoInterNetException, NoConnectivityException 등 모든 경우에 사용되는 Exception은 별도로 처리
* Exception이 발생할 경우 Firebase Crashlytics에 제보합니다.
*
*/
fun throwUnknownException(
e: Throwable,
Expand All @@ -27,3 +26,28 @@ fun throwUnknownException(
}
}
}

/**
* 심통에서 예상 밖에 예외를 toast 방식으로 처리할 때 사용하는 함수
*
* NoInterNetException, NoConnectivityException 등 모든 경우에 사용되는 Exception은 별도로 처리
* Exception이 발생할 경우 Firebase Crashlytics에 제보합니다.
*/
fun throwUnknownExceptionForToast(
e: Throwable,
throwErrorMessage: (String) -> Unit,
) {
// TODO(limsaehyun): 인터넷 에러가 UnknwonException으로 감지됨 해결 필요
// TODO(limsaehyun): 임시로 message text 로 구분
if (e.message?.contains("NoInternetException") == true) throw NoInternetException()
if (e.message?.contains("NoConnectivityException") == true) throw NoInternetException()

when (e) {
is NoInternetException -> throw NoInternetException()
is NoConnectivityException -> throw NoInternetException()
else -> {
Firebase.crashlytics.recordException(e)
throwErrorMessage(e.message ?: "알 수 없는 에러가 발생했습니다!")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ enum class SimTongCalendarStatus(
),
}

private val CalendarLoadingHeight: Dp = 255.dp
private const val Week: Int = 7

@Stable
Expand Down Expand Up @@ -216,14 +217,16 @@ fun SimTongCalendar(
CircularProgressIndicator(
color = SimTongColor.MainColor,
modifier = Modifier
.fillMaxSize()
.fillMaxWidth()
.height(CalendarLoadingHeight)
.wrapContentSize(Alignment.Center),
)
} else {
SimTongCalendarList(
list = calendarList,
onItemClicked = onItemClicked
)
Spacer(modifier = Modifier.height(40.dp))
}
}
}
Expand Down Expand Up @@ -327,9 +330,7 @@ fun SimTongCalendarList(
list: List<SimTongCalendarData>,
onItemClicked: (Int, String) -> Unit = { _, _ -> },
) {
Column(
modifier = Modifier.fillMaxSize()
) {
Column {
repeat(list.size / Week) { size ->
val rowList = list.subList(size * Week, size * Week + Week)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ sealed class CloseDaySideEffect {

object TokenException : CloseDaySideEffect()

object DayOffExcess : CloseDaySideEffect()
object AlreadyHoliday : CloseDaySideEffect()

object AnnualDayChangeFail : CloseDaySideEffect()
object TooManyHoliday : CloseDaySideEffect()

object TooManyAnnualDay : CloseDaySideEffect()

object AlreadyAnnualDay : CloseDaySideEffect()

object AlreadyWork : CloseDaySideEffect()

object CannotChangeWorkState : CloseDaySideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ fun ScheduleList.Schedule.toStateSchedule() = FetchScheduleState.Schedule(

sealed class FetchScheduleSideEffect {

object FetchScheduleFail : FetchScheduleSideEffect()
object DeleteScheduleDateError : FetchScheduleSideEffect()

object DeleteScheduleCannotFound : FetchScheduleSideEffect()

object DeleteScheduleSuccess : FetchScheduleSideEffect()

object DeleteScheduleFail : FetchScheduleSideEffect()
object TokenError : FetchScheduleSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import androidx.navigation.navArgument
import androidx.navigation.navigation
import com.comit.feature_home.screen.HomeScreen
import com.comit.feature_home.screen.SalaryWebViewScreen
import com.comit.feature_home.screen.WriteClosedDayScreen
import com.comit.feature_home.screen.alarm.AlarmScreen
import com.comit.feature_home.screen.schedule.ShowScheduleScreen
import com.comit.feature_home.screen.schedule.WriteScheduleScreen
import com.comit.feature_home.vm.WriteClosedDayScreen
import com.comit.navigator.SimTongScreen

fun NavGraphBuilder.homeNavigation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:OptIn(ExperimentalMaterialApi::class, InternalCoroutinesApi::class,)
@file:OptIn(ExperimentalMaterialApi::class, InternalCoroutinesApi::class)

package com.comit.feature_home.screen

Expand Down Expand Up @@ -28,13 +28,15 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.comit.common.rememberToast
import com.comit.common.utils.string
import com.comit.core.observeWithLifecycle
import com.comit.core_design_system.color.SimTongColor
import com.comit.core_design_system.component.Header
Expand All @@ -57,8 +59,6 @@ private val HomeScreenPadding = PaddingValues(
horizontal = 25.dp,
)

private val HomeCalendarHeight: Dp = 343.dp

private const val StartDateAdd = -3
private const val EndDateAdd = 3

Expand All @@ -84,23 +84,35 @@ fun HomeScreen(
today.get(Calendar.MONTH),
today.get(Calendar.DATE) + StartDateAdd
)
val startYear = startAt.get(Calendar.YEAR).toString()
val startMonth = (startAt.get(Calendar.MONTH) + 1).toString()
val startDay = startAt.get(Calendar.DATE).toString()
val startYear = startAt.get(Calendar.YEAR)
val startMonth = (startAt.get(Calendar.MONTH) + 1)
val startDay = startAt.get(Calendar.DATE)

val endAt = GregorianCalendar(
today.get(Calendar.YEAR),
today.get(Calendar.MONTH),
today.get(Calendar.DATE) + EndDateAdd
)
val endYear = endAt.get(Calendar.YEAR).toString()
val endMonth = (endAt.get(Calendar.MONTH) + 1).toString()
val endDay = endAt.get(Calendar.DATE).toString()
val endYear = endAt.get(Calendar.YEAR)
val endMonth = (endAt.get(Calendar.MONTH) + 1)
val endDay = endAt.get(Calendar.DATE)

LaunchedEffect(key1 = homeViewModel) {
homeViewModel.fetchMenu(
startAt = "$startYear-$startMonth-$startDay",
endAt = "$endYear-$endMonth-$endDay",
startAt = buildAnnotatedString {
append(startYear.toString())
append("-")
append(string.format("%02d", startMonth))
append("-")
append(string.format("%02d", startDay))
}.toString(),
endAt = buildAnnotatedString {
append(endYear.toString())
append("-")
append(string.format("%02d", endMonth))
append("-")
append(string.format("%02d", endDay))
}.toString()
)
}

Expand Down Expand Up @@ -163,7 +175,6 @@ fun HomeScreen(
SimTongCalendar(
modifier = Modifier
.fillMaxWidth()
.height(HomeCalendarHeight)
.simClickable(
rippleEnabled = false,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)
@file:Suppress("OPT_IN_IS_NOT_ENABLED")

package com.comit.feature_home.vm
package com.comit.feature_home.screen

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -62,6 +62,7 @@ import com.comit.feature_home.calendar.SimTongCalendar
import com.comit.feature_home.calendar.SimTongCalendarStatus
import com.comit.feature_home.mvi.CloseDaySideEffect
import com.comit.feature_home.string
import com.comit.feature_home.vm.CloseDayViewModel
import com.example.feature_home.R
import kotlinx.coroutines.InternalCoroutinesApi
import kotlinx.coroutines.launch
Expand All @@ -78,8 +79,12 @@ private val CalendarPadding = PaddingValues(

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

@Composable
fun WriteClosedDayScreen(
Expand Down Expand Up @@ -122,15 +127,24 @@ fun WriteClosedDayScreen(
CloseDaySideEffect.TokenException -> {
toast(message = TokenExceptionMessage)
}
CloseDaySideEffect.DayOffExcess -> {
toast(message = DayOffExcessMessage)
CloseDaySideEffect.AlreadyHoliday -> {
toast(message = AlreadyHoliday)
}
CloseDaySideEffect.AnnualDayChangeFail -> {
toast(message = "서비스 준비중입니다")
CloseDaySideEffect.TooManyHoliday -> {
toast(message = TooManyHoliday)
}
CloseDaySideEffect.AlreadyAnnualDay -> {
toast(message = AlreadyAnnualDay)
}
CloseDaySideEffect.TooManyAnnualDay -> {
toast(message = TooManyAnnualDay)
}
CloseDaySideEffect.AlreadyWork -> {
toast(message = AlreadyWorkMessage)
}
CloseDaySideEffect.CannotChangeWorkState -> {
toast(message = CannotChangeWorkState)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
Expand Down Expand Up @@ -69,16 +68,12 @@ import kotlinx.coroutines.InternalCoroutinesApi
import kotlinx.coroutines.launch
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.util.Calendar
import java.util.GregorianCalendar
import java.util.UUID

private val HorizontalPadding = PaddingValues(
horizontal = 30.dp,
)

private val HomeCalendarHeight: Dp = 343.dp

private val CalendarPadding = PaddingValues(
horizontal = 20.dp,
)
Expand All @@ -95,25 +90,8 @@ fun ShowScheduleScreen(
val showScheduleState = showScheduleContainer.stateFlow.collectAsState().value
val showScheduleSideEffect = showScheduleContainer.sideEffectFlow

val today = GregorianCalendar()
val calendar = GregorianCalendar(
today.get(Calendar.YEAR),
today.get(Calendar.MONTH),
today.get(Calendar.DATE)
)
var checkMonth by remember { mutableStateOf(0) }

// var date by remember {
// mutableStateOf<Date>(
// Date.valueOf(
// string.format("%02d", calendar.get(Calendar.YEAR)) +
// "-" +
// string.format("%02d", calendar.get(Calendar.MONTH) + 1) +
// "-01"
// )
// )
// }

LaunchedEffect(showScheduleViewModel) {
showScheduleViewModel.showSchedule(
startAt = getStartAt(checkMonth),
Expand All @@ -133,9 +111,6 @@ fun ShowScheduleScreen(

showScheduleSideEffect.observeWithLifecycle() {
when (it) {
FetchScheduleSideEffect.FetchScheduleFail -> {
toast(message = "일정을 불러오는데 실패했습니다.")
}
FetchScheduleSideEffect.DeleteScheduleSuccess -> {
coroutineScope.launch {
bottomSheetState.hide()
Expand All @@ -145,8 +120,14 @@ fun ShowScheduleScreen(
endAt = getEndAt(checkMonth)
)
}
FetchScheduleSideEffect.DeleteScheduleFail -> {
toast(message = "일정 삭제를 실패했습니다.")
FetchScheduleSideEffect.DeleteScheduleDateError -> {
toast(message = "삭제할 일정을 찾지 못했습니다")
}
FetchScheduleSideEffect.DeleteScheduleCannotFound -> {
toast(message = "일정이 존재하지 않습니다")
}
FetchScheduleSideEffect.TokenError -> {
toast(message = "토큰 만료. 다시 로그인해주세요")
}
}
}
Expand Down Expand Up @@ -259,6 +240,9 @@ fun ShowScheduleScreen(
Spacer(modifier = Modifier.height(20.dp))

SimTongCalendar(
modifier = Modifier
.fillMaxWidth()
.padding(CalendarPadding),
onBeforeClicked = { _, _checkMonth ->
checkMonth = _checkMonth
showScheduleViewModel.showSchedule(
Expand All @@ -273,10 +257,6 @@ fun ShowScheduleScreen(
endAt = getEndAt(checkMonth)
)
},
modifier = Modifier
.fillMaxWidth()
.height(HomeCalendarHeight)
.padding(CalendarPadding),
)

Spacer(modifier = Modifier.height(7.dp))
Expand Down
Loading

0 comments on commit 669a282

Please sign in to comment.