From f19e5fc7be294729741ee1e7d91e5ec5bf21e25f Mon Sep 17 00:00:00 2001 From: Ray Jang <48707913+ajou4095@users.noreply.github.com> Date: Wed, 24 Jan 2024 01:57:27 +0900 Subject: [PATCH] =?UTF-8?q?[System]=20DialogScreen=20=EA=B3=A0=EB=8F=84?= =?UTF-8?q?=ED=99=94=20(#10)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/common/util/ComposeUtil.kt | 17 ++++++++++++++--- presentation/src/main/res/values/strings.xml | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/ComposeUtil.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/ComposeUtil.kt index dc486129..7001e041 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/ComposeUtil.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/ComposeUtil.kt @@ -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 @@ -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 } } } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 8f8b0669..cf65dd35 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -5,6 +5,8 @@ 확인 취소 + 앗, 에러가 발생했어요! + 테스트