From 2aaf2ac51d2488b7fcc96ac31315748c4d7831e7 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 19 Jan 2024 16:38:29 +0900 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20#105=20:=20=EC=84=A4=EB=AC=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EB=B2=84=ED=8A=BC=20=EB=88=84=EB=A5=BC=20?= =?UTF-8?q?=EC=8B=9C=20=EC=82=AD=EC=A0=9C=20=EB=8B=A4=EC=9D=B4=EC=96=BC?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EA=B0=80=20=EB=82=98=EC=98=A4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/event/edit/EventEditScreen.kt | 8 +- .../survey/edit/SurveyFormEditScreen.kt | 131 +++++++++++++++++- .../src/main/res/values/strings.xml | 2 + 3 files changed, 136 insertions(+), 5 deletions(-) diff --git a/feature/management-event/src/main/java/com/wap/wapp/feature/management/event/edit/EventEditScreen.kt b/feature/management-event/src/main/java/com/wap/wapp/feature/management/event/edit/EventEditScreen.kt index 5bbff9dbd..6687d38ce 100644 --- a/feature/management-event/src/main/java/com/wap/wapp/feature/management/event/edit/EventEditScreen.kt +++ b/feature/management-event/src/main/java/com/wap/wapp/feature/management/event/edit/EventEditScreen.kt @@ -154,7 +154,7 @@ internal fun EventEditScreen( var showStartTimePicker by remember { mutableStateOf(false) } var showEndDatePicker by remember { mutableStateOf(false) } var showEndTimePicker by remember { mutableStateOf(false) } - var showDeleteDialog by remember { mutableStateOf(false) } + var showDeleteEventDialog by remember { mutableStateOf(false) } val timePickerState = rememberTimePickerState() Scaffold( @@ -164,10 +164,10 @@ internal fun EventEditScreen( contentWindowInsets = WindowInsets(0.dp), ) { paddingValues -> - if (showDeleteDialog) { + if (showDeleteEventDialog) { DeleteEventDialog( deleteEvent = deleteEvent, - onDismissRequest = { showDeleteDialog = false }, + onDismissRequest = { showDeleteEventDialog = false }, ) } @@ -182,7 +182,7 @@ internal fun EventEditScreen( showLeftButton = true, showRightButton = true, onClickLeftButton = onBackButtonClicked, - onClickRightButton = { showDeleteDialog = true }, + onClickRightButton = { showDeleteEventDialog = true }, ) EventEditStateIndicator( diff --git a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditScreen.kt b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditScreen.kt index fd44886e8..4765338d9 100644 --- a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditScreen.kt +++ b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditScreen.kt @@ -1,14 +1,24 @@ package com.wap.wapp.feature.management.survey.edit +import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Text import androidx.compose.material3.rememberTimePickerState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -17,8 +27,18 @@ 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.draw.clip +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogProperties import androidx.hilt.navigation.compose.hiltViewModel import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappSubTopBar @@ -50,6 +70,7 @@ internal fun SurveyFormEditScreen( val timePickerState = rememberTimePickerState() var showDatePicker by remember { mutableStateOf(false) } var showTimePicker by remember { mutableStateOf(false) } + var showDeleteSurveyDialog by remember { mutableStateOf(false) } LaunchedEffect(true) { viewModel.getSurveyForm(surveyFormId) @@ -86,6 +107,13 @@ internal fun SurveyFormEditScreen( .padding(16.dp), // dp value padding verticalArrangement = Arrangement.spacedBy(32.dp), ) { + if (showDeleteSurveyDialog) { + DeleteSurveyDialog( + deleteSurvey = viewModel::deleteSurveyForm, + onDismissRequest = { showDeleteSurveyDialog = false }, + ) + } + Column( verticalArrangement = Arrangement.spacedBy(16.dp), ) { @@ -94,7 +122,7 @@ internal fun SurveyFormEditScreen( showLeftButton = true, showRightButton = true, onClickLeftButton = navigateToManagement, - onClickRightButton = viewModel::deleteSurveyForm, + onClickRightButton = { showDeleteSurveyDialog = true }, ) SurveyFormStateIndicator( @@ -154,3 +182,104 @@ internal fun SurveyFormEditScreen( } } } + +@Composable +private fun DeleteSurveyDialog( + deleteSurvey: () -> Unit, + onDismissRequest: () -> Unit, +) { + Dialog( + onDismissRequest = onDismissRequest, + properties = DialogProperties( + usePlatformDefaultWidth = false, + ), + ) { + Column( + verticalArrangement = Arrangement.spacedBy(16.dp), + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .wrapContentSize() + .padding(horizontal = 30.dp) + .clip(RoundedCornerShape(8.dp)) + .background(WappTheme.colors.black25), + ) { + Text( + text = stringResource(id = R.string.delete_survey), + style = WappTheme.typography.contentBold.copy(fontSize = 20.sp), + color = WappTheme.colors.yellow34, + modifier = Modifier.padding(top = 16.dp), + ) + + Divider( + color = WappTheme.colors.gray82, + modifier = Modifier.padding(horizontal = 12.dp), + ) + + Text( + text = generateDialogContentString(), + style = WappTheme.typography.contentRegular, + color = WappTheme.colors.white, + modifier = Modifier.padding(top = 12.dp, start = 12.dp, end = 12.dp), + ) + + Row( + horizontalArrangement = Arrangement.spacedBy(20.dp), + modifier = Modifier.padding(horizontal = 12.dp, vertical = 16.dp), + ) { + Button( + onClick = { + deleteSurvey() + onDismissRequest() + }, + shape = RoundedCornerShape(8.dp), + colors = ButtonDefaults.buttonColors( + containerColor = WappTheme.colors.yellow34, + ), + contentPadding = PaddingValues(vertical = 12.dp), + modifier = Modifier.weight(1f), + ) { + Text( + text = stringResource(id = R.string.complete), + style = WappTheme.typography.titleRegular, + color = WappTheme.colors.black, + ) + } + + Button( + onClick = onDismissRequest, + shape = RoundedCornerShape(10.dp), + colors = ButtonDefaults.buttonColors( + containerColor = WappTheme.colors.black25, + ), + contentPadding = PaddingValues(vertical = 12.dp), + modifier = Modifier + .weight(1f) + .border( + width = 1.dp, + color = WappTheme.colors.yellow34, + shape = RoundedCornerShape(8.dp), + ), + ) { + Text( + text = stringResource(R.string.cancel), + style = WappTheme.typography.titleRegular, + color = WappTheme.colors.yellow34, + ) + } + } + } + } +} + +@Composable +private fun generateDialogContentString() = buildAnnotatedString { + append("정말로 해당 설문을 삭제하시겠습니까?\n") + withStyle( + style = SpanStyle( + textDecoration = TextDecoration.Underline, + color = WappTheme.colors.yellow34, + ), + ) { + append("해당 설문과 관련된 답변들이 모두 삭제됩니다.") + } +} diff --git a/feature/management-survey/src/main/res/values/strings.xml b/feature/management-survey/src/main/res/values/strings.xml index 4cc913c5f..c3a3b3470 100644 --- a/feature/management-survey/src/main/res/values/strings.xml +++ b/feature/management-survey/src/main/res/values/strings.xml @@ -6,7 +6,9 @@ / 4 문항 추가 설문 등록하기 + 설문 삭제 취소 + 완료 선택 설문 기간 설정 설문의 마감 기한을 설정하세요.