-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE]#155 : SideEffectState 및 SideEffect에 따른 처리 컴포넌트 구현
- Loading branch information
1 parent
5176524
commit 95f7346
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
core/ui/src/main/kotlin/com/bff/wespot/model/SideEffectState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
35
core/ui/src/main/kotlin/com/bff/wespot/ui/SideEffectHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |