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

[Setting] DialogScreen isShowing 제거 #43

Merged
merged 1 commit into from
Feb 4, 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
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 @@ -218,13 +218,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
Loading