Skip to content

Commit 43a7219

Browse files
committed
Feat: DeleteConfirmBottomSheet 컴포넌트 구현
1 parent 5b3cff7 commit 43a7219

1 file changed

Lines changed: 192 additions & 0 deletions

File tree

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
package com.threegap.bitnagil.presentation.routinelist.component.template
2+
3+
import androidx.compose.foundation.layout.Arrangement
4+
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.Row
6+
import androidx.compose.foundation.layout.Spacer
7+
import androidx.compose.foundation.layout.fillMaxWidth
8+
import androidx.compose.foundation.layout.height
9+
import androidx.compose.foundation.layout.padding
10+
import androidx.compose.material3.ExperimentalMaterial3Api
11+
import androidx.compose.material3.ModalBottomSheet
12+
import androidx.compose.material3.Text
13+
import androidx.compose.runtime.Composable
14+
import androidx.compose.ui.Modifier
15+
import androidx.compose.ui.tooling.preview.Preview
16+
import androidx.compose.ui.unit.dp
17+
import com.threegap.bitnagil.designsystem.BitnagilTheme
18+
import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton
19+
import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButtonColor
20+
import com.threegap.bitnagil.presentation.routinelist.model.RoutineUiModel
21+
22+
@OptIn(ExperimentalMaterial3Api::class)
23+
@Composable
24+
fun DeleteConfirmBottomSheet(
25+
routine: RoutineUiModel,
26+
onDismissRequest: () -> Unit,
27+
onDeleteToday: () -> Unit,
28+
onDeleteAll: () -> Unit,
29+
onCancel: () -> Unit,
30+
modifier: Modifier = Modifier,
31+
) {
32+
ModalBottomSheet(
33+
modifier = modifier,
34+
onDismissRequest = onDismissRequest,
35+
contentColor = BitnagilTheme.colors.white,
36+
containerColor = BitnagilTheme.colors.white,
37+
) {
38+
if (routine.repeatDay.isNotEmpty()) {
39+
RepeatRoutineDeleteContent(
40+
onDeleteToday = onDeleteToday,
41+
onDeleteAll = onDeleteAll,
42+
modifier = Modifier
43+
.padding(horizontal = 24.dp)
44+
.padding(bottom = 26.dp),
45+
)
46+
} else {
47+
SingleRoutineDeleteContent(
48+
onCancel = onCancel,
49+
onDelete = onDeleteAll,
50+
modifier = Modifier
51+
.padding(horizontal = 24.dp)
52+
.padding(bottom = 26.dp),
53+
)
54+
}
55+
}
56+
}
57+
58+
@Composable
59+
private fun RepeatRoutineDeleteContent(
60+
onDeleteToday: () -> Unit,
61+
onDeleteAll: () -> Unit,
62+
modifier: Modifier = Modifier,
63+
) {
64+
Column(
65+
modifier = modifier,
66+
) {
67+
Text(
68+
text = "이 루틴은 반복 설정되어 있어요",
69+
color = BitnagilTheme.colors.coolGray10,
70+
style = BitnagilTheme.typography.title3SemiBold,
71+
)
72+
73+
Spacer(modifier = Modifier.height(10.dp))
74+
75+
Text(
76+
text = "오늘만 삭제하거나, 전체 반복 일정에서 모두 삭제할 수\n있습니다. 삭제한 루틴은 되돌릴 수 없어요.",
77+
color = BitnagilTheme.colors.coolGray40,
78+
style = BitnagilTheme.typography.body2Medium,
79+
modifier = Modifier
80+
.padding(end = 40.dp)
81+
.fillMaxWidth(),
82+
)
83+
84+
Spacer(modifier = Modifier.height(24.dp))
85+
86+
BitnagilTextButton(
87+
text = "오늘만 삭제",
88+
onClick = onDeleteToday,
89+
modifier = Modifier.fillMaxWidth(),
90+
textStyle = BitnagilTheme.typography.body2Medium,
91+
)
92+
93+
Spacer(modifier = Modifier.height(12.dp))
94+
95+
BitnagilTextButton(
96+
text = "모든 날짜에서 삭제",
97+
onClick = onDeleteAll,
98+
colors = BitnagilTextButtonColor.delete(),
99+
modifier = Modifier.fillMaxWidth(),
100+
textStyle = BitnagilTheme.typography.body2Medium,
101+
)
102+
}
103+
}
104+
105+
@Composable
106+
private fun SingleRoutineDeleteContent(
107+
onCancel: () -> Unit,
108+
onDelete: () -> Unit,
109+
modifier: Modifier = Modifier,
110+
) {
111+
Column(
112+
modifier = modifier,
113+
) {
114+
Text(
115+
text = "루틴을 삭제하시겠어요?",
116+
color = BitnagilTheme.colors.coolGray10,
117+
style = BitnagilTheme.typography.title3SemiBold,
118+
)
119+
120+
Spacer(modifier = Modifier.height(10.dp))
121+
122+
Text(
123+
text = "이 루틴과 관련된 모든 기록이 함께 삭제되며, 삭제 후에는\n되돌릴 수 없습니다. 정말 삭제하시겠어요?",
124+
color = BitnagilTheme.colors.coolGray40,
125+
style = BitnagilTheme.typography.body2Medium,
126+
modifier = Modifier
127+
.padding(end = 40.dp)
128+
.fillMaxWidth(),
129+
)
130+
131+
Spacer(modifier = Modifier.height(24.dp))
132+
133+
Row(
134+
horizontalArrangement = Arrangement.spacedBy(12.dp),
135+
) {
136+
BitnagilTextButton(
137+
text = "취소",
138+
onClick = onCancel,
139+
colors = BitnagilTextButtonColor.cancel(),
140+
modifier = Modifier.weight(1f),
141+
textStyle = BitnagilTheme.typography.body2Medium,
142+
)
143+
144+
BitnagilTextButton(
145+
text = "삭제",
146+
onClick = onDelete,
147+
modifier = Modifier.weight(1f),
148+
textStyle = BitnagilTheme.typography.body2Medium,
149+
)
150+
}
151+
}
152+
}
153+
154+
@Preview
155+
@Composable
156+
private fun SingleRoutineDeleteContentPreview() {
157+
SingleRoutineDeleteContent(
158+
onCancel = {},
159+
onDelete = {},
160+
modifier = Modifier.padding(24.dp),
161+
)
162+
}
163+
164+
@Preview
165+
@Composable
166+
private fun RepeatRoutineDeleteContentPreview() {
167+
RepeatRoutineDeleteContent(
168+
onDeleteToday = {},
169+
onDeleteAll = {},
170+
modifier = Modifier.padding(24.dp),
171+
)
172+
}
173+
174+
@Preview
175+
@Composable
176+
private fun DeleteConfirmBottomSheetPreview() {
177+
DeleteConfirmBottomSheet(
178+
routine = RoutineUiModel(
179+
routineId = "1",
180+
routineName = "물마시기",
181+
repeatDay = listOf(),
182+
routineDate = "",
183+
executionTime = "08:00",
184+
recommendedRoutineType = null,
185+
subRoutineNames = emptyList()
186+
),
187+
onDismissRequest = {},
188+
onDeleteToday = {},
189+
onDeleteAll = {},
190+
onCancel = {},
191+
)
192+
}

0 commit comments

Comments
 (0)