Skip to content

Commit

Permalink
[System] DialogScreen 고도화 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajou4095 authored Jan 23, 2024
1 parent 26ce0bc commit f19e5fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package ac.dnd.bookkeeping.android.presentation.common.util

import ac.dnd.bookkeeping.android.presentation.R
import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.eventObserve
import ac.dnd.bookkeeping.android.presentation.common.view.DialogScreen
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
Expand All @@ -22,15 +26,22 @@ import kotlin.coroutines.EmptyCoroutineContext
fun ErrorObserver(
viewModel: BaseViewModel
) {
val dialogIsShowingState = remember { mutableStateOf(false) }
DialogScreen(dialogIsShowingState)
var isDialogShowing by remember { mutableStateOf(false) }

DialogScreen(
isShowing = isDialogShowing,
title = stringResource(id = R.string.error_dialog_title),
onDismissRequest = {
isDialogShowing = false
}
)

LaunchedEffectWithLifecycle(viewModel.errorEvent) {
viewModel.errorEvent.eventObserve { event ->
Timber.d(event.throwable)
Sentry.captureException(event.throwable)

dialogIsShowingState.value = true
isDialogShowing = true
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<string name="dialog_confirm">확인</string>
<string name="dialog_cancel">취소</string>

<string name="error_dialog_title">앗, 에러가 발생했어요!</string>

<string name="setting_dialog_title">테스트</string>

</resources>

0 comments on commit f19e5fc

Please sign in to comment.