diff --git a/core/common/src/main/java/com/teamwiney/core/common/WineyBottomSheetState.kt b/core/common/src/main/java/com/teamwiney/core/common/WineyBottomSheetState.kt index 0c000bb9..2f5ebf3a 100644 --- a/core/common/src/main/java/com/teamwiney/core/common/WineyBottomSheetState.kt +++ b/core/common/src/main/java/com/teamwiney/core/common/WineyBottomSheetState.kt @@ -72,6 +72,7 @@ class WineyBottomSheetState( @OptIn(ExperimentalMaterialApi::class) fun showBottomSheet(content: SheetContent) = scope.launch { keyboardController?.hide() + bottomSheetState.hide() setBottomSheet(content) bottomSheetState.show() } diff --git a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpContract.kt b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpContract.kt index 2e515750..5f43ef0e 100644 --- a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpContract.kt +++ b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpContract.kt @@ -81,7 +81,6 @@ class SignUpContract { object BackToLogin : Event() object CancelTasteSelection : Event() object SetPreferences : Event() - object VerifyCode : Event() } diff --git a/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailContract.kt b/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailContract.kt index ce08cb44..fd8df26f 100644 --- a/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailContract.kt +++ b/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailContract.kt @@ -3,6 +3,7 @@ package com.teamwiney.notedetail import androidx.navigation.NavOptions import com.teamwiney.core.common.base.UiEffect import com.teamwiney.core.common.base.UiEvent +import com.teamwiney.core.common.base.UiSheet import com.teamwiney.core.common.base.UiState import com.teamwiney.data.network.model.response.TastingNoteDetail @@ -13,6 +14,9 @@ class NoteDetailContract { ) : UiState sealed class Event : UiEvent { + object ShowNoteOptionBottomSheet : Event() + + object ShowNoteDeleteBottomSheet : Event() } sealed class Effect : UiEffect { @@ -22,7 +26,15 @@ class NoteDetailContract { ) : Effect() data class ShowSnackBar(val message: String) : Effect() + + data class ShowBottomSheet(val bottomSheet: BottomSheet) : Effect() + object NoteDeleted : Effect() } + sealed class BottomSheet : UiSheet { + object NoteOption : BottomSheet() + object NoteDelete : BottomSheet() + } + } \ No newline at end of file diff --git a/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailScreen.kt b/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailScreen.kt index b7d42c65..ee21560b 100644 --- a/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailScreen.kt +++ b/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailScreen.kt @@ -28,6 +28,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.teamwiney.core.common.WineyAppState import com.teamwiney.core.common.WineyBottomSheetState import com.teamwiney.core.design.R +import com.teamwiney.notedetail.component.NoteDeleteBottomSheet import com.teamwiney.notedetail.component.NoteDetailBottomSheet import com.teamwiney.notedetail.component.WineInfo import com.teamwiney.notedetail.component.WineMemo @@ -64,6 +65,34 @@ fun NoteDetailScreen( appState.showSnackbar(effect.message) } + is NoteDetailContract.Effect.ShowBottomSheet -> { + bottomSheetState.showBottomSheet { + when (effect.bottomSheet) { + is NoteDetailContract.BottomSheet.NoteOption -> { + NoteDetailBottomSheet( + deleteNote = { + bottomSheetState.hideBottomSheet() + viewModel.processEvent( + NoteDetailContract.Event.ShowNoteDeleteBottomSheet + ) + }, + patchNote = { + } + ) + } + + is NoteDetailContract.BottomSheet.NoteDelete -> { + NoteDeleteBottomSheet( + onConfirm = { + viewModel.deleteNote(uiState.noteDetail.noteId.toInt()) + }, + onCancel = bottomSheetState::hideBottomSheet + ) + } + } + } + } + is NoteDetailContract.Effect.NoteDeleted -> { appState.showSnackbar("노트가 삭제되었습니다.") appState.navController.navigateUp() @@ -93,17 +122,7 @@ fun NoteDetailScreen( .clip(CircleShape) .size(28.dp) .clickable { - bottomSheetState.showBottomSheet { - NoteDetailBottomSheet( - showBottomSheet = bottomSheetState::showBottomSheet, - hideBottomSheet = bottomSheetState::hideBottomSheet, - deleteNote = { - viewModel.deleteNote(uiState.noteDetail.noteId.toInt()) - }, - patchNote = { - } - ) - } + viewModel.processEvent(NoteDetailContract.Event.ShowNoteOptionBottomSheet) } ) } diff --git a/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailViewModel.kt b/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailViewModel.kt index 0518fa90..d3ff8f3e 100644 --- a/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailViewModel.kt +++ b/feature/note/src/main/java/com/teamwiney/notedetail/NoteDetailViewModel.kt @@ -18,7 +18,20 @@ class NoteDetailViewModel @Inject constructor( override fun reduceState(event: NoteDetailContract.Event) { viewModelScope.launch { when (event) { - else -> {} + is NoteDetailContract.Event.ShowNoteOptionBottomSheet -> { + postEffect( + NoteDetailContract.Effect.ShowBottomSheet( + NoteDetailContract.BottomSheet.NoteOption + ) + ) + } + is NoteDetailContract.Event.ShowNoteDeleteBottomSheet -> { + postEffect( + NoteDetailContract.Effect.ShowBottomSheet( + NoteDetailContract.BottomSheet.NoteDelete + ) + ) + } } } } diff --git a/feature/note/src/main/java/com/teamwiney/notedetail/component/NoteDetailBottomSheet.kt b/feature/note/src/main/java/com/teamwiney/notedetail/component/NoteDetailBottomSheet.kt index 792c6ff8..da9b0359 100644 --- a/feature/note/src/main/java/com/teamwiney/notedetail/component/NoteDetailBottomSheet.kt +++ b/feature/note/src/main/java/com/teamwiney/notedetail/component/NoteDetailBottomSheet.kt @@ -8,25 +8,17 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.teamwiney.core.common.`typealias`.SheetContent import com.teamwiney.ui.theme.WineyTheme -import kotlinx.coroutines.launch @Composable fun NoteDetailBottomSheet( - showBottomSheet: (SheetContent) -> Unit, - hideBottomSheet: () -> Unit, deleteNote: () -> Unit, patchNote: () -> Unit ) { - - val localScope = rememberCoroutineScope() - Column( modifier = Modifier .fillMaxWidth() @@ -51,18 +43,7 @@ fun NoteDetailBottomSheet( style = WineyTheme.typography.bodyB1, modifier = Modifier .fillMaxWidth() - .clickable { - localScope.launch { - hideBottomSheet() - - showBottomSheet { - NoteDeleteBottomSheet( - onConfirm = deleteNote, - onCancel = hideBottomSheet - ) - } - } - } + .clickable { deleteNote() } .padding(20.dp) ) Text(