Skip to content

Commit

Permalink
[#28 refactoring] snackbar가 viewModel 들고있는 것 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahn-seokjoo committed Jun 28, 2024
1 parent 6dabf68 commit dbf4419
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import com.mashup.dorabangs.core.designsystem.component.snackbar.DoraSnackBar
fun HomeDoraSnackBar(
view: View,
text: String,
viewModel: HomeViewModel,
clipboardManager: ClipboardManager,
snackBarHostState: SnackbarHostState,
showSnackBarWithText: (String) -> Unit,
hideSnackBar: () -> Unit,
action: () -> Unit,
dismissAction: () -> Unit,
modifier: Modifier = Modifier,
Expand All @@ -23,11 +24,11 @@ fun HomeDoraSnackBar(
runCatching {
view.post {
val clipboardText = clipboardManager.getText()?.text.orEmpty()
viewModel.showSnackBar(clipboardText)
showSnackBarWithText(clipboardText)
}
}
onPauseOrDispose {
viewModel.hideSnackBar()
hideSnackBar()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ fun HomeRoute(
val snackBarHostState by remember { mutableStateOf(SnackbarHostState()) }
val state by viewModel.collectAsState()
val scope = rememberCoroutineScope()
viewModel.collectSideEffect {
when (it) {
viewModel.collectSideEffect { sideEffect ->
when (sideEffect) {
is HomeSideEffect.ShowSnackBar -> {
scope.launch {
snackBarHostState.showSnackbar(
message = it.copiedText,
message = sideEffect.copiedText,
duration = SnackbarDuration.Indefinite,
)
}
Expand Down Expand Up @@ -70,8 +70,9 @@ fun HomeRoute(
action = actionSnackBar,
snackBarHostState = snackBarHostState,
view = view,
viewModel = viewModel,
clipboardManager = clipboardManager,
hideSnackBar = viewModel::hideSnackBar,
showSnackBarWithText = viewModel::showSnackBar,
dismissAction = viewModel::hideSnackBar,
)
}
Expand Down

0 comments on commit dbf4419

Please sign in to comment.