Skip to content

Commit

Permalink
[FEATURE] #105 : 설문 삭제 버튼 누를 시 삭제 다이얼로그가 나오도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Jan 19, 2024
1 parent 53f55b4 commit 2aaf2ac
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 },
)
}

Expand All @@ -182,7 +182,7 @@ internal fun EventEditScreen(
showLeftButton = true,
showRightButton = true,
onClickLeftButton = onBackButtonClicked,
onClickRightButton = { showDeleteDialog = true },
onClickRightButton = { showDeleteEventDialog = true },
)

EventEditStateIndicator(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
) {
Expand All @@ -94,7 +122,7 @@ internal fun SurveyFormEditScreen(
showLeftButton = true,
showRightButton = true,
onClickLeftButton = navigateToManagement,
onClickRightButton = viewModel::deleteSurveyForm,
onClickRightButton = { showDeleteSurveyDialog = true },
)

SurveyFormStateIndicator(
Expand Down Expand Up @@ -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("해당 설문과 관련된 답변들이 모두 삭제됩니다.")
}
}
2 changes: 2 additions & 0 deletions feature/management-survey/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<string name="survey_registration_total_page">/ 4</string>
<string name="add_survey_question">문항 추가</string>
<string name="register_survey">설문 등록하기</string>
<string name="delete_survey">설문 삭제</string>
<string name="cancel">취소</string>
<string name="complete">완료</string>
<string name="select">선택</string>
<string name="survey_deadline_title">설문 기간 설정</string>
<string name="survey_deadline_content">설문의 마감 기한을 설정하세요.</string>
Expand Down

0 comments on commit 2aaf2ac

Please sign in to comment.