|
| 1 | +package com.threegap.bitnagil.presentation.routinelist.component.template |
| 2 | + |
| 3 | +import androidx.compose.foundation.layout.Column |
| 4 | +import androidx.compose.foundation.layout.Spacer |
| 5 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 6 | +import androidx.compose.foundation.layout.height |
| 7 | +import androidx.compose.foundation.layout.padding |
| 8 | +import androidx.compose.material3.ExperimentalMaterial3Api |
| 9 | +import androidx.compose.material3.ModalBottomSheet |
| 10 | +import androidx.compose.material3.Text |
| 11 | +import androidx.compose.material3.rememberModalBottomSheetState |
| 12 | +import androidx.compose.runtime.Composable |
| 13 | +import androidx.compose.runtime.rememberCoroutineScope |
| 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 kotlinx.coroutines.launch |
| 20 | + |
| 21 | +@OptIn(ExperimentalMaterial3Api::class) |
| 22 | +@Composable |
| 23 | +fun EditConfirmBottomSheet( |
| 24 | + onDismissRequest: () -> Unit, |
| 25 | + onApplyToday: () -> Unit, |
| 26 | + onApplyTomorrow: () -> Unit, |
| 27 | + modifier: Modifier = Modifier, |
| 28 | +) { |
| 29 | + val sheetState = rememberModalBottomSheetState() |
| 30 | + val coroutineScope = rememberCoroutineScope() |
| 31 | + |
| 32 | + ModalBottomSheet( |
| 33 | + sheetState = sheetState, |
| 34 | + onDismissRequest = onDismissRequest, |
| 35 | + contentColor = BitnagilTheme.colors.white, |
| 36 | + containerColor = BitnagilTheme.colors.white, |
| 37 | + modifier = modifier, |
| 38 | + ) { |
| 39 | + EditConfirmContent( |
| 40 | + onApplyToday = { |
| 41 | + onApplyToday() |
| 42 | + coroutineScope |
| 43 | + .launch { sheetState.hide() } |
| 44 | + .invokeOnCompletion { |
| 45 | + if (!sheetState.isVisible) { |
| 46 | + onDismissRequest() |
| 47 | + } |
| 48 | + } |
| 49 | + }, |
| 50 | + onApplyTomorrow = { |
| 51 | + onApplyTomorrow() |
| 52 | + coroutineScope |
| 53 | + .launch { sheetState.hide() } |
| 54 | + .invokeOnCompletion { |
| 55 | + if (!sheetState.isVisible) { |
| 56 | + onDismissRequest() |
| 57 | + } |
| 58 | + } |
| 59 | + }, |
| 60 | + modifier = Modifier |
| 61 | + .padding(horizontal = 24.dp) |
| 62 | + .padding(bottom = 26.dp), |
| 63 | + ) |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +@Composable |
| 68 | +private fun EditConfirmContent( |
| 69 | + onApplyToday: () -> Unit, |
| 70 | + onApplyTomorrow: () -> Unit, |
| 71 | + modifier: Modifier = Modifier, |
| 72 | +) { |
| 73 | + Column( |
| 74 | + modifier = modifier, |
| 75 | + ) { |
| 76 | + Text( |
| 77 | + text = "변경한 루틴, 언제 시작할까요?", |
| 78 | + color = BitnagilTheme.colors.coolGray10, |
| 79 | + style = BitnagilTheme.typography.title3SemiBold, |
| 80 | + ) |
| 81 | + |
| 82 | + Spacer(modifier = Modifier.height(10.dp)) |
| 83 | + |
| 84 | + Text( |
| 85 | + text = "변경된 루틴이 반영되는 시점을 선택해 주세요.", |
| 86 | + color = BitnagilTheme.colors.coolGray40, |
| 87 | + style = BitnagilTheme.typography.body2Medium, |
| 88 | + ) |
| 89 | + |
| 90 | + Spacer(modifier = Modifier.height(24.dp)) |
| 91 | + |
| 92 | + BitnagilTextButton( |
| 93 | + text = "당일부터 적용", |
| 94 | + onClick = onApplyToday, |
| 95 | + modifier = Modifier.fillMaxWidth(), |
| 96 | + textStyle = BitnagilTheme.typography.body2Medium, |
| 97 | + ) |
| 98 | + |
| 99 | + Spacer(modifier = Modifier.height(12.dp)) |
| 100 | + |
| 101 | + BitnagilTextButton( |
| 102 | + text = "다음 날부터 적용", |
| 103 | + onClick = onApplyTomorrow, |
| 104 | + modifier = Modifier.fillMaxWidth(), |
| 105 | + textStyle = BitnagilTheme.typography.body2Medium, |
| 106 | + ) |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | +@Preview |
| 111 | +@Composable |
| 112 | +private fun EditConfirmContentPreview() { |
| 113 | + EditConfirmContent( |
| 114 | + onApplyToday = {}, |
| 115 | + onApplyTomorrow = {}, |
| 116 | + ) |
| 117 | +} |
0 commit comments