Skip to content

Commit

Permalink
[FEATURE]#155 : SideEffectState 및 SideEffect에 따른 처리 컴포넌트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Sep 18, 2024
1 parent 5176524 commit 95f7346
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.bff.wespot.model

data class SideEffectState(
val show: Boolean,
val sideEffect: SideEffect,
) {
constructor() : this(false, SideEffect.ShowToast(""))
}
35 changes: 35 additions & 0 deletions core/ui/src/main/kotlin/com/bff/wespot/ui/SideEffectHandler.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.bff.wespot.ui

import androidx.compose.runtime.Composable
import com.bff.wespot.designsystem.component.indicator.WSToastType
import com.bff.wespot.designsystem.component.modal.WSDialog
import com.bff.wespot.designsystem.component.modal.WSDialogType
import com.bff.wespot.model.SideEffect
import com.bff.wespot.model.SideEffectState

@Composable
fun SideEffectHandler(
state: SideEffectState,
onDismiss: () -> Unit,
onNavigate: () -> Unit,
) {
if (state.show) {
when (state.sideEffect) {
is SideEffect.ShowToast -> TopToast(
message = state.sideEffect.message,
toastType = WSToastType.Error,
showToast = true,
closeToast = onDismiss,
)

is SideEffect.ShowDialog -> WSDialog(
dialogType = WSDialogType.OneButton,
title = state.sideEffect.message,
okButtonClick = onDismiss,
onDismissRequest = { },
)

SideEffect.Redirect -> onNavigate()
}
}
}

0 comments on commit 95f7346

Please sign in to comment.