Skip to content

Commit

Permalink
[Setting] DialogScreen isShowing 제거 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajou4095 authored Feb 4, 2024
1 parent 0414d69 commit 2a3acf0
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +29,6 @@ import androidx.compose.ui.window.DialogProperties

@Composable
fun DialogScreen(
isShowing: Boolean,
isCancelable: Boolean = true,
title: String = "",
message: String = "",
Expand All @@ -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
)
}
}
}
Expand All @@ -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 = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down

0 comments on commit 2a3acf0

Please sign in to comment.