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 7001e041..e50f578f 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 @@ -28,13 +28,14 @@ fun ErrorObserver( ) { var isDialogShowing by remember { mutableStateOf(false) } - DialogScreen( - isShowing = isDialogShowing, - title = stringResource(id = R.string.error_dialog_title), - onDismissRequest = { - isDialogShowing = false - } - ) + if (isDialogShowing) { + DialogScreen( + title = stringResource(id = R.string.error_dialog_title), + onDismissRequest = { + isDialogShowing = false + } + ) + } LaunchedEffectWithLifecycle(viewModel.errorEvent) { viewModel.errorEvent.eventObserve { event -> diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/DialogScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/DialogScreen.kt index 38588a26..c3d7885a 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/DialogScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/DialogScreen.kt @@ -16,10 +16,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Card import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -33,7 +29,6 @@ import androidx.compose.ui.window.DialogProperties @Composable fun DialogScreen( - isShowing: Boolean, isCancelable: Boolean = true, title: String = "", message: String = "", @@ -43,84 +38,81 @@ fun DialogScreen( onCancel: (() -> Unit)? = null, onDismissRequest: (() -> Unit), ) { - - if (isShowing) { - Dialog( - properties = DialogProperties( - dismissOnBackPress = isCancelable, - dismissOnClickOutside = isCancelable - ), - onDismissRequest = { - onDismissRequest() - } + Dialog( + properties = DialogProperties( + dismissOnBackPress = isCancelable, + dismissOnClickOutside = isCancelable + ), + onDismissRequest = { + onDismissRequest() + } + ) { + Card( + backgroundColor = Color.White, + shape = RoundedCornerShape(10.dp) ) { - Card( - backgroundColor = Color.White, - shape = RoundedCornerShape(10.dp) + Column( + modifier = Modifier + .wrapContentSize() + .padding(top = 25.dp, start = 20.dp, end = 20.dp, bottom = 20.dp), + horizontalAlignment = Alignment.CenterHorizontally ) { - Column( - modifier = Modifier - .wrapContentSize() - .padding(top = 25.dp, start = 20.dp, end = 20.dp, bottom = 20.dp), - horizontalAlignment = Alignment.CenterHorizontally - ) { - Text( - text = title, - fontSize = 24.sp, - color = Color.Black - ) - - if (message.isNotEmpty()) { - Spacer(modifier = Modifier.height(15.dp)) + Text( + text = title, + fontSize = 24.sp, + color = Color.Black + ) - Text( - text = message, - fontSize = 16.sp, - color = Color.Black, - textAlign = TextAlign.Center - ) - } - - Spacer(modifier = Modifier.height(20.dp)) + if (message.isNotEmpty()) { + Spacer(modifier = Modifier.height(15.dp)) - Row(modifier = Modifier.wrapContentSize()) { - if (onCancel != null) { - ConfirmButton( - properties = ConfirmButtonProperties( - size = ConfirmButtonSize.Large, - type = ConfirmButtonType.Secondary - ), - modifier = Modifier.weight(1f), - onClick = { - onCancel() - onDismissRequest() - } - ) { style -> - Text( - text = cancelMessage, - style = style - ) - } + Text( + text = message, + fontSize = 16.sp, + color = Color.Black, + textAlign = TextAlign.Center + ) + } - Spacer(modifier = Modifier.width(10.dp)) - } + Spacer(modifier = Modifier.height(20.dp)) + Row(modifier = Modifier.wrapContentSize()) { + if (onCancel != null) { ConfirmButton( properties = ConfirmButtonProperties( size = ConfirmButtonSize.Large, - type = ConfirmButtonType.Primary + type = ConfirmButtonType.Secondary ), modifier = Modifier.weight(1f), onClick = { - onConfirm() + onCancel() onDismissRequest() } ) { style -> Text( - text = confirmMessage, + text = cancelMessage, style = style ) } + + Spacer(modifier = Modifier.width(10.dp)) + } + + ConfirmButton( + properties = ConfirmButtonProperties( + size = ConfirmButtonSize.Large, + type = ConfirmButtonType.Primary + ), + modifier = Modifier.weight(1f), + onClick = { + onConfirm() + onDismissRequest() + } + ) { style -> + Text( + text = confirmMessage, + style = style + ) } } } @@ -131,29 +123,19 @@ fun DialogScreen( @Preview @Composable fun DialogScreenPreview1() { - var isShowing by remember { mutableStateOf(true) } - DialogScreen( - isShowing = isShowing, title = "제목", message = "내용\n여러줄 넘어가면 이렇게 됨.\n가가가가가가가가가가가가가가가가가가가가가가가", onCancel = {}, - onDismissRequest = { - isShowing = false - } + onDismissRequest = {} ) } @Preview @Composable fun DialogScreenPreview2() { - var isShowing by remember { mutableStateOf(true) } - DialogScreen( - isShowing = isShowing, title = "제목", - onDismissRequest = { - isShowing = false - } + onDismissRequest = {} ) } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/setting/SettingScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/setting/SettingScreen.kt index ae2e8b73..21474780 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/setting/SettingScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/setting/SettingScreen.kt @@ -241,13 +241,15 @@ fun SettingScreen( } } } - DialogScreen( - isShowing = isDialogShowing, - title = stringResource(R.string.setting_dialog_title), - message = stringResource(R.string.setting_dialog_message), - onCancel = {}, - onDismissRequest = { isDialogShowing = false } - ) + + if (isDialogShowing) { + DialogScreen( + title = stringResource(R.string.setting_dialog_title), + message = stringResource(R.string.setting_dialog_message), + onCancel = {}, + onDismissRequest = { isDialogShowing = false } + ) + } } @Composable diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainScreen.kt index a16e69a7..b9b499a5 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainScreen.kt @@ -127,13 +127,14 @@ fun LoginMainScreen( } } - DialogScreen( - isShowing = isDialogShowing, - title = stringResource(R.string.login_main_dialog_message), - onDismissRequest = { - isDialogShowing = false - } - ) + if (isDialogShowing) { + DialogScreen( + title = stringResource(R.string.login_main_dialog_message), + onDismissRequest = { + isDialogShowing = false + } + ) + } LaunchedEffectWithLifecycle(event, handler) { event.eventObserve { event -> diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/registration/main/RegistrationMainScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/registration/main/RegistrationMainScreen.kt index ef7d4d3c..79383982 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/registration/main/RegistrationMainScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/registration/main/RegistrationMainScreen.kt @@ -25,7 +25,6 @@ import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingTextF import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingTextFieldType import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState import ac.dnd.bookkeeping.android.presentation.ui.main.home.HomeConstant -import ac.dnd.bookkeeping.android.presentation.ui.main.login.LoginConstant import ac.dnd.bookkeeping.android.presentation.ui.main.registration.main.component.ErrorUserNamingComponent import ac.dnd.bookkeeping.android.presentation.ui.main.registration.main.component.RegistraionUserDate import ac.dnd.bookkeeping.android.presentation.ui.main.registration.main.type.RegistrationMainNamingErrorType @@ -314,7 +313,9 @@ fun RegistrationNamingScreen( } Spacer(modifier = Modifier.width(12.dp)) Button( - modifier = Modifier.weight(1f).height(48.dp), + modifier = Modifier + .weight(1f) + .height(48.dp), shape = Shapes.large, colors = ButtonDefaults.textButtonColors( backgroundColor = if (userGender == UserGender.FEMALE) Primary1 else Gray000 @@ -388,13 +389,14 @@ fun RegistrationNamingScreen( } } - DialogScreen( - isShowing = isDialogShowing, - title = "회원 가입에 실패하였습니다.", - onDismissRequest = { - isDialogShowing = false - } - ) + if (isDialogShowing) { + DialogScreen( + title = "회원 가입에 실패하였습니다.", + onDismissRequest = { + isDialogShowing = false + } + ) + } LaunchedEffectWithLifecycle(event, handler) { event.eventObserve { event ->