Skip to content

Commit

Permalink
#9 Fix : 노트 상세보기에서 노트 삭제 바텀 시트가 잘려보이는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
DongChyeon committed Dec 10, 2023
1 parent 7cfc5bc commit 3716ee5
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class WineyBottomSheetState(
@OptIn(ExperimentalMaterialApi::class)
fun showBottomSheet(content: SheetContent) = scope.launch {
keyboardController?.hide()
bottomSheetState.hide()
setBottomSheet(content)
bottomSheetState.show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class SignUpContract {
object BackToLogin : Event()
object CancelTasteSelection : Event()
object SetPreferences : Event()

object VerifyCode : Event()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -13,6 +14,9 @@ class NoteDetailContract {
) : UiState

sealed class Event : UiEvent {
object ShowNoteOptionBottomSheet : Event()

object ShowNoteDeleteBottomSheet : Event()
}

sealed class Effect : UiEffect {
Expand All @@ -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()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(
Expand Down

0 comments on commit 3716ee5

Please sign in to comment.