Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[System] DialogScreen 고도화 #10

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>