Skip to content

Commit 63deaf0

Browse files
authored
Merge pull request #115 from YAPP-Github/feature/#114-routine-list
2 parents b86184d + 95c5283 commit 63deaf0

File tree

16 files changed

+142
-85
lines changed

16 files changed

+142
-85
lines changed

app/src/main/java/com/threegap/bitnagil/MainActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import androidx.activity.compose.setContent
99
import androidx.activity.enableEdgeToEdge
1010
import androidx.compose.foundation.layout.Box
1111
import androidx.compose.foundation.layout.fillMaxSize
12+
import androidx.compose.foundation.layout.navigationBarsPadding
1213
import androidx.compose.foundation.layout.padding
1314
import androidx.compose.runtime.LaunchedEffect
1415
import androidx.compose.ui.Alignment
@@ -53,7 +54,8 @@ class MainActivity : ComponentActivity() {
5354
state = globalToast,
5455
modifier = Modifier
5556
.align(Alignment.BottomCenter)
56-
.padding(bottom = 100.dp),
57+
.navigationBarsPadding()
58+
.padding(bottom = if (mainNavigator.hasBottomNavigationBarRoute()) 80.dp else 16.dp),
5759
)
5860
}
5961
}

app/src/main/java/com/threegap/bitnagil/MainNavigator.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
package com.threegap.bitnagil
22

33
import androidx.compose.runtime.Composable
4+
import androidx.compose.runtime.getValue
45
import androidx.compose.runtime.remember
6+
import androidx.navigation.NavDestination
7+
import androidx.navigation.NavDestination.Companion.hasRoute
58
import androidx.navigation.NavHostController
9+
import androidx.navigation.compose.currentBackStackEntryAsState
610
import androidx.navigation.compose.rememberNavController
711

812
class MainNavigator(
913
val navController: NavHostController,
1014
) {
1115
val startDestination = Route.Splash
1216

17+
private val currentDestination: NavDestination?
18+
@Composable get() {
19+
val currentEntry by navController.currentBackStackEntryAsState()
20+
return currentEntry?.destination
21+
}
22+
1323
internal fun navigateToHomeAndClearStack() =
1424
navController.navigate(Route.Home) {
1525
popUpTo(0) {
1626
inclusive = true
1727
}
1828
}
29+
30+
@Composable
31+
internal fun hasBottomNavigationBarRoute(): Boolean {
32+
val destination = currentDestination
33+
return when {
34+
destination?.hasRoute<Route.Home>() == true -> true
35+
else -> false
36+
}
37+
}
1938
}
2039

2140
@Composable

core/designsystem/src/main/java/com/threegap/bitnagil/designsystem/component/atom/BitnagilToastMessage.kt

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import androidx.compose.animation.slideInVertically
88
import androidx.compose.animation.slideOutVertically
99
import androidx.compose.foundation.background
1010
import androidx.compose.foundation.layout.Arrangement
11-
import androidx.compose.foundation.layout.Box
12-
import androidx.compose.foundation.layout.Column
1311
import androidx.compose.foundation.layout.Row
12+
import androidx.compose.foundation.layout.fillMaxWidth
1413
import androidx.compose.foundation.layout.padding
1514
import androidx.compose.foundation.layout.size
1615
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -33,38 +32,34 @@ import kotlinx.coroutines.delay
3332

3433
@Composable
3534
fun BitnagilToastMessage(
35+
@DrawableRes id: Int,
3636
text: String,
3737
modifier: Modifier = Modifier,
38-
@DrawableRes id: Int? = null,
3938
) {
40-
Box(
39+
Row(
4140
modifier = modifier
41+
.padding(horizontal = 16.dp)
4242
.background(
43-
color = BitnagilTheme.colors.navy400,
44-
shape = RoundedCornerShape(8.dp),
43+
color = BitnagilTheme.colors.coolGray30,
44+
shape = RoundedCornerShape(12.dp),
4545
)
46-
.padding(vertical = 10.dp, horizontal = 20.dp),
47-
contentAlignment = Alignment.Center,
46+
.fillMaxWidth()
47+
.padding(vertical = 14.dp, horizontal = 16.dp),
48+
verticalAlignment = Alignment.CenterVertically,
49+
horizontalArrangement = Arrangement.spacedBy(8.dp),
4850
) {
49-
Row(
50-
verticalAlignment = Alignment.CenterVertically,
51-
) {
52-
if (id != null) {
53-
BitnagilIcon(
54-
id = id,
55-
tint = BitnagilTheme.colors.error,
56-
modifier = Modifier
57-
.padding(end = 4.dp)
58-
.size(24.dp),
59-
)
60-
}
61-
Text(
62-
text = text,
63-
color = BitnagilTheme.colors.white,
64-
style = BitnagilTheme.typography.body2Medium,
65-
textAlign = TextAlign.Center,
66-
)
67-
}
51+
BitnagilIcon(
52+
id = id,
53+
tint = null,
54+
modifier = Modifier.size(24.dp),
55+
)
56+
57+
Text(
58+
text = text,
59+
color = BitnagilTheme.colors.white,
60+
style = BitnagilTheme.typography.body2Medium,
61+
textAlign = TextAlign.Center,
62+
)
6863
}
6964
}
7065

@@ -98,17 +93,17 @@ fun BitnagilToastContainer(
9893

9994
class BitnagilToastState {
10095
private var _text by mutableStateOf("")
101-
private var _icon by mutableStateOf<Int?>(null)
96+
private var _icon by mutableIntStateOf(0)
10297
private var _isVisible by mutableStateOf(false)
10398
private var _toastId by mutableIntStateOf(0)
10499
private var _lastShowTime = 0L
105100

106101
val text: String get() = _text
107-
val icon: Int? get() = _icon
102+
val icon: Int get() = _icon
108103
val isVisible: Boolean get() = _isVisible
109104
val toastId: Int get() = _toastId
110105

111-
fun show(text: String, icon: Int? = null) {
106+
fun show(text: String, icon: Int) {
112107
if (shouldPreventDuplicateShow(text, icon)) {
113108
return
114109
}
@@ -124,7 +119,7 @@ class BitnagilToastState {
124119
return _text == text && _icon == icon && currentTime - _lastShowTime < 500L
125120
}
126121

127-
private fun showToast(text: String, icon: Int?) {
122+
private fun showToast(text: String, icon: Int) {
128123
_text = text
129124
_icon = icon
130125
_isVisible = true
@@ -139,16 +134,8 @@ fun rememberBitnagilToast(): BitnagilToastState = remember { BitnagilToastState(
139134
@Preview
140135
@Composable
141136
private fun BitnagilToastMessagePreview() {
142-
Column(
143-
verticalArrangement = Arrangement.spacedBy(8.dp),
144-
) {
145-
BitnagilToastMessage(
146-
text = "버튼을 한 번 더 누르면 종료됩니다.",
147-
id = R.drawable.ic_warning,
148-
)
149-
150-
BitnagilToastMessage(
151-
text = "루틴 완료 상태 저장에 실패했어요.\n다시 시도해 주세요.",
152-
)
153-
}
137+
BitnagilToastMessage(
138+
text = "버튼을 한 번 더 누르면 종료됩니다.",
139+
id = R.drawable.ic_warning,
140+
)
154141
}

core/designsystem/src/main/res/drawable/ic_warning.xml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,29 @@
55
android:viewportHeight="24">
66
<path
77
android:fillColor="#FF6868"
8-
android:pathData="M12,15.5C11.575,15.5 11.219,15.383 10.931,15.149C10.644,14.914 10.5,14.624 10.5,14.278V5.722C10.5,5.376 10.644,5.086 10.931,4.851C11.219,4.617 11.575,4.5 12,4.5C12.425,4.5 12.781,4.617 13.069,4.851C13.356,5.086 13.5,5.376 13.5,5.722V14.278C13.5,14.624 13.356,14.914 13.069,15.149C12.781,15.383 12.425,15.5 12,15.5Z" />
8+
android:pathData="M4.622,15.21C4.472,15.47 4.332,15.71 4.202,15.93C4.052,16.2 3.632,16.28 3.512,16.5C3.362,16.79 3.132,17 3.052,17.22C2.942,17.53 2.892,17.87 2.912,18.11C2.942,18.39 3.002,18.76 3.142,19C3.282,19.24 3.612,19.41 3.842,19.58C4.032,19.72 4.372,19.55 4.702,19.61C4.932,19.65 5.172,19.78 5.492,19.79C5.742,19.8 6.012,19.8 6.312,19.8C6.562,19.8 6.842,19.63 7.142,19.63C7.542,19.63 7.542,19.79 7.942,19.79C8.342,19.79 8.342,19.88 8.752,19.88C9.162,19.88 9.152,20.12 9.562,20.12C9.972,20.12 9.962,20.12 10.372,20.12C10.781,20.12 10.771,19.79 11.182,19.79C11.592,19.79 11.582,19.9 11.991,19.9C12.401,19.9 12.392,19.99 12.802,19.99C13.212,19.99 13.201,20.09 13.611,20.09C14.021,20.09 14.012,19.74 14.422,19.74C14.832,19.74 14.832,20.03 15.231,20.03C15.632,20.03 15.642,20.04 16.042,20.04C16.441,20.04 16.451,19.77 16.851,19.77C17.152,19.77 17.431,19.6 17.681,19.59C17.992,19.59 18.271,19.87 18.511,19.85C18.831,19.84 19.111,19.85 19.341,19.81C19.671,19.75 19.751,19.41 19.941,19.27C20.171,19.1 20.601,19.16 20.742,18.92C20.882,18.68 21.031,18.38 21.062,18.1C21.091,17.86 21.132,17.5 21.011,17.19C20.931,16.97 20.581,16.81 20.431,16.52C20.322,16.3 20.132,16.09 19.982,15.82C19.851,15.6 19.851,15.28 19.701,15.02C19.501,14.67 19.521,14.66 19.312,14.31C19.101,13.96 18.761,14.16 18.552,13.81C18.341,13.46 18.701,13.26 18.501,12.91C18.302,12.56 18.351,12.53 18.152,12.18C17.951,11.83 17.751,11.94 17.552,11.59C17.351,11.24 17.242,11.3 17.042,10.95C16.841,10.6 16.861,10.59 16.662,10.24C16.462,9.89 16.462,9.89 16.261,9.54C16.062,9.19 16.281,9.06 16.081,8.71C15.882,8.36 15.651,8.49 15.451,8.14C15.252,7.79 15.601,7.58 15.401,7.23C15.201,6.88 15.151,6.9 14.951,6.55C14.802,6.29 14.571,6.1 14.441,5.88C14.281,5.61 13.872,5.55 13.741,5.34C13.571,5.07 13.741,4.6 13.592,4.42C13.382,4.17 13.071,4.02 12.851,3.92C12.592,3.8 12.262,3.99 11.991,3.99C11.722,3.99 11.542,4.15 11.281,4.26C11.061,4.36 10.672,4.22 10.451,4.48C10.302,4.66 10.292,4.99 10.111,5.26C9.982,5.47 9.702,5.62 9.552,5.89C9.422,6.11 9.242,6.32 9.082,6.58C8.882,6.93 9.012,7 8.802,7.35C8.592,7.7 8.852,7.84 8.642,8.19C8.432,8.54 8.132,8.36 7.932,8.71C7.732,9.06 7.662,9.02 7.462,9.37C7.262,9.72 7.162,9.66 6.962,10.01C6.762,10.36 7.042,10.52 6.842,10.87C6.642,11.22 6.712,11.26 6.512,11.61C6.312,11.96 6.392,12.01 6.192,12.35C5.992,12.69 5.842,12.62 5.642,12.97C5.442,13.32 5.242,13.2 5.032,13.56C4.822,13.92 4.812,13.93 4.692,14.32C4.562,14.74 4.792,14.83 4.592,15.18L4.622,15.21Z" />
99
<path
10-
android:fillColor="#FF6868"
11-
android:pathData="M12,18m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0" />
10+
android:fillColor="#00000000"
11+
android:pathData="M4.622,15.21C4.472,15.47 4.332,15.71 4.202,15.93C4.052,16.2 3.632,16.28 3.512,16.5C3.362,16.79 3.132,17 3.052,17.22C2.942,17.53 2.892,17.87 2.912,18.11C2.942,18.39 3.002,18.76 3.142,19C3.282,19.24 3.612,19.41 3.842,19.58C4.032,19.72 4.372,19.55 4.702,19.61C4.932,19.65 5.172,19.78 5.492,19.79C5.742,19.8 6.012,19.8 6.312,19.8C6.562,19.8 6.842,19.63 7.142,19.63C7.542,19.63 7.542,19.79 7.942,19.79C8.342,19.79 8.342,19.88 8.752,19.88C9.162,19.88 9.152,20.12 9.562,20.12C9.972,20.12 9.962,20.12 10.372,20.12C10.781,20.12 10.771,19.79 11.182,19.79C11.592,19.79 11.582,19.9 11.991,19.9C12.401,19.9 12.392,19.99 12.802,19.99C13.212,19.99 13.201,20.09 13.611,20.09C14.021,20.09 14.012,19.74 14.422,19.74C14.832,19.74 14.832,20.03 15.231,20.03C15.632,20.03 15.642,20.04 16.042,20.04C16.441,20.04 16.451,19.77 16.851,19.77C17.152,19.77 17.431,19.6 17.681,19.59C17.992,19.59 18.271,19.87 18.511,19.85C18.831,19.84 19.111,19.85 19.341,19.81C19.671,19.75 19.751,19.41 19.941,19.27C20.171,19.1 20.601,19.16 20.742,18.92C20.882,18.68 21.031,18.38 21.062,18.1C21.091,17.86 21.132,17.5 21.011,17.19C20.931,16.97 20.581,16.81 20.431,16.52C20.322,16.3 20.132,16.09 19.982,15.82C19.851,15.6 19.851,15.28 19.701,15.02C19.501,14.67 19.521,14.66 19.312,14.31C19.101,13.96 18.761,14.16 18.552,13.81C18.341,13.46 18.701,13.26 18.501,12.91C18.302,12.56 18.351,12.53 18.152,12.18C17.951,11.83 17.751,11.94 17.552,11.59C17.351,11.24 17.242,11.3 17.042,10.95C16.841,10.6 16.861,10.59 16.662,10.24C16.462,9.89 16.462,9.89 16.261,9.54C16.062,9.19 16.281,9.06 16.081,8.71C15.882,8.36 15.651,8.49 15.451,8.14C15.252,7.79 15.601,7.58 15.401,7.23C15.201,6.88 15.151,6.9 14.951,6.55C14.802,6.29 14.571,6.1 14.441,5.88C14.281,5.61 13.872,5.55 13.741,5.34C13.571,5.07 13.741,4.6 13.592,4.42C13.382,4.17 13.071,4.02 12.851,3.92C12.592,3.8 12.262,3.99 11.991,3.99C11.722,3.99 11.542,4.15 11.281,4.26C11.061,4.36 10.672,4.22 10.451,4.48C10.302,4.66 10.292,4.99 10.111,5.26C9.982,5.47 9.702,5.62 9.552,5.89C9.422,6.11 9.242,6.32 9.082,6.58C8.882,6.93 9.012,7 8.802,7.35C8.592,7.7 8.852,7.84 8.642,8.19C8.432,8.54 8.132,8.36 7.932,8.71C7.732,9.06 7.662,9.02 7.462,9.37C7.262,9.72 7.162,9.66 6.962,10.01C6.762,10.36 7.042,10.52 6.842,10.87C6.642,11.22 6.712,11.26 6.512,11.61C6.312,11.96 6.392,12.01 6.192,12.35C5.992,12.69 5.842,12.62 5.642,12.97C5.442,13.32 5.242,13.2 5.032,13.56C4.822,13.92 4.812,13.93 4.692,14.32C4.562,14.74 4.792,14.83 4.592,15.18L4.622,15.21Z"
12+
android:strokeWidth="2"
13+
android:strokeColor="#FF6868"
14+
android:strokeLineCap="round"
15+
android:strokeLineJoin="round" />
16+
<path
17+
android:fillColor="#00000000"
18+
android:pathData="M12.191,8.88C12.191,9.28 12.301,9.28 12.301,9.68C12.301,10.08 12.161,10.08 12.161,10.48C12.161,10.88 11.871,10.88 11.871,11.28C11.871,11.68 11.891,11.68 11.891,12.08C11.891,12.48 12.181,12.48 12.181,12.88"
19+
android:strokeWidth="2"
20+
android:strokeColor="#ffffff"
21+
android:strokeLineCap="round"
22+
android:strokeLineJoin="round" />
23+
<path
24+
android:fillColor="#00000000"
25+
android:pathData="M11.932,16.01C11.932,16.01 11.972,15.81 11.932,15.84C11.892,15.87 12.162,15.84 12.132,15.8C12.102,15.76 12.012,15.77 11.962,15.77C11.882,15.77 11.892,15.97 11.932,16.01Z"
26+
android:strokeWidth="2"
27+
android:strokeColor="#ffffff"
28+
android:strokeLineCap="round"
29+
android:strokeLineJoin="round" />
30+
<path
31+
android:fillColor="#ffffff"
32+
android:pathData="M11.954,15.889m-1,0a1,1 0,1 1,2 0a1,1 0,1 1,-2 0" />
1233
</vector>

domain/src/main/java/com/threegap/bitnagil/domain/routine/model/DayOfWeek.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enum class DayOfWeek {
3535
}
3636

3737
fun List<DayOfWeek>.formatRepeatDays(): String {
38-
if (this.isEmpty()) return "반복 없음"
38+
if (this.isEmpty()) return "x"
3939
return this.sortedBy { it.ordinal }
4040
.joinToString(", ") { it.toKoreanShort() }
4141
}

presentation/src/main/java/com/threegap/bitnagil/presentation/common/toast/GlobalBitnagilToast.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ object GlobalBitnagilToast {
1111
_toastStateRef = WeakReference(toastState)
1212
}
1313

14-
fun show(text: String, icon: Int? = null) {
14+
fun show(text: String, icon: Int) {
1515
_toastStateRef?.get()?.show(text, icon)
1616
}
1717

18-
fun showCheck(text: String) = show(text, R.drawable.ic_check)
18+
fun showCheck(text: String) = show(text, R.drawable.ic_check_circle_orange)
1919

2020
fun showWarning(text: String) = show(text, R.drawable.ic_warning)
2121
}

presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeScreen.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
2626
import com.threegap.bitnagil.designsystem.BitnagilTheme
2727
import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple
2828
import com.threegap.bitnagil.presentation.common.flow.collectAsEffect
29-
import com.threegap.bitnagil.presentation.common.toast.GlobalBitnagilToast
3029
import com.threegap.bitnagil.presentation.home.component.template.CollapsibleHomeHeader
3130
import com.threegap.bitnagil.presentation.home.component.template.EmptyRoutineView
3231
import com.threegap.bitnagil.presentation.home.component.template.RoutineSection
@@ -64,14 +63,6 @@ fun HomeScreenContainer(
6463
is HomeSideEffect.NavigateToRoutineList -> {
6564
navigateToRoutineList(sideEffect.selectedDate)
6665
}
67-
68-
is HomeSideEffect.ShowToastWithIcon -> {
69-
GlobalBitnagilToast.showCheck(sideEffect.message)
70-
}
71-
72-
is HomeSideEffect.ShowToast -> {
73-
GlobalBitnagilToast.show(sideEffect.message)
74-
}
7566
}
7667
}
7768

presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ class HomeViewModel @Inject constructor(
132132
}
133133

134134
is HomeIntent.RoutineToggleCompletionFailure -> {
135-
sendSideEffect(HomeSideEffect.ShowToast("루틴 완료 상태 저장에 실패했어요.\n다시 시도해 주세요."))
136135
null
137136
}
138137
}

presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/HomeSideEffect.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package com.threegap.bitnagil.presentation.home.model
33
import com.threegap.bitnagil.presentation.common.mviviewmodel.MviSideEffect
44

55
sealed interface HomeSideEffect : MviSideEffect {
6-
data class ShowToast(val message: String) : HomeSideEffect
7-
data class ShowToastWithIcon(val message: String) : HomeSideEffect
86
data object NavigateToGuide : HomeSideEffect
97
data object NavigateToRegisterRoutine : HomeSideEffect
108
data object NavigateToEmotion : HomeSideEffect

presentation/src/main/java/com/threegap/bitnagil/presentation/home/util/LocalDateExtension.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ private val koreanLocale = Locale.KOREAN
1111
private val monthYearFormatter = DateTimeFormatter.ofPattern("yyyy년 M월", koreanLocale)
1212
private val executionTimeFormatter12 = DateTimeFormatter.ofPattern("a h:mm", koreanLocale)
1313
private val executionTimeFormatter24 = DateTimeFormatter.ofPattern("HH:mm", koreanLocale)
14+
private val shortDateFormatter = DateTimeFormatter.ofPattern("yy.MM.dd")
1415

1516
fun LocalDate.getCurrentWeekDays(): List<LocalDate> =
1617
(0..6).map { this.with(DayOfWeek.MONDAY).plusDays(it.toLong()) }
@@ -47,3 +48,11 @@ fun String.formatExecutionTime12Hour(): String =
4748
} catch (e: Exception) {
4849
"시간 미정"
4950
}
51+
52+
fun String.toShortDateFormat(): String =
53+
try {
54+
val date = LocalDate.parse(this)
55+
date.format(shortDateFormatter)
56+
} catch (e: Exception) {
57+
this
58+
}

0 commit comments

Comments
 (0)