From 2e8b297812788467dba0ca4f9140a68bcc6bb284 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 28 Dec 2023 23:57:30 +0900 Subject: [PATCH 01/31] =?UTF-8?q?[FEATURE]=20#69=20:=20TimePicker=20?= =?UTF-8?q?=EC=BB=A4=EC=8A=A4=ED=85=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/core/commmon/util/DateUtil.kt | 4 ++ .../survey/deadline/SurveyDeadlineContent.kt | 65 +++++++++++++------ .../wap/wapp/feature/profile/ProfileScreen.kt | 2 +- .../wap/wapp/feature/survey/SurveyScreen.kt | 2 +- 4 files changed, 52 insertions(+), 21 deletions(-) diff --git a/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt b/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt index d9c5ecb5..029ebc4a 100644 --- a/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt +++ b/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt @@ -1,6 +1,7 @@ package com.wap.wapp.core.commmon.util import java.time.LocalDate +import java.time.LocalDateTime import java.time.ZoneId import java.time.format.DateTimeFormatter @@ -8,6 +9,9 @@ object DateUtil { fun generateNowDate(zoneId: ZoneId = ZoneId.of("Asia/Seoul")): LocalDate = LocalDate.now(zoneId) + fun generateNowDateTime(zoneId: ZoneId = ZoneId.of("Asia/Seoul")): LocalDateTime = + LocalDateTime.now(zoneId) + const val YEAR_MONTH_START_INDEX = 0 const val YEAR_MONTH_END_INDEX = 7 const val MONTH_DATE_START_INDEX = 5 diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index ac2ceac8..8d3ddffc 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -1,5 +1,6 @@ package com.wap.wapp.feature.management.registration.survey.deadline +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -15,11 +16,13 @@ import androidx.compose.material3.DatePickerState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text import androidx.compose.material3.TextButton -import androidx.compose.material3.TimeInput +import androidx.compose.material3.TimePicker +import androidx.compose.material3.TimePickerDefaults import androidx.compose.material3.TimePickerState import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp @@ -175,30 +178,54 @@ private fun TimePickerDialog( onDismissRequest = onDismissRequest, ) { Card { - Column { - TimeInput( - modifier = Modifier.padding(16.dp), + Column(modifier = Modifier.background(WappTheme.colors.black25)) { + TimePicker( state = state, + colors = TimePickerDefaults.colors( + selectorColor = WappTheme.colors.yellow34, + clockDialSelectedContentColor = WappTheme.colors.black25, + clockDialUnselectedContentColor = WappTheme.colors.gray95, + clockDialColor = WappTheme.colors.black25, + periodSelectorBorderColor = Color.Transparent, + timeSelectorSelectedContainerColor = WappTheme.colors.yellow34, + timeSelectorUnselectedContainerColor = WappTheme.colors.black25, + timeSelectorSelectedContentColor = WappTheme.colors.black25, + timeSelectorUnselectedContentColor = WappTheme.colors.gray95, + periodSelectorSelectedContentColor = WappTheme.colors.black25, + periodSelectorUnselectedContentColor = WappTheme.colors.gray95, + periodSelectorSelectedContainerColor = WappTheme.colors.yellow34, + periodSelectorUnselectedContainerColor = WappTheme.colors.black25, + ), + modifier = Modifier.padding(16.dp), ) Row( - modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End, + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 20.dp), ) { - TextButton( - onClick = onDismissButtonClicked, - ) { - Text(stringResource(R.string.cancel)) - } - TextButton( - onClick = { - onConfirmButtonClicked( - LocalTime.of(state.hour, state.minute), - ) - }, - ) { - Text(stringResource(R.string.select)) - } + Text( + stringResource(R.string.cancel), + color = WappTheme.colors.grayBD, + style = WappTheme.typography.contentBold, + modifier = Modifier + .padding(end = 30.dp) + .clickable { onDismissButtonClicked() }, + ) + + Text( + stringResource(R.string.select), + color = WappTheme.colors.grayBD, + style = WappTheme.typography.contentBold, + modifier = Modifier + .padding(end = 20.dp) + .clickable { + onConfirmButtonClicked( + LocalTime.of(state.hour, state.minute), + ) + }, + ) } } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 33a60a53..4d41134a 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -44,7 +44,7 @@ internal fun ProfileRoute( @Composable internal fun ProfileScreen( - role: Role = Role.GUEST, + role: Role = Role.MANAGER, userName: String = "", eventsState: ProfileViewModel.EventsState, navigateToProfileSetting: () -> Unit, diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt index 1b4d76f1..0b4be248 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt @@ -157,7 +157,7 @@ private fun SurveyFormItemCard( } private fun calculateDeadline(deadline: LocalDateTime): String { - val currentDateTime = DateUtil.generateNowDate() + val currentDateTime = DateUtil.generateNowDateTime() val duration = Duration.between(currentDateTime, deadline) if (duration.toMinutes() < 60) { From 19ea0a1abc8c462d978fbca54f6f0ae9e787f786 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 00:14:29 +0900 Subject: [PATCH 02/31] =?UTF-8?q?[CHORE]=20#69=20:=20TimePickerDialog=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/TimePickerDialog.kt | 90 +++++++++++++++++++ .../survey/deadline/SurveyDeadlineContent.kt | 72 +-------------- 2 files changed, 91 insertions(+), 71 deletions(-) create mode 100644 feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/TimePickerDialog.kt diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/TimePickerDialog.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/TimePickerDialog.kt new file mode 100644 index 00000000..c0410061 --- /dev/null +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/TimePickerDialog.kt @@ -0,0 +1,90 @@ +package com.wap.wapp.feature.management.registration.component + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Card +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Text +import androidx.compose.material3.TimePicker +import androidx.compose.material3.TimePickerDefaults +import androidx.compose.material3.TimePickerState +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Dialog +import com.wap.designsystem.WappTheme +import com.wap.wapp.feature.management.R +import java.time.LocalTime + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +internal fun TimePickerDialog( + state: TimePickerState, + onDismissRequest: () -> Unit, + onConfirmButtonClicked: (LocalTime) -> Unit, + onDismissButtonClicked: () -> Unit, +) { + Dialog( + onDismissRequest = onDismissRequest, + ) { + Card { + Column(modifier = Modifier.background(WappTheme.colors.black25)) { + TimePicker( + state = state, + colors = TimePickerDefaults.colors( + selectorColor = WappTheme.colors.yellow34, + clockDialSelectedContentColor = WappTheme.colors.black25, + clockDialUnselectedContentColor = WappTheme.colors.gray95, + clockDialColor = WappTheme.colors.black25, + periodSelectorBorderColor = Color.Transparent, + timeSelectorSelectedContainerColor = WappTheme.colors.yellow34, + timeSelectorUnselectedContainerColor = WappTheme.colors.black25, + timeSelectorSelectedContentColor = WappTheme.colors.black25, + timeSelectorUnselectedContentColor = WappTheme.colors.gray95, + periodSelectorSelectedContentColor = WappTheme.colors.black25, + periodSelectorUnselectedContentColor = WappTheme.colors.gray95, + periodSelectorSelectedContainerColor = WappTheme.colors.yellow34, + periodSelectorUnselectedContainerColor = WappTheme.colors.black25, + ), + modifier = Modifier.padding(16.dp), + ) + + Row( + horizontalArrangement = Arrangement.End, + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 20.dp), + ) { + Text( + text = stringResource(R.string.cancel), + color = WappTheme.colors.grayBD, + style = WappTheme.typography.contentBold, + modifier = Modifier + .padding(end = 30.dp) + .clickable { onDismissButtonClicked() }, + ) + + Text( + stringResource(R.string.select), + color = WappTheme.colors.grayBD, + style = WappTheme.typography.contentBold, + modifier = Modifier + .padding(end = 20.dp) + .clickable { + onConfirmButtonClicked( + LocalTime.of(state.hour, state.minute), + ) + }, + ) + } + } + } + } +} diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index 8d3ddffc..74b4ad57 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -1,6 +1,5 @@ package com.wap.wapp.feature.management.registration.survey.deadline -import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -16,21 +15,18 @@ import androidx.compose.material3.DatePickerState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text import androidx.compose.material3.TextButton -import androidx.compose.material3.TimePicker -import androidx.compose.material3.TimePickerDefaults import androidx.compose.material3.TimePickerState import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Dialog import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappButton import com.wap.designsystem.component.WappTitle import com.wap.wapp.feature.management.R +import com.wap.wapp.feature.management.registration.component.TimePickerDialog import java.time.Instant import java.time.LocalDate import java.time.LocalTime @@ -166,72 +162,6 @@ private fun SurveyDeadlineCard( } } -@OptIn(ExperimentalMaterial3Api::class) -@Composable -private fun TimePickerDialog( - state: TimePickerState, - onDismissRequest: () -> Unit, - onConfirmButtonClicked: (LocalTime) -> Unit, - onDismissButtonClicked: () -> Unit, -) { - Dialog( - onDismissRequest = onDismissRequest, - ) { - Card { - Column(modifier = Modifier.background(WappTheme.colors.black25)) { - TimePicker( - state = state, - colors = TimePickerDefaults.colors( - selectorColor = WappTheme.colors.yellow34, - clockDialSelectedContentColor = WappTheme.colors.black25, - clockDialUnselectedContentColor = WappTheme.colors.gray95, - clockDialColor = WappTheme.colors.black25, - periodSelectorBorderColor = Color.Transparent, - timeSelectorSelectedContainerColor = WappTheme.colors.yellow34, - timeSelectorUnselectedContainerColor = WappTheme.colors.black25, - timeSelectorSelectedContentColor = WappTheme.colors.black25, - timeSelectorUnselectedContentColor = WappTheme.colors.gray95, - periodSelectorSelectedContentColor = WappTheme.colors.black25, - periodSelectorUnselectedContentColor = WappTheme.colors.gray95, - periodSelectorSelectedContainerColor = WappTheme.colors.yellow34, - periodSelectorUnselectedContainerColor = WappTheme.colors.black25, - ), - modifier = Modifier.padding(16.dp), - ) - - Row( - horizontalArrangement = Arrangement.End, - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 20.dp), - ) { - Text( - stringResource(R.string.cancel), - color = WappTheme.colors.grayBD, - style = WappTheme.typography.contentBold, - modifier = Modifier - .padding(end = 30.dp) - .clickable { onDismissButtonClicked() }, - ) - - Text( - stringResource(R.string.select), - color = WappTheme.colors.grayBD, - style = WappTheme.typography.contentBold, - modifier = Modifier - .padding(end = 20.dp) - .clickable { - onConfirmButtonClicked( - LocalTime.of(state.hour, state.minute), - ) - }, - ) - } - } - } - } -} - private fun Long.toLocalDate(): LocalDate { val instant = Instant.ofEpochMilli(this) val instantAtSeoul = instant.atZone(ZoneId.of("Asia/Seoul")) From a6307fa2d6b5bee0ed12051b99059e4fe91e4273 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 00:26:27 +0900 Subject: [PATCH 03/31] =?UTF-8?q?[FEATURE]=20#69=20:=20DatePickerDialog=20?= =?UTF-8?q?=EC=BA=98=EB=A6=B0=EB=8D=94=20=EC=9D=B4=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/WappDatePickerDialog.kt | 248 ++++++++++++++++++ ...ickerDialog.kt => WappTimePickerDialog.kt} | 2 +- .../survey/deadline/SurveyDeadlineContent.kt | 4 +- .../src/main/res/values/strings.xml | 2 + 4 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt rename feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/{TimePickerDialog.kt => WappTimePickerDialog.kt} (99%) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt new file mode 100644 index 00000000..9c56d2f4 --- /dev/null +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt @@ -0,0 +1,248 @@ +package com.wap.wapp.feature.management.registration.component + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.items +import androidx.compose.foundation.lazy.grid.itemsIndexed +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import com.wap.designsystem.WappTheme +import com.wap.wapp.core.commmon.util.DateUtil +import com.wap.wapp.feature.management.R +import java.time.DayOfWeek +import java.time.LocalDate +import java.time.format.TextStyle +import java.util.Locale + +@Composable +internal fun WappDatePickerDialog( + selectedDate: LocalDate, + onDateSelected: (LocalDate) -> Unit, +) { + Column { + CalendarHeader( + selectedDate = selectedDate, + onDateSelected = onDateSelected, + ) + CalendarBody( + selectedDate = selectedDate, + onDateSelected = onDateSelected, + ) + } +} + +@Composable +private fun CalendarHeader( + selectedDate: LocalDate, + onDateSelected: (LocalDate) -> Unit, +) = Box { + val date = selectedDate.format(DateUtil.yyyyMMddFormatter) + + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.align(Alignment.Center), + ) { + Image( + painter = painterResource(id = com.wap.wapp.core.designresource.R.drawable.ic_back), + contentDescription = stringResource(id = R.string.backMonthArrowContentDescription), + modifier = Modifier + .padding(end = 20.dp) + .clickable { onDateSelected(selectedDate.minusMonths(1)) }, + ) + + Text( + text = date.substring( + DateUtil.YEAR_MONTH_START_INDEX, + DateUtil.YEAR_MONTH_END_INDEX, + ), + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + ) + + Image( + painter = painterResource(id = com.wap.wapp.core.designresource.R.drawable.ic_forward), + contentDescription = stringResource(id = R.string.forwardMonthArrowContentDescription), + modifier = Modifier + .padding(start = 20.dp) + .clickable { onDateSelected(selectedDate.plusMonths(1)) }, + ) + } +} + +@Composable +private fun CalendarBody( + selectedDate: LocalDate, + onDateSelected: (LocalDate) -> Unit, +) { + DayOfWeek() + CalendarMonthItem( + selectedDate = selectedDate, + onDateSelected = onDateSelected, + ) +} + +@Composable +private fun DayOfWeek(modifier: Modifier = Modifier) { + Row(modifier = modifier) { + DateUtil.DaysOfWeek.values().forEach { dayOfWeek -> + val textColor = when (dayOfWeek) { + DateUtil.DaysOfWeek.SATURDAY -> WappTheme.colors.blueA3 + DateUtil.DaysOfWeek.SUNDAY -> WappTheme.colors.red + else -> WappTheme.colors.white + } + + Text( + text = dayOfWeek.displayName, + textAlign = TextAlign.Center, + color = textColor, + modifier = Modifier + .weight(1f) + .padding(vertical = 10.dp), + ) + } + } +} + +@Composable +private fun CalendarMonthItem( + selectedDate: LocalDate, + onDateSelected: (LocalDate) -> Unit, +) { + LazyVerticalGrid( + columns = GridCells.Fixed(DateUtil.DAYS_IN_WEEK), + modifier = Modifier.fillMaxWidth(), + ) { + val visibleDaysFromLastMonth = calculateVisibleDaysFromLastMonth(selectedDate) + val beforeMonthDaysToShow = generateBeforeMonthDaysToShow( + visibleDaysFromLastMonth, + selectedDate, + ) + itemsIndexed(beforeMonthDaysToShow) { index, day -> + CalendarDayText( + text = day.toString(), + color = getDayColor(index + 1).copy(alpha = ALPHA_DIM), + ) + } + + val thisMonthLastDate = selectedDate.lengthOfMonth() + val thisMonthFirstDayOfWeek = selectedDate.withDayOfMonth(1).dayOfWeek + val thisMonthDaysToShow: List = (1..thisMonthLastDate).toList() + items(thisMonthDaysToShow) { day -> + val date = selectedDate.withDayOfMonth(day) + val currentLocalDate = LocalDate.of( + selectedDate.year, + selectedDate.month, + day, + ) + + val isSelected = (day == selectedDate.dayOfMonth) + CalendarDayText( + text = DateUtil.ddFormatter.format(date), + color = getDayColor(day + thisMonthFirstDayOfWeek.value), + isSelected = isSelected, + modifier = Modifier.clickable { onDateSelected(currentLocalDate) }, + ) + } + + val remainingDays = + DateUtil.DAYS_IN_WEEK - (visibleDaysFromLastMonth + thisMonthDaysToShow.size) % + DateUtil.DAYS_IN_WEEK + val nextMonthDaysToShow = IntRange(1, remainingDays).toList() + items(nextMonthDaysToShow) { day -> + CalendarDayText( + text = day.toString(), + color = + getDayColor(visibleDaysFromLastMonth + thisMonthDaysToShow.size + day) + .copy(alpha = ALPHA_DIM), + ) + } + } +} + +@Composable +private fun CalendarDayText( + text: String, + color: Color, + isSelected: Boolean = false, + modifier: Modifier = Modifier, +) { + var columnModifier = modifier + .padding( + horizontal = 10.dp, + vertical = 5.dp, + ) + + if (isSelected) { + columnModifier = columnModifier.background( + color = WappTheme.colors.gray82.copy(alpha = 0.4F), + shape = RoundedCornerShape(5.dp), + ) + } + + columnModifier = columnModifier.padding(vertical = 5.dp) + + Column( + modifier = columnModifier, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Box( + contentAlignment = Alignment.Center, + ) { + Text( + text = text, + textAlign = TextAlign.Center, + color = color, + ) + } + } +} + +@Composable +private fun getDayColor(day: Int): Color = when (day % DateUtil.DAYS_IN_WEEK) { + SUNDAY -> WappTheme.colors.red + SATURDAY -> WappTheme.colors.blueA3 + else -> WappTheme.colors.white +} + +private fun generateBeforeMonthDaysToShow( + visibleDaysFromLastMonth: Int, + currentDate: LocalDate, +): List { + val beforeMonth = currentDate.minusMonths(1) + val beforeMonthLastDay = beforeMonth.lengthOfMonth() + return IntRange(beforeMonthLastDay - visibleDaysFromLastMonth + 1, beforeMonthLastDay).toList() +} + +private fun calculateVisibleDaysFromLastMonth(currentDate: LocalDate): Int { + val firstDayOfWeek: DayOfWeek = currentDate.withDayOfMonth(1).dayOfWeek + + var count = 0 + for (day in DateUtil.DaysOfWeek.values()) { + if (day.name == firstDayOfWeek.getDisplayName(TextStyle.FULL, Locale.US).uppercase()) { + break + } + count += 1 + } + + return count +} + +private const val ALPHA_DIM = 0.3F +private const val SUNDAY = 1 +private const val SATURDAY = 0 diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/TimePickerDialog.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappTimePickerDialog.kt similarity index 99% rename from feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/TimePickerDialog.kt rename to feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappTimePickerDialog.kt index c0410061..2c0e6768 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/TimePickerDialog.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappTimePickerDialog.kt @@ -25,7 +25,7 @@ import java.time.LocalTime @OptIn(ExperimentalMaterial3Api::class) @Composable -internal fun TimePickerDialog( +internal fun WappTimePickerDialog( state: TimePickerState, onDismissRequest: () -> Unit, onConfirmButtonClicked: (LocalTime) -> Unit, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index 74b4ad57..f615b3f8 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -26,7 +26,7 @@ import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappButton import com.wap.designsystem.component.WappTitle import com.wap.wapp.feature.management.R -import com.wap.wapp.feature.management.registration.component.TimePickerDialog +import com.wap.wapp.feature.management.registration.component.WappTimePickerDialog import java.time.Instant import java.time.LocalDate import java.time.LocalTime @@ -75,7 +75,7 @@ internal fun SurveyDeadlineContent( } if (showTimePicker) { - TimePickerDialog( + WappTimePickerDialog( state = timePickerState, onDismissRequest = { onTimePickerStateChanged(false) }, onConfirmButtonClicked = { localTime -> diff --git a/feature/management/src/main/res/values/strings.xml b/feature/management/src/main/res/values/strings.xml index 1d0cb6f5..3844aca5 100644 --- a/feature/management/src/main/res/values/strings.xml +++ b/feature/management/src/main/res/values/strings.xml @@ -61,4 +61,6 @@ 설문 확인 이름 다음 + "이전 달을 보여주는 화살표 입니다." + "다음 달을 보여주는 화살표 입니다." From c90a3845b3e6d7c309ceb74ae319de9286bc9b1e Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 01:09:59 +0900 Subject: [PATCH 04/31] =?UTF-8?q?[FEATURE]=20#69=20:=20DatePickerDialog=20?= =?UTF-8?q?=EC=BA=98=EB=A6=B0=EB=8D=94=20UI=20=EB=B3=B4=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/WappDatePickerDialog.kt | 72 ++++++++++++++----- .../component/WappTimePickerDialog.kt | 3 +- .../survey/deadline/SurveyDeadlineContent.kt | 30 ++------ 3 files changed, 62 insertions(+), 43 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt index 9c56d2f4..35bbd90c 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt @@ -3,16 +3,19 @@ package com.wap.wapp.feature.management.registration.component import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.grid.itemsIndexed import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Card import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -22,6 +25,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Dialog import com.wap.designsystem.WappTheme import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.feature.management.R @@ -32,18 +36,56 @@ import java.util.Locale @Composable internal fun WappDatePickerDialog( - selectedDate: LocalDate, + selectedDate: LocalDate = DateUtil.generateNowDate(), onDateSelected: (LocalDate) -> Unit, + onDismissRequest: () -> Unit, + onConfirmButtonClicked: () -> Unit, ) { - Column { - CalendarHeader( - selectedDate = selectedDate, - onDateSelected = onDateSelected, - ) - CalendarBody( - selectedDate = selectedDate, - onDateSelected = onDateSelected, - ) + Dialog( + onDismissRequest = onDismissRequest, + ) { + Card(shape = RoundedCornerShape(10.dp)) { + Column( + modifier = Modifier + .wrapContentSize() + .background(color = WappTheme.colors.black25) + .padding(10.dp), + ) { + CalendarHeader( + selectedDate = selectedDate, + onDateSelected = onDateSelected, + ) + CalendarBody( + selectedDate = selectedDate, + onDateSelected = onDateSelected, + ) + + Row( + horizontalArrangement = Arrangement.End, + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 20.dp), + ) { + Text( + text = stringResource(R.string.cancel), + color = WappTheme.colors.grayBD, + style = WappTheme.typography.contentBold, + modifier = Modifier + .padding(end = 30.dp) + .clickable { onDismissRequest() }, + ) + + Text( + stringResource(R.string.select), + color = WappTheme.colors.grayBD, + style = WappTheme.typography.contentBold, + modifier = Modifier + .padding(end = 20.dp) + .clickable { onConfirmButtonClicked() }, + ) + } + } + } } } @@ -51,7 +93,7 @@ internal fun WappDatePickerDialog( private fun CalendarHeader( selectedDate: LocalDate, onDateSelected: (LocalDate) -> Unit, -) = Box { +) = Box(modifier = Modifier.fillMaxWidth()) { val date = selectedDate.format(DateUtil.yyyyMMddFormatter) Row( @@ -182,11 +224,7 @@ private fun CalendarDayText( isSelected: Boolean = false, modifier: Modifier = Modifier, ) { - var columnModifier = modifier - .padding( - horizontal = 10.dp, - vertical = 5.dp, - ) + var columnModifier = modifier.padding(5.dp) if (isSelected) { columnModifier = columnModifier.background( @@ -195,7 +233,7 @@ private fun CalendarDayText( ) } - columnModifier = columnModifier.padding(vertical = 5.dp) + columnModifier = columnModifier.padding(5.dp) Column( modifier = columnModifier, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappTimePickerDialog.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappTimePickerDialog.kt index 2c0e6768..98339193 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappTimePickerDialog.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappTimePickerDialog.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text @@ -34,7 +35,7 @@ internal fun WappTimePickerDialog( Dialog( onDismissRequest = onDismissRequest, ) { - Card { + Card(shape = RoundedCornerShape(10.dp)) { Column(modifier = Modifier.background(WappTheme.colors.black25)) { TimePicker( state = state, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index f615b3f8..8c5d90b9 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -9,12 +9,9 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults -import androidx.compose.material3.DatePicker -import androidx.compose.material3.DatePickerDialog import androidx.compose.material3.DatePickerState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text -import androidx.compose.material3.TextButton import androidx.compose.material3.TimePickerState import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -26,6 +23,7 @@ import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappButton import com.wap.designsystem.component.WappTitle import com.wap.wapp.feature.management.R +import com.wap.wapp.feature.management.registration.component.WappDatePickerDialog import com.wap.wapp.feature.management.registration.component.WappTimePickerDialog import java.time.Instant import java.time.LocalDate @@ -49,29 +47,11 @@ internal fun SurveyDeadlineContent( onRegisterButtonClicked: () -> Unit, ) { if (showDatePicker) { - DatePickerDialog( + WappDatePickerDialog( onDismissRequest = { onDatePickerStateChanged(false) }, - confirmButton = { - TextButton( - onClick = { - val selectedDateMillis = datePickerState.selectedDateMillis - if (selectedDateMillis != null) { - onDateChanged( - selectedDateMillis.toLocalDate(), - ) - } - onDatePickerStateChanged(false) - }, - ) { Text(stringResource(id = R.string.select)) } - }, - dismissButton = { - TextButton( - onClick = { onDatePickerStateChanged(false) }, - ) { Text(stringResource(id = R.string.cancel)) } - }, - ) { - DatePicker(state = datePickerState) - } + onConfirmButtonClicked = {}, + onDateSelected = {}, + ) } if (showTimePicker) { From f6d90d0049773016674bbcfe9a22b01c8c161d93 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 01:20:25 +0900 Subject: [PATCH 05/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=84=A4=EB=AC=B8?= =?UTF-8?q?=EC=A1=B0=EC=82=AC=20=EB=93=B1=EB=A1=9D=20UI=20=EB=B3=B4?= =?UTF-8?q?=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../survey/deadline/SurveyDeadlineContent.kt | 2 ++ .../survey/information/SurveyInformationContent.kt | 6 +++++- .../survey/question/SurveyQuestionContent.kt | 10 +++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index 8c5d90b9..9c066e6b 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.DatePickerState @@ -122,6 +123,7 @@ private fun SurveyDeadlineCard( ) Card( + shape = RoundedCornerShape(10.dp), modifier = Modifier .weight(3f) .clickable { onCardClicked() }, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/information/SurveyInformationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/information/SurveyInformationContent.kt index d0e965fb..74ffcbfa 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/information/SurveyInformationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/information/SurveyInformationContent.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Text @@ -48,7 +49,9 @@ internal fun SurveyInformationContent( value = title, onValueChange = onTitleChanged, placeholder = stringResource(R.string.survey_title_hint), - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .padding(top = 10.dp) + .fillMaxWidth(), ) } @@ -65,6 +68,7 @@ internal fun SurveyInformationContent( onValueChange = onContentChanged, placeholder = stringResource(R.string.survey_introduce_hint), modifier = Modifier + .padding(top = 10.dp) .fillMaxWidth() .height(200.dp), ) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/question/SurveyQuestionContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/question/SurveyQuestionContent.kt index 89db3432..e42e45ee 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/question/SurveyQuestionContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/question/SurveyQuestionContent.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults @@ -84,6 +85,7 @@ internal fun SurveyQuestionContent( value = question, onValueChange = onQuestionChanged, modifier = Modifier + .padding(top = 10.dp) .fillMaxWidth() .height(200.dp), placeholder = stringResource(R.string.suvey_question_hint), @@ -145,7 +147,9 @@ private fun SurveyQuestionTypeDescription( QuestionType.OBJECTIVE -> { Column( verticalArrangement = Arrangement.spacedBy(16.dp), - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .padding(top = 20.dp) + .fillMaxWidth(), ) { SurveyQuestionTypeCard( title = stringResource(R.string.good), @@ -200,8 +204,8 @@ private fun SurveyQuestionTypeCard( content: String, ) { Card( - modifier = Modifier - .fillMaxWidth(), + shape = RoundedCornerShape(10.dp), + modifier = Modifier.fillMaxWidth(), colors = CardDefaults.cardColors( containerColor = WappTheme.colors.black25, ), From b0806c4b137a31c8d5ee1a49513f88f092deb5d6 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 01:25:48 +0900 Subject: [PATCH 06/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20UI=20=EB=B3=B4=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/management/ManagementEventContent.kt | 1 + .../feature/management/ManagementSurveyContent.kt | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt index 13b1b64b..ade44e05 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt @@ -94,6 +94,7 @@ private fun ManagementEventItem( onCardClicked: (Int) -> Unit, ) { Card( + shape = RoundedCornerShape(10.dp), modifier = Modifier .fillMaxSize() .clickable { onCardClicked(item.eventId) }, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementSurveyContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementSurveyContent.kt index 00b28210..17ab9386 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementSurveyContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementSurveyContent.kt @@ -100,6 +100,7 @@ private fun ManagementSurveyItem( onCardClicked: (String) -> Unit, ) { Card( + shape = RoundedCornerShape(10.dp), modifier = Modifier .fillMaxSize() .clickable { onCardClicked(item.surveyId) }, @@ -108,14 +109,16 @@ private fun ManagementSurveyItem( Row( modifier = Modifier .fillMaxSize() - .padding(16.dp), + .padding(10.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween, ) { Column( - modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(16.dp), - horizontalAlignment = Alignment.CenterHorizontally, + horizontalAlignment = Alignment.Start, + modifier = Modifier + .weight(1f) + .padding(start = 10.dp), ) { Text( text = item.surveyAnswerList.first().questionAnswer, @@ -125,8 +128,9 @@ private fun ManagementSurveyItem( ) Row( - horizontalArrangement = Arrangement.spacedBy(10.dp), + horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth(), ) { SurveyCaption(item.eventName, WappTheme.colors.white) From 7a7e3b849cb676379e2a0864ea5739c46149491c Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 02:14:00 +0900 Subject: [PATCH 07/31] =?UTF-8?q?[FEATURE]=20#69=20:=20WappDatePickerDialo?= =?UTF-8?q?g=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/core/commmon/util/DateUtil.kt | 3 +++ .../component/WappDatePickerDialog.kt | 23 ++++++++++++------- .../survey/SurveyRegistrationContent.kt | 9 +++----- .../survey/SurveyRegistrationScreen.kt | 5 +--- .../survey/SurveyRegistrationViewModel.kt | 8 +++---- .../survey/deadline/SurveyDeadlineContent.kt | 6 ++--- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt b/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt index 029ebc4a..1a502e2e 100644 --- a/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt +++ b/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt @@ -2,11 +2,14 @@ package com.wap.wapp.core.commmon.util import java.time.LocalDate import java.time.LocalDateTime +import java.time.LocalTime import java.time.ZoneId import java.time.format.DateTimeFormatter object DateUtil { + fun generateNowTime(zoneId: ZoneId = ZoneId.of("Asia/Seoul")): LocalTime = LocalTime.now(zoneId) + fun generateNowDate(zoneId: ZoneId = ZoneId.of("Asia/Seoul")): LocalDate = LocalDate.now(zoneId) fun generateNowDateTime(zoneId: ZoneId = ZoneId.of("Asia/Seoul")): LocalDateTime = diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt index 35bbd90c..a27d4b41 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt @@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items @@ -18,6 +17,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.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 @@ -36,10 +39,9 @@ import java.util.Locale @Composable internal fun WappDatePickerDialog( - selectedDate: LocalDate = DateUtil.generateNowDate(), - onDateSelected: (LocalDate) -> Unit, + date: LocalDate, + onDateChanged: (LocalDate) -> Unit, onDismissRequest: () -> Unit, - onConfirmButtonClicked: () -> Unit, ) { Dialog( onDismissRequest = onDismissRequest, @@ -47,17 +49,19 @@ internal fun WappDatePickerDialog( Card(shape = RoundedCornerShape(10.dp)) { Column( modifier = Modifier - .wrapContentSize() + .fillMaxWidth() .background(color = WappTheme.colors.black25) .padding(10.dp), ) { + var selectedDate by remember { mutableStateOf(date) } + CalendarHeader( selectedDate = selectedDate, - onDateSelected = onDateSelected, + onDateSelected = { date -> selectedDate = date }, ) CalendarBody( selectedDate = selectedDate, - onDateSelected = onDateSelected, + onDateSelected = { date -> selectedDate = date }, ) Row( @@ -81,7 +85,10 @@ internal fun WappDatePickerDialog( style = WappTheme.typography.contentBold, modifier = Modifier .padding(end = 20.dp) - .clickable { onConfirmButtonClicked() }, + .clickable { + onDateChanged(selectedDate) + onDismissRequest() + }, ) } } diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationContent.kt index 0360060d..3ade9cec 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationContent.kt @@ -1,6 +1,5 @@ package com.wap.wapp.feature.management.registration.survey -import androidx.compose.material3.DatePickerState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.TimePickerState import androidx.compose.runtime.Composable @@ -27,10 +26,10 @@ internal fun SurveyRegistrationContent( date: LocalDate, currentQuestionIndex: Int, totalQuestionSize: Int, - datePickerState: DatePickerState, timePickerState: TimePickerState, showDatePicker: Boolean, showTimePicker: Boolean, + onDateChanged: (LocalDate) -> Unit, onDatePickerStateChanged: (Boolean) -> Unit, onTimePickerStateChanged: (Boolean) -> Unit, onEventListChanged: () -> Unit, @@ -39,7 +38,6 @@ internal fun SurveyRegistrationContent( onContentChanged: (String) -> Unit, onQuestionChanged: (String) -> Unit, onQuestionTypeChanged: (QuestionType) -> Unit, - onDateChanged: (LocalDate) -> Unit, onTimeChanged: (LocalTime) -> Unit, onNextButtonClicked: (SurveyRegistrationState) -> Unit, onAddQuestionButtonClicked: () -> Unit, @@ -86,15 +84,14 @@ internal fun SurveyRegistrationContent( SurveyDeadlineContent( time = time, date = date, - datePickerState = datePickerState, timePickerState = timePickerState, showDatePicker = showDatePicker, showTimePicker = showTimePicker, - onDatePickerStateChanged = onDatePickerStateChanged, - onTimePickerStateChanged = onTimePickerStateChanged, onDateChanged = onDateChanged, + onTimePickerStateChanged = onTimePickerStateChanged, onTimeChanged = onTimeChanged, onRegisterButtonClicked = onRegisterButtonClicked, + onDatePickerStateChanged = onDatePickerStateChanged, ) } } diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationScreen.kt index 802e79ac..9aa623fd 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationScreen.kt @@ -13,7 +13,6 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Text -import androidx.compose.material3.rememberDatePickerState import androidx.compose.material3.rememberTimePickerState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -91,7 +90,6 @@ internal fun SurveyRegistrationScreen( onBackButtonClicked: () -> Unit, ) { val snackBarHostState = remember { SnackbarHostState() } - val datePickerState = rememberDatePickerState() val timePickerState = rememberTimePickerState() var showDatePicker by remember { mutableStateOf(false) } var showTimePicker by remember { mutableStateOf(false) } @@ -150,7 +148,6 @@ internal fun SurveyRegistrationScreen( questionType = questionType, date = date, time = time, - datePickerState = datePickerState, timePickerState = timePickerState, showDatePicker = showDatePicker, showTimePicker = showTimePicker, @@ -166,7 +163,7 @@ internal fun SurveyRegistrationScreen( onQuestionTypeChanged = { questionType -> viewModel.setSurveyQuestionType(questionType) }, - onDateChanged = { localDate -> viewModel.setSurveyDateDeadline(localDate) }, + onDateChanged = viewModel::setSurveyDateDeadline, onTimeChanged = { localTime -> viewModel.setSurveyTimeDeadline(localTime) }, onNextButtonClicked = { surveyRegistrationState -> viewModel.setSurveyRegistrationState(surveyRegistrationState) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt index 123b98b9..d21354bd 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt @@ -55,10 +55,12 @@ class SurveyRegistrationViewModel @Inject constructor( MutableStateFlow(mutableListOf()) val surveyQuestionList = _surveyQuestionList.asStateFlow() - private val _surveyTimeDeadline: MutableStateFlow = MutableStateFlow(LOCAL_TIME_INIT) + private val _surveyTimeDeadline: MutableStateFlow = + MutableStateFlow(DateUtil.generateNowTime()) val surveyTimeDeadline = _surveyTimeDeadline.asStateFlow() - private val _surveyDateDeadline: MutableStateFlow = MutableStateFlow(LOCAL_DATE_INIT) + private val _surveyDateDeadline: MutableStateFlow = + MutableStateFlow(DateUtil.generateNowDate()) val surveyDateDeadline = _surveyDateDeadline.asStateFlow() // Content 전환 함수, 전환 전 내용 검증 @@ -207,8 +209,6 @@ class SurveyRegistrationViewModel @Inject constructor( companion object { const val EMPTY = "" - val LOCAL_TIME_INIT: LocalTime = LocalTime.now() - val LOCAL_DATE_INIT: LocalDate = LocalDate.now() val EVENT_SELECTION_INIT: Event = Event("", -1, "", LocalDate.now(), "") } } diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index 9c066e6b..3cc12ebe 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults -import androidx.compose.material3.DatePickerState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text import androidx.compose.material3.TimePickerState @@ -37,7 +36,6 @@ import java.time.format.DateTimeFormatter internal fun SurveyDeadlineContent( date: LocalDate, time: LocalTime, - datePickerState: DatePickerState, timePickerState: TimePickerState, showDatePicker: Boolean, showTimePicker: Boolean, @@ -49,9 +47,9 @@ internal fun SurveyDeadlineContent( ) { if (showDatePicker) { WappDatePickerDialog( + date = date, onDismissRequest = { onDatePickerStateChanged(false) }, - onConfirmButtonClicked = {}, - onDateSelected = {}, + onDateChanged = onDateChanged, ) } From 41fe35a9395d314e634cd855e2131132e7d71710 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 02:29:48 +0900 Subject: [PATCH 08/31] =?UTF-8?q?[FEATURE]=20#69=20:=20DeadLineCard=20?= =?UTF-8?q?=EC=9E=AC=EC=82=AC=EC=9A=A9=20=ED=95=A0=20=EC=88=98=20=EC=9E=88?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../registration/component/DeadlineCard.kt | 55 ++++++++++++++++++ .../survey/deadline/SurveyDeadlineContent.kt | 57 ++----------------- 2 files changed, 59 insertions(+), 53 deletions(-) create mode 100644 feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/DeadlineCard.kt diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/DeadlineCard.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/DeadlineCard.kt new file mode 100644 index 00000000..aa712e12 --- /dev/null +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/DeadlineCard.kt @@ -0,0 +1,55 @@ +package com.wap.wapp.feature.management.registration.component + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import com.wap.designsystem.WappTheme + +@Composable +internal fun DeadlineCard( + title: String, + hint: String, + onCardClicked: () -> Unit, +) { + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = title, + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + textAlign = TextAlign.Start, + modifier = Modifier.weight(2f), + ) + + Card( + shape = RoundedCornerShape(10.dp), + modifier = Modifier + .weight(3f) + .clickable { onCardClicked() }, + colors = CardDefaults.cardColors( + containerColor = WappTheme.colors.black25, + ), + ) { + Text( + text = hint, + style = WappTheme.typography.contentMedium, + color = WappTheme.colors.white, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(vertical = 8.dp) + .fillMaxWidth(), + ) + } + } +} diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index 3cc12ebe..1a852578 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -1,28 +1,18 @@ package com.wap.wapp.feature.management.registration.survey.deadline -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Card -import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Text import androidx.compose.material3.TimePickerState import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappButton import com.wap.designsystem.component.WappTitle import com.wap.wapp.feature.management.R +import com.wap.wapp.feature.management.registration.component.DeadlineCard import com.wap.wapp.feature.management.registration.component.WappDatePickerDialog import com.wap.wapp.feature.management.registration.component.WappTimePickerDialog import java.time.Instant @@ -77,9 +67,9 @@ internal fun SurveyDeadlineContent( ) Column( - verticalArrangement = Arrangement.spacedBy(16.dp), + verticalArrangement = Arrangement.spacedBy(20.dp), ) { - SurveyDeadlineCard( + DeadlineCard( title = stringResource(R.string.date), hint = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), onCardClicked = { @@ -87,7 +77,7 @@ internal fun SurveyDeadlineContent( }, ) - SurveyDeadlineCard( + DeadlineCard( title = stringResource(R.string.time), hint = time.format(DateTimeFormatter.ofPattern("HH.mm")), onCardClicked = { @@ -103,45 +93,6 @@ internal fun SurveyDeadlineContent( } } -@Composable -private fun SurveyDeadlineCard( - title: String, - hint: String, - onCardClicked: () -> Unit, -) { - Row( - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - text = title, - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, - textAlign = TextAlign.Start, - modifier = Modifier.weight(2f), - ) - - Card( - shape = RoundedCornerShape(10.dp), - modifier = Modifier - .weight(3f) - .clickable { onCardClicked() }, - colors = CardDefaults.cardColors( - containerColor = WappTheme.colors.black25, - ), - ) { - Text( - text = hint, - style = WappTheme.typography.contentMedium, - color = WappTheme.colors.white, - textAlign = TextAlign.Center, - modifier = Modifier - .padding(vertical = 8.dp) - .fillMaxWidth(), - ) - } - } -} - private fun Long.toLocalDate(): LocalDate { val instant = Instant.ofEpochMilli(this) val instantAtSeoul = instant.atZone(ZoneId.of("Asia/Seoul")) From 7462c96e341431b933b17cefd37f992a5b42358f Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 02:34:00 +0900 Subject: [PATCH 09/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=84=A4=EB=AC=B8?= =?UTF-8?q?=EC=A1=B0=EC=82=AC=20=EB=93=B1=EB=A1=9D=20UI=20=EB=B3=B4?= =?UTF-8?q?=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../registration/component/DeadlineCard.kt | 2 ++ .../survey/deadline/SurveyDeadlineContent.kt | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/DeadlineCard.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/DeadlineCard.kt index aa712e12..d8da3e10 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/DeadlineCard.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/DeadlineCard.kt @@ -20,9 +20,11 @@ internal fun DeadlineCard( title: String, hint: String, onCardClicked: () -> Unit, + modifier: Modifier = Modifier, ) { Row( verticalAlignment = Alignment.CenterVertically, + modifier = modifier, ) { Text( text = title, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index 1a852578..23c73286 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -3,6 +3,7 @@ package com.wap.wapp.feature.management.registration.survey.deadline import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.TimePickerState import androidx.compose.runtime.Composable @@ -61,20 +62,22 @@ internal fun SurveyDeadlineContent( verticalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxSize(), ) { - WappTitle( - title = stringResource(R.string.survey_deadline_title), - content = stringResource(R.string.survey_deadline_content), - ) - Column( verticalArrangement = Arrangement.spacedBy(20.dp), + modifier = Modifier.weight(1f), ) { + WappTitle( + title = stringResource(R.string.survey_deadline_title), + content = stringResource(R.string.survey_deadline_content), + ) + DeadlineCard( title = stringResource(R.string.date), hint = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), onCardClicked = { onDatePickerStateChanged(true) }, + modifier = Modifier.padding(top = 40.dp), ) DeadlineCard( @@ -83,12 +86,14 @@ internal fun SurveyDeadlineContent( onCardClicked = { onTimePickerStateChanged(true) }, + modifier = Modifier.padding(top = 20.dp), ) } WappButton( textRes = R.string.register_survey, onClick = onRegisterButtonClicked, + modifier = Modifier.padding(bottom = 20.dp), ) } } From 3dd2a56fe87da3e9e4c73f4463bfcf35dad3655b Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 03:23:58 +0900 Subject: [PATCH 10/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=9D=BC=EC=A0=95?= =?UTF-8?q?=20=EB=93=B1=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EB=8C=80=EA=B3=B5?= =?UTF-8?q?=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/event/EventRepository.kt | 4 +- .../repository/event/EventRepositoryImpl.kt | 8 +- ...ventUseCase.kt => RegisterEventUseCase.kt} | 11 +- .../com/wap/wapp/core/model/event/Event.kt | 5 +- .../core/network/model/event/EventRequest.kt | 3 +- .../core/network/model/event/EventResponse.kt | 8 +- .../management/ManagementEventContent.kt | 2 +- .../event/EventRegistrationContent.kt | 143 ++++++++++++------ .../event/EventRegistrationScreen.kt | 60 +++++--- .../event/EventRegistrationViewModel.kt | 19 ++- .../survey/SurveyRegistrationViewModel.kt | 2 +- .../wapp/feature/notice/BottomSheetContent.kt | 4 +- .../com/wap/wapp/feature/notice/Calendar.kt | 2 +- .../wapp/feature/notice/NoticeViewModel.kt | 6 +- .../wapp/feature/profile/ProfileViewModel.kt | 6 +- 15 files changed, 178 insertions(+), 105 deletions(-) rename core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/{PostEventUseCase.kt => RegisterEventUseCase.kt} (72%) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt index 9f54bb6e..bbb377d7 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt @@ -2,6 +2,7 @@ package com.wap.wapp.core.data.repository.event import com.wap.wapp.core.model.event.Event import java.time.LocalDate +import java.time.LocalDateTime interface EventRepository { suspend fun getMonthEvents(date: LocalDate): Result> @@ -11,7 +12,6 @@ interface EventRepository { eventTitle: String, eventContent: String, eventLocation: String, - eventDate: String, - eventTime: String, + eventDateTime: LocalDateTime, ): Result } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index 4d33bb3e..0a84a0ae 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -4,6 +4,8 @@ import com.wap.wapp.core.model.event.Event import com.wap.wapp.core.network.model.event.EventRequest import com.wap.wapp.core.network.source.event.EventDataSource import java.time.LocalDate +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter import javax.inject.Inject class EventRepositoryImpl @Inject constructor( @@ -21,8 +23,7 @@ class EventRepositoryImpl @Inject constructor( eventTitle: String, eventContent: String, eventLocation: String, - eventDate: String, - eventTime: String, + eventDateTime: LocalDateTime, ): Result = eventDataSource.postEvent( date = date, @@ -30,8 +31,7 @@ class EventRepositoryImpl @Inject constructor( title = eventTitle, content = eventContent, location = eventLocation, - period = eventDate, - time = eventTime, + dateTime = eventDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), ), ) } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/PostEventUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/RegisterEventUseCase.kt similarity index 72% rename from core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/PostEventUseCase.kt rename to core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/RegisterEventUseCase.kt index 85741211..5922d769 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/PostEventUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/RegisterEventUseCase.kt @@ -2,9 +2,11 @@ package com.wap.wapp.core.domain.usecase.event import com.wap.wapp.core.data.repository.event.EventRepository import java.time.LocalDate +import java.time.LocalDateTime +import java.time.LocalTime import javax.inject.Inject -class PostEventUseCase @Inject constructor( +class RegisterEventUseCase @Inject constructor( private val eventRepository: EventRepository, ) { suspend operator fun invoke( @@ -12,16 +14,15 @@ class PostEventUseCase @Inject constructor( eventTitle: String, eventContent: String, eventLocation: String, - eventDate: String, - eventTime: String, + eventDate: LocalDate, + eventTime: LocalTime, ): Result = runCatching { eventRepository.postEvent( date = date, eventTitle = eventTitle, eventContent = eventContent, eventLocation = eventLocation, - eventDate = eventDate, - eventTime = eventTime, + eventDateTime = LocalDateTime.of(eventDate, eventTime), ) } } diff --git a/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt b/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt index 52b3366d..fdf538d0 100644 --- a/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt +++ b/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt @@ -1,12 +1,11 @@ package com.wap.wapp.core.model.event -import java.time.LocalDate +import java.time.LocalDateTime data class Event( val content: String, val eventId: Int, val location: String, - val period: LocalDate, val title: String, - val time: String = "", + val dateTime: LocalDateTime, ) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt index acedfd76..9fa584ef 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt @@ -4,7 +4,6 @@ data class EventRequest( val title: String = "", val content: String = "", val location: String = "", - val period: String = "", - val time: String = "", + val dateTime: String = "", val eventId: Int = 0, ) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt index 3669d6fe..d6112709 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt @@ -1,16 +1,15 @@ package com.wap.wapp.core.network.model.event import com.wap.wapp.core.model.event.Event -import java.time.LocalDate +import com.wap.wapp.core.network.utils.toISOLocalDateTime import java.time.format.DateTimeFormatter data class EventResponse( val content: String = "", val eventId: Int = 0, val location: String = "", - val period: String = "", val title: String = "", - val time: String = "", + val dateTime: String = "", ) { private val formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd") @@ -19,7 +18,6 @@ data class EventResponse( eventId = eventId, location = location, title = title, - period = LocalDate.parse(this.period, formatter), - time = time, + dateTime = dateTime.toISOLocalDateTime(), ) } diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt index ade44e05..4901c4b4 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt @@ -120,7 +120,7 @@ private fun ManagementEventItem( ) Text( - text = item.period.toString(), + text = item.dateTime.toString(), style = WappTheme.typography.captionMedium, color = WappTheme.colors.white, maxLines = 1, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt index 25982524..4d44ba75 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt @@ -2,35 +2,52 @@ package com.wap.wapp.feature.management.registration.event import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text +import androidx.compose.material3.TimePickerState import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappButton import com.wap.wapp.feature.management.R +import com.wap.wapp.feature.management.registration.component.DeadlineCard import com.wap.wapp.feature.management.registration.component.RegistrationTextField import com.wap.wapp.feature.management.registration.component.RegistrationTitle +import com.wap.wapp.feature.management.registration.component.WappDatePickerDialog +import com.wap.wapp.feature.management.registration.component.WappTimePickerDialog +import java.time.LocalDate +import java.time.LocalTime +import java.time.format.DateTimeFormatter +@OptIn(ExperimentalMaterial3Api::class) @Composable internal fun EventRegistrationContent( eventRegistrationState: EventRegistrationState, modifier: Modifier = Modifier, eventTitle: String, eventContent: String, - eventLocation: String, - eventDate: String, - eventTime: String, + location: String, + date: LocalDate, + time: LocalTime, + showDatePicker: Boolean, + showTimePicker: Boolean, + timePickerState: TimePickerState, onTitleChanged: (String) -> Unit, onContentChanged: (String) -> Unit, onLocationChanged: (String) -> Unit, - onDateChanged: (String) -> Unit, - onTimeChanged: (String) -> Unit, + onDateChanged: (LocalDate) -> Unit, + onTimeChanged: (LocalTime) -> Unit, + onDatePickerStateChanged: (Boolean) -> Unit, + onTimePickerStateChanged: (Boolean) -> Unit, onNextButtonClicked: (EventRegistrationState) -> Unit, onRegisterButtonClicked: () -> Unit, ) { @@ -46,12 +63,17 @@ internal fun EventRegistrationContent( ) EventRegistrationState.EVENT_SCHEDULE -> EventScheduleContent( - eventLocation = eventLocation, - eventDate = eventDate, - eventTime = eventTime, + location = location, + date = date, + time = time, + timePickerState = timePickerState, onLocationChanged = onLocationChanged, onDateChanged = onDateChanged, onTimeChanged = onTimeChanged, + showDatePicker = showDatePicker, + showTimePicker = showTimePicker, + onDatePickerStateChanged = onDatePickerStateChanged, + onTimePickerStateChanged = onTimePickerStateChanged, onNextButtonClicked = onRegisterButtonClicked, ) } @@ -116,16 +138,44 @@ private fun EventDetailsContent( } } +@OptIn(ExperimentalMaterial3Api::class) @Composable private fun EventScheduleContent( - eventLocation: String, - eventDate: String, - eventTime: String, + location: String, + date: LocalDate, + time: LocalTime, + timePickerState: TimePickerState, + showDatePicker: Boolean, + showTimePicker: Boolean, + onDatePickerStateChanged: (Boolean) -> Unit, + onTimePickerStateChanged: (Boolean) -> Unit, onLocationChanged: (String) -> Unit, - onDateChanged: (String) -> Unit, - onTimeChanged: (String) -> Unit, + onDateChanged: (LocalDate) -> Unit, + onTimeChanged: (LocalTime) -> Unit, onNextButtonClicked: () -> Unit, ) { + if (showDatePicker) { + WappDatePickerDialog( + date = date, + onDismissRequest = { onDatePickerStateChanged(false) }, + onDateChanged = onDateChanged, + ) + } + + if (showTimePicker) { + WappTimePickerDialog( + state = timePickerState, + onDismissRequest = { onTimePickerStateChanged(false) }, + onConfirmButtonClicked = { localTime -> + onTimeChanged(localTime) + onTimePickerStateChanged(false) + }, + onDismissButtonClicked = { + onTimePickerStateChanged(false) + }, + ) + } + RegistrationTitle( title = stringResource(id = R.string.event_schedule_title), content = stringResource(id = R.string.event_schedule_content), @@ -137,45 +187,42 @@ private fun EventScheduleContent( .padding(top = 50.dp) .weight(1f), ) { - Text( - text = stringResource(R.string.event_location), - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, - ) + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.padding(40.dp), + ) { + Text( + text = stringResource(R.string.event_location), + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + textAlign = TextAlign.Start, + modifier = Modifier.weight(2f), + ) - RegistrationTextField( - value = eventLocation, - onValueChange = onLocationChanged, - placeholder = stringResource(R.string.event_location_hint), - modifier = Modifier.fillMaxWidth(), - ) + RegistrationTextField( + value = location, + onValueChange = onLocationChanged, + placeholder = stringResource(R.string.event_location_hint), + modifier = Modifier.fillMaxWidth(), + ) + } - Text( - text = stringResource(R.string.event_date), - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, - modifier = Modifier.padding(top = 30.dp), - ) - - RegistrationTextField( - value = eventDate, - onValueChange = onDateChanged, - placeholder = stringResource(R.string.event_date_hint), - modifier = Modifier.fillMaxWidth(), - ) - - Text( - text = stringResource(R.string.event_time), - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, - modifier = Modifier.padding(top = 30.dp), + DeadlineCard( + title = stringResource(R.string.date), + hint = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), + onCardClicked = { + onDatePickerStateChanged(true) + }, + modifier = Modifier.padding(top = 40.dp), ) - RegistrationTextField( - value = eventTime, - onValueChange = onTimeChanged, - placeholder = stringResource(R.string.event_time_hint), - modifier = Modifier.fillMaxWidth(), + DeadlineCard( + title = stringResource(R.string.time), + hint = time.format(DateTimeFormatter.ofPattern("HH.mm")), + onCardClicked = { + onTimePickerStateChanged(true) + }, + modifier = Modifier.padding(top = 20.dp), ) } diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt index b93f9498..af4d084c 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt @@ -7,14 +7,18 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.LinearProgressIndicator 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.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.StrokeCap @@ -25,7 +29,10 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappTopBar import com.wap.wapp.feature.management.R +import java.time.LocalDate +import java.time.LocalTime +@OptIn(ExperimentalMaterial3Api::class) @Composable internal fun EventRegistrationRoute( viewModel: EventRegistrationViewModel = hiltViewModel(), @@ -33,11 +40,11 @@ internal fun EventRegistrationRoute( ) { val currentRegistrationState by viewModel.currentRegistrationState.collectAsStateWithLifecycle() - val eventTitle by viewModel.eventTitle.collectAsStateWithLifecycle() - val eventContent by viewModel.eventContent.collectAsStateWithLifecycle() - val eventLocation by viewModel.eventLocation.collectAsStateWithLifecycle() - val eventDate by viewModel.eventDate.collectAsStateWithLifecycle() - val eventTime by viewModel.eventTime.collectAsStateWithLifecycle() + val title by viewModel.eventTitle.collectAsStateWithLifecycle() + val content by viewModel.eventContent.collectAsStateWithLifecycle() + val location by viewModel.eventLocation.collectAsStateWithLifecycle() + val date by viewModel.eventDate.collectAsStateWithLifecycle() + val time by viewModel.eventTime.collectAsStateWithLifecycle() val onTitleChanged = viewModel::setEventTitle val onContentChanged = viewModel::setEventContent val onLocationChanged = viewModel::setEventLocation @@ -49,11 +56,11 @@ internal fun EventRegistrationRoute( EventRegistrationScreen( currentRegistrationState = currentRegistrationState, - eventTitle = eventTitle, - eventContent = eventContent, - eventLocation = eventLocation, - eventDate = eventDate, - eventTime = eventTime, + title = title, + content = content, + location = location, + date = date, + time = time, onTitleChanged = onTitleChanged, onContentChanged = onContentChanged, onLocationChanged = onLocationChanged, @@ -68,24 +75,28 @@ internal fun EventRegistrationRoute( ) } +@OptIn(ExperimentalMaterial3Api::class) @Composable internal fun EventRegistrationScreen( currentRegistrationState: EventRegistrationState, - eventTitle: String, - eventContent: String, - eventLocation: String, - eventDate: String, - eventTime: String, + title: String, + content: String, + location: String, + date: LocalDate, + time: LocalTime, onTitleChanged: (String) -> Unit, onContentChanged: (String) -> Unit, onLocationChanged: (String) -> Unit, - onDateChanged: (String) -> Unit, - onTimeChanged: (String) -> Unit, + onDateChanged: (LocalDate) -> Unit, + onTimeChanged: (LocalTime) -> Unit, onNextButtonClicked: (EventRegistrationState) -> Unit, onRegisterButtonClicked: () -> Unit, onBackButtonClicked: () -> Unit, ) { val snackBarHostState = remember { SnackbarHostState() } + var showDatePicker by remember { mutableStateOf(false) } + var showTimePicker by remember { mutableStateOf(false) } + val timePickerState = rememberTimePickerState() Scaffold( snackbarHost = { SnackbarHost(snackBarHostState) }, @@ -112,16 +123,21 @@ internal fun EventRegistrationScreen( EventRegistrationContent( eventRegistrationState = currentRegistrationState, modifier = Modifier.padding(top = 50.dp), - eventTitle = eventTitle, - eventContent = eventContent, - eventLocation = eventLocation, - eventDate = eventDate, - eventTime = eventTime, + eventTitle = title, + eventContent = content, + location = location, + date = date, + time = time, + showDatePicker = showDatePicker, + showTimePicker = showTimePicker, onTitleChanged = onTitleChanged, onContentChanged = onContentChanged, onLocationChanged = onLocationChanged, + timePickerState = timePickerState, onDateChanged = onDateChanged, onTimeChanged = onTimeChanged, + onDatePickerStateChanged = { state -> showDatePicker = state }, + onTimePickerStateChanged = { state -> showTimePicker = state }, onNextButtonClicked = onNextButtonClicked, onRegisterButtonClicked = onRegisterButtonClicked, ) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt index 8642accd..a45896c7 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt @@ -2,17 +2,20 @@ package com.wap.wapp.feature.management.registration.event import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.commmon.util.DateUtil.generateNowDate -import com.wap.wapp.core.domain.usecase.event.PostEventUseCase +import com.wap.wapp.core.domain.usecase.event.RegisterEventUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import java.time.LocalDate +import java.time.LocalTime import javax.inject.Inject @HiltViewModel class EventRegistrationViewModel @Inject constructor( - private val postEventUseCase: PostEventUseCase, + private val registerEventUseCase: RegisterEventUseCase, ) : ViewModel() { private val _currentRegistrationState: MutableStateFlow = MutableStateFlow(EventRegistrationState.EVENT_DETAILS) @@ -27,10 +30,12 @@ class EventRegistrationViewModel @Inject constructor( private val _eventLocation: MutableStateFlow = MutableStateFlow("") val eventLocation = _eventLocation.asStateFlow() - private val _eventDate: MutableStateFlow = MutableStateFlow("") + private val _eventDate: MutableStateFlow = + MutableStateFlow(DateUtil.generateNowDate()) val eventDate = _eventDate.asStateFlow() - private val _eventTime: MutableStateFlow = MutableStateFlow("") + private val _eventTime: MutableStateFlow = + MutableStateFlow(DateUtil.generateNowTime()) val eventTime = _eventTime.asStateFlow() fun setEventTitle(eventTitle: String) { @@ -45,11 +50,11 @@ class EventRegistrationViewModel @Inject constructor( _eventLocation.value = eventLocation } - fun setEventDate(eventDate: String) { + fun setEventDate(eventDate: LocalDate) { _eventDate.value = eventDate } - fun setEventTime(eventTime: String) { + fun setEventTime(eventTime: LocalTime) { _eventTime.value = eventTime } @@ -59,7 +64,7 @@ class EventRegistrationViewModel @Inject constructor( fun registerEvent() { viewModelScope.launch { - postEventUseCase( + registerEventUseCase( date = generateNowDate(), eventTitle = _eventTitle.value, eventContent = _eventContent.value, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt index d21354bd..fd0fb11f 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt @@ -209,6 +209,6 @@ class SurveyRegistrationViewModel @Inject constructor( companion object { const val EMPTY = "" - val EVENT_SELECTION_INIT: Event = Event("", -1, "", LocalDate.now(), "") + val EVENT_SELECTION_INIT: Event = Event("", -1, "", "", DateUtil.generateNowDateTime()) } } diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt index 7a3d807b..a06d9890 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt @@ -119,7 +119,7 @@ private fun EventItem(event: Event) { verticalAlignment = Alignment.CenterVertically, ) { Text( - text = event.time, + text = event.dateTime.toString(), style = WappTheme.typography.contentBold, color = WappTheme.colors.white, ) @@ -140,7 +140,7 @@ private fun EventItem(event: Event) { color = WappTheme.colors.white, ) Text( - text = event.time, + text = event.dateTime.toString(), style = WappTheme.typography.captionRegular, color = WappTheme.colors.grayBD, ) diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt index 66393db0..ca63a71d 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt @@ -141,7 +141,7 @@ private fun handleMonthEventsState( is NoticeViewModel.EventsState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) is NoticeViewModel.EventsState.Success -> { val eventDates = eventsState.events.map { - it.period + it.dateTime.toLocalDate() } CalendarBody( selectedDate = selectedDate, diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index 990efec7..4ac18706 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -48,7 +48,11 @@ class NoticeViewModel @Inject constructor( getEventListUseCase(_selectedDate.value).fold( onSuccess = { _selectedDateEvents.value = - EventsState.Success(it.filter { it.period == _selectedDate.value }) + EventsState.Success( + it.filter { + it.dateTime.toLocalDate() == _selectedDate.value + }, + ) }, onFailure = { _selectedDateEvents.value = EventsState.Failure(it) }, ) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 9494fa57..127e4a59 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -29,7 +29,11 @@ class ProfileViewModel @Inject constructor( getEventListUseCase(DateUtil.generateNowDate()).fold( onSuccess = { _todayEvents.value = - EventsState.Success(it.filter { it.period == DateUtil.generateNowDate() }) + EventsState.Success( + it.filter { + it.dateTime == DateUtil.generateNowDateTime() + }, + ) }, onFailure = { _todayEvents.value = EventsState.Failure(it) }, ) From e556a4449e5938a167186ac7df0da3d8dcd54f4b Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 03:33:39 +0900 Subject: [PATCH 11/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=9D=BC=EC=A0=95?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20Dialog=20=EC=A0=81=EC=9A=A9=20=EB=B0=8F?= =?UTF-8?q?=20UI=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../registration/component/RegistrationTextField.kt | 11 +++++++++-- .../registration/event/EventRegistrationContent.kt | 8 +++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/RegistrationTextField.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/RegistrationTextField.kt index d2819587..e9e34d43 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/RegistrationTextField.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/RegistrationTextField.kt @@ -6,7 +6,9 @@ import androidx.compose.material3.TextField import androidx.compose.material3.TextFieldDefaults import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import com.wap.designsystem.WappTheme @Composable @@ -19,7 +21,11 @@ internal fun RegistrationTextField( TextField( value = value, onValueChange = onValueChange, - modifier = modifier, + singleLine = true, + shape = RoundedCornerShape(10.dp), + textStyle = WappTheme.typography.contentMedium.copy( + textAlign = TextAlign.Center, + ), colors = TextFieldDefaults.colors( focusedTextColor = WappTheme.colors.white, unfocusedTextColor = WappTheme.colors.white, @@ -33,8 +39,9 @@ internal fun RegistrationTextField( Text( text = placeholder, color = WappTheme.colors.gray82, + style = WappTheme.typography.contentMedium.copy(fontSize = 15.sp), ) }, - shape = RoundedCornerShape(10.dp), + modifier = modifier, ) } diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt index 4d44ba75..05ad4226 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt @@ -189,7 +189,9 @@ private fun EventScheduleContent( ) { Row( verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.padding(40.dp), + modifier = Modifier + .padding(top = 40.dp) + .fillMaxWidth(), ) { Text( text = stringResource(R.string.event_location), @@ -203,7 +205,7 @@ private fun EventScheduleContent( value = location, onValueChange = onLocationChanged, placeholder = stringResource(R.string.event_location_hint), - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.weight(3f), ) } @@ -213,7 +215,7 @@ private fun EventScheduleContent( onCardClicked = { onDatePickerStateChanged(true) }, - modifier = Modifier.padding(top = 40.dp), + modifier = Modifier.padding(top = 20.dp), ) DeadlineCard( From 55682ba5fdce5602b1e82823d9f637e64e5144ab Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 03:48:49 +0900 Subject: [PATCH 12/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20eventId=20Int=20->?= =?UTF-8?q?=20String=20=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/event/EventRepositoryImpl.kt | 11 ++++------ .../repository/survey/SurveyRepository.kt | 4 ++-- .../repository/survey/SurveyRepositoryImpl.kt | 4 ++-- .../survey/IsSubmittedSurveyUseCase.kt | 2 +- .../usecase/survey/PostSurveyUseCase.kt | 2 +- .../com/wap/wapp/core/model/event/Event.kt | 2 +- .../wap/wapp/core/model/survey/SurveyForm.kt | 4 ++-- .../core/network/model/event/EventRequest.kt | 2 +- .../core/network/model/event/EventResponse.kt | 2 +- .../network/model/survey/SurveyRequest.kt | 2 +- .../model/survey/form/SurveyFormRequest.kt | 4 ++-- .../model/survey/form/SurveyFormResponse.kt | 4 ++-- .../network/source/event/EventDataSource.kt | 9 ++++++-- .../source/event/EventDataSourceImpl.kt | 21 +++++++++++++++++-- .../network/source/survey/SurveyDataSource.kt | 7 +++++-- .../source/survey/SurveyDataSourceImpl.kt | 7 +++++-- .../management/ManagementEventContent.kt | 4 ++-- .../survey/SurveyRegistrationViewModel.kt | 2 +- .../wap/wapp/feature/survey/SurveyScreen.kt | 6 +++--- .../wapp/feature/survey/SurveyViewModel.kt | 4 ++-- .../survey/navigation/SurveyNavigation.kt | 6 +++--- 21 files changed, 67 insertions(+), 42 deletions(-) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index 0a84a0ae..2e5dd73d 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -1,7 +1,6 @@ package com.wap.wapp.core.data.repository.event import com.wap.wapp.core.model.event.Event -import com.wap.wapp.core.network.model.event.EventRequest import com.wap.wapp.core.network.source.event.EventDataSource import java.time.LocalDate import java.time.LocalDateTime @@ -27,11 +26,9 @@ class EventRepositoryImpl @Inject constructor( ): Result = eventDataSource.postEvent( date = date, - EventRequest( - title = eventTitle, - content = eventContent, - location = eventLocation, - dateTime = eventDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), - ), + title = eventTitle, + content = eventContent, + location = eventLocation, + dateTime = eventDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), ) } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepository.kt index b097c9e1..95bf33d5 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepository.kt @@ -10,7 +10,7 @@ interface SurveyRepository { suspend fun getSurvey(surveyId: String): Result suspend fun postSurvey( - eventId: Int, + eventId: String, userId: String, title: String, content: String, @@ -18,5 +18,5 @@ interface SurveyRepository { surveyedAt: LocalDateTime, ): Result - suspend fun isSubmittedSurvey(eventId: Int, userId: String): Result + suspend fun isSubmittedSurvey(eventId: String, userId: String): Result } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt index 582dae76..5dc0ecc5 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt @@ -45,7 +45,7 @@ class SurveyRepositoryImpl @Inject constructor( } override suspend fun postSurvey( - eventId: Int, + eventId: String, userId: String, title: String, content: String, @@ -62,7 +62,7 @@ class SurveyRepositoryImpl @Inject constructor( ) } - override suspend fun isSubmittedSurvey(eventId: Int, userId: String): Result { + override suspend fun isSubmittedSurvey(eventId: String, userId: String): Result { return surveyDataSource.isSubmittedSurvey(eventId, userId) } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt index dcf68040..5b81e5f0 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt @@ -8,7 +8,7 @@ class IsSubmittedSurveyUseCase @Inject constructor( private val userRepository: UserRepository, private val surveyRepository: SurveyRepository, ) { - suspend operator fun invoke(eventId: Int): Result { + suspend operator fun invoke(eventId: String): Result { return runCatching { val userId = userRepository.getUserId().getOrThrow() diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/PostSurveyUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/PostSurveyUseCase.kt index 9fa2a1dd..8e89f014 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/PostSurveyUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/PostSurveyUseCase.kt @@ -11,7 +11,7 @@ class PostSurveyUseCase @Inject constructor( private val surveyRepository: SurveyRepository, ) { suspend operator fun invoke( - eventId: Int, + eventId: String, title: String, content: String, surveyAnswerList: List, diff --git a/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt b/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt index fdf538d0..5dd04b88 100644 --- a/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt +++ b/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt @@ -4,7 +4,7 @@ import java.time.LocalDateTime data class Event( val content: String, - val eventId: Int, + val eventId: String, val location: String, val title: String, val dateTime: LocalDateTime, diff --git a/core/model/src/main/java/com/wap/wapp/core/model/survey/SurveyForm.kt b/core/model/src/main/java/com/wap/wapp/core/model/survey/SurveyForm.kt index 5e7f6524..d105c51a 100644 --- a/core/model/src/main/java/com/wap/wapp/core/model/survey/SurveyForm.kt +++ b/core/model/src/main/java/com/wap/wapp/core/model/survey/SurveyForm.kt @@ -4,14 +4,14 @@ import java.time.LocalDateTime // 운영진이 등록하는 설문 모델 data class SurveyForm( - val eventId: Int, + val eventId: String, val title: String, val content: String, val surveyQuestionList: List, val deadline: LocalDateTime, ) { constructor() : this( - -1, + "", "", "", emptyList(), diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt index 9fa584ef..fb9ce9d9 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt @@ -5,5 +5,5 @@ data class EventRequest( val content: String = "", val location: String = "", val dateTime: String = "", - val eventId: Int = 0, + val eventId: String = "", ) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt index d6112709..9fe5af2d 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt @@ -6,7 +6,7 @@ import java.time.format.DateTimeFormatter data class EventResponse( val content: String = "", - val eventId: Int = 0, + val eventId: String = "", val location: String = "", val title: String = "", val dateTime: String = "", diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/survey/SurveyRequest.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/survey/SurveyRequest.kt index 3e6bff84..e4f6b28e 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/survey/SurveyRequest.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/survey/SurveyRequest.kt @@ -4,7 +4,7 @@ import com.wap.wapp.core.model.survey.SurveyAnswer data class SurveyRequest( val surveyId: String, - val eventId: Int, + val eventId: String, val userId: String, val title: String, val content: String, diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/survey/form/SurveyFormRequest.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/survey/form/SurveyFormRequest.kt index 864e7444..d6dc3a6d 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/survey/form/SurveyFormRequest.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/survey/form/SurveyFormRequest.kt @@ -3,14 +3,14 @@ package com.wap.wapp.core.network.model.survey.form import com.wap.wapp.core.model.survey.SurveyQuestion data class SurveyFormRequest( - val eventId: Int, + val eventId: String, val title: String, val content: String, val surveyQuestionList: List, val deadline: String, ) { constructor() : this( - -1, + "", "", "", emptyList(), diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/survey/form/SurveyFormResponse.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/survey/form/SurveyFormResponse.kt index 1391e7d9..dec777a6 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/survey/form/SurveyFormResponse.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/survey/form/SurveyFormResponse.kt @@ -4,7 +4,7 @@ import com.wap.wapp.core.model.survey.SurveyForm import com.wap.wapp.core.network.utils.toISOLocalDateTime data class SurveyFormResponse( - val eventId: Int, + val eventId: String, val userId: String, val title: String, val content: String, @@ -12,7 +12,7 @@ data class SurveyFormResponse( val deadline: String, ) { constructor() : this( - -1, + "", "", "", "", diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt index cd26ea87..4980b388 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt @@ -1,10 +1,15 @@ package com.wap.wapp.core.network.source.event -import com.wap.wapp.core.network.model.event.EventRequest import com.wap.wapp.core.network.model.event.EventResponse import java.time.LocalDate interface EventDataSource { suspend fun getMonthEvents(date: LocalDate): Result> - suspend fun postEvent(date: LocalDate, eventRequest: EventRequest): Result + suspend fun postEvent( + date: LocalDate, + title: String, + content: String, + location: String, + dateTime: String, + ): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index c0d57e0b..79d56bef 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -3,6 +3,7 @@ package com.wap.wapp.core.network.source.event import com.google.firebase.firestore.FirebaseFirestore import com.google.firebase.firestore.ktx.toObject import com.wap.wapp.core.network.constant.EVENT_COLLECTION +import com.wap.wapp.core.network.constant.SURVEY_COLLECTION import com.wap.wapp.core.network.model.event.EventRequest import com.wap.wapp.core.network.model.event.EventResponse import com.wap.wapp.core.network.utils.await @@ -32,12 +33,28 @@ class EventDataSourceImpl @Inject constructor( result } - override suspend fun postEvent(date: LocalDate, eventRequest: EventRequest): Result = + override suspend fun postEvent( + date: LocalDate, + title: String, + content: String, + location: String, + dateTime: String, + ): Result = runCatching { + val documentId = firebaseFirestore.collection(SURVEY_COLLECTION).document().id + + val eventRequest = EventRequest( + title = title, + content = content, + location = location, + dateTime = dateTime, + eventId = documentId, + ) + firebaseFirestore.collection(EVENT_COLLECTION) .document(getMonth(date)) .collection(EVENT_COLLECTION) - .document() + .document(documentId) .set(eventRequest) .await() } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSource.kt index 9a4f61c8..64573f65 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSource.kt @@ -4,14 +4,17 @@ import com.wap.wapp.core.model.survey.SurveyAnswer import com.wap.wapp.core.network.model.survey.SurveyResponse interface SurveyDataSource { - suspend fun isSubmittedSurvey(eventId: Int, userId: String): Result + suspend fun isSubmittedSurvey( + eventId: String, + userId: String, + ): Result suspend fun getSurveyList(): Result> suspend fun getSurvey(surveyId: String): Result suspend fun postSurvey( - eventId: Int, + eventId: String, userId: String, title: String, content: String, diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt index 774877d8..8fcef26a 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt @@ -44,7 +44,7 @@ class SurveyDataSourceImpl @Inject constructor( } override suspend fun postSurvey( - eventId: Int, + eventId: String, userId: String, title: String, content: String, @@ -72,7 +72,10 @@ class SurveyDataSourceImpl @Inject constructor( } } - override suspend fun isSubmittedSurvey(eventId: Int, userId: String): Result { + override suspend fun isSubmittedSurvey( + eventId: String, + userId: String, + ): Result { return runCatching { val result = firebaseFirestore.collection(SURVEY_COLLECTION) .whereEqualTo("eventId", eventId) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt index 4901c4b4..347ead74 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt @@ -31,7 +31,7 @@ import com.wap.wapp.core.model.event.Event @Composable internal fun ManagementEventContent( eventsState: ManagementViewModel.EventsState, - onCardClicked: (Int) -> Unit, + onCardClicked: (String) -> Unit, onAddEventButtonClicked: () -> Unit, modifier: Modifier = Modifier, ) { @@ -91,7 +91,7 @@ internal fun ManagementEventContent( private fun ManagementEventItem( item: Event, cardColor: Color, - onCardClicked: (Int) -> Unit, + onCardClicked: (String) -> Unit, ) { Card( shape = RoundedCornerShape(10.dp), diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt index fd0fb11f..f1236ad3 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt @@ -209,6 +209,6 @@ class SurveyRegistrationViewModel @Inject constructor( companion object { const val EMPTY = "" - val EVENT_SELECTION_INIT: Event = Event("", -1, "", "", DateUtil.generateNowDateTime()) + val EVENT_SELECTION_INIT: Event = Event("", "", "", "", DateUtil.generateNowDateTime()) } } diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt index 0b4be248..07af22be 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyScreen.kt @@ -38,7 +38,7 @@ import java.time.LocalDateTime @Composable internal fun SurveyScreen( viewModel: SurveyViewModel, - navigateToSurveyAnswer: (Int) -> Unit, + navigateToSurveyAnswer: (String) -> Unit, ) { val context = LocalContext.current val surveyFormListUiState = viewModel.surveyFormListUiState.collectAsState().value @@ -86,7 +86,7 @@ internal fun SurveyScreen( private fun SurveyContent( surveyFormList: List, paddingValues: PaddingValues, - selectedSurveyForm: (Int) -> Unit, + selectedSurveyForm: (String) -> Unit, ) { Column( verticalArrangement = Arrangement.spacedBy(16.dp), @@ -115,7 +115,7 @@ private fun SurveyContent( @Composable private fun SurveyFormItemCard( surveyForm: SurveyForm, - selectedSurveyForm: (Int) -> Unit, + selectedSurveyForm: (String) -> Unit, ) { Card( colors = CardDefaults.cardColors( diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyViewModel.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyViewModel.kt index d18096d7..443c064f 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyViewModel.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyViewModel.kt @@ -41,7 +41,7 @@ class SurveyViewModel @Inject constructor( } } - fun isSubmittedSurvey(eventId: Int) { + fun isSubmittedSurvey(eventId: String) { viewModelScope.launch { isSubmittedSurveyUseCase(eventId) .onSuccess { isSubmittedSurvey -> @@ -67,6 +67,6 @@ class SurveyViewModel @Inject constructor( data object AlreadySubmitted : SurveyUiEvent() - data class NotSubmitted(val eventId: Int) : SurveyUiEvent() + data class NotSubmitted(val eventId: String) : SurveyUiEvent() } } diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt index b674d47a..6f907168 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt @@ -15,12 +15,12 @@ fun NavController.navigateToSurvey(navOptions: NavOptions? = navOptions {}) { this.navigate(SurveyRoute.route, navOptions) } -fun NavController.navigateToSurveyAnswer(eventId: Int, navOptions: NavOptions? = navOptions {}) { - navigate(SurveyRoute.answerRoute(eventId.toString()), navOptions) +fun NavController.navigateToSurveyAnswer(eventId: String, navOptions: NavOptions? = navOptions {}) { + navigate(SurveyRoute.answerRoute(eventId), navOptions) } fun NavGraphBuilder.surveyNavGraph( - navigateToSurveyAnswer: (Int) -> Unit, + navigateToSurveyAnswer: (String) -> Unit, navigateToSurvey: () -> Unit, ) { composable(route = SurveyRoute.route) { From 5dc38dc73c2889b90e84e6cfb3b907928af731bc Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 04:23:51 +0900 Subject: [PATCH 13/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20RegistrationTextFi?= =?UTF-8?q?eld=20=EC=83=81=EB=8B=A8=20=EB=B6=80=ED=84=B0=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../registration/component/RegistrationTextField.kt | 4 ++-- .../management/registration/event/EventRegistrationContent.kt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/RegistrationTextField.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/RegistrationTextField.kt index e9e34d43..a06ab33b 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/RegistrationTextField.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/RegistrationTextField.kt @@ -16,15 +16,15 @@ internal fun RegistrationTextField( value: String, onValueChange: (String) -> Unit, modifier: Modifier = Modifier, + textAlign: TextAlign? = null, placeholder: String, ) { TextField( value = value, onValueChange = onValueChange, - singleLine = true, shape = RoundedCornerShape(10.dp), textStyle = WappTheme.typography.contentMedium.copy( - textAlign = TextAlign.Center, + textAlign = textAlign, ), colors = TextFieldDefaults.colors( focusedTextColor = WappTheme.colors.white, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt index 05ad4226..8ffcdf35 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt @@ -205,6 +205,8 @@ private fun EventScheduleContent( value = location, onValueChange = onLocationChanged, placeholder = stringResource(R.string.event_location_hint), + textAlign = TextAlign.Center, + isSingline = true, modifier = Modifier.weight(3f), ) } From a0d381b1698e3b05dff684c65b21859e2c9c65aa Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 14:25:13 +0900 Subject: [PATCH 14/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20=EC=9D=BC=EC=A0=95?= =?UTF-8?q?=20=EB=93=B1=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/EventRegistrationContent.kt | 12 ++++------ .../event/EventRegistrationScreen.kt | 2 +- .../event/EventRegistrationViewModel.kt | 23 ++++++++++++++++--- .../survey/SurveyRegistrationViewModel.kt | 2 +- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt index 8ffcdf35..00536f5f 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt @@ -48,7 +48,7 @@ internal fun EventRegistrationContent( onTimeChanged: (LocalTime) -> Unit, onDatePickerStateChanged: (Boolean) -> Unit, onTimePickerStateChanged: (Boolean) -> Unit, - onNextButtonClicked: (EventRegistrationState) -> Unit, + onNextButtonClicked: () -> Unit, onRegisterButtonClicked: () -> Unit, ) { Column(modifier = modifier) { @@ -58,8 +58,7 @@ internal fun EventRegistrationContent( eventContent = eventContent, onTitleChanged = onTitleChanged, onContentChanged = onContentChanged, - onNextButtonClicked = - { onNextButtonClicked(EventRegistrationState.EVENT_SCHEDULE) }, + onNextButtonClicked = onNextButtonClicked, ) EventRegistrationState.EVENT_SCHEDULE -> EventScheduleContent( @@ -74,7 +73,7 @@ internal fun EventRegistrationContent( showTimePicker = showTimePicker, onDatePickerStateChanged = onDatePickerStateChanged, onTimePickerStateChanged = onTimePickerStateChanged, - onNextButtonClicked = onRegisterButtonClicked, + onRegisterButtonClicked = onRegisterButtonClicked, ) } } @@ -152,7 +151,7 @@ private fun EventScheduleContent( onLocationChanged: (String) -> Unit, onDateChanged: (LocalDate) -> Unit, onTimeChanged: (LocalTime) -> Unit, - onNextButtonClicked: () -> Unit, + onRegisterButtonClicked: () -> Unit, ) { if (showDatePicker) { WappDatePickerDialog( @@ -206,7 +205,6 @@ private fun EventScheduleContent( onValueChange = onLocationChanged, placeholder = stringResource(R.string.event_location_hint), textAlign = TextAlign.Center, - isSingline = true, modifier = Modifier.weight(3f), ) } @@ -231,7 +229,7 @@ private fun EventScheduleContent( } WappButton( - onClick = onNextButtonClicked, + onClick = onRegisterButtonClicked, textRes = R.string.register_event, modifier = Modifier.padding(bottom = 20.dp), ) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt index af4d084c..4598ae55 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt @@ -89,7 +89,7 @@ internal fun EventRegistrationScreen( onLocationChanged: (String) -> Unit, onDateChanged: (LocalDate) -> Unit, onTimeChanged: (LocalTime) -> Unit, - onNextButtonClicked: (EventRegistrationState) -> Unit, + onNextButtonClicked: () -> Unit, onRegisterButtonClicked: () -> Unit, onBackButtonClicked: () -> Unit, ) { diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt index a45896c7..f3144c91 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.commmon.util.DateUtil.generateNowDate import com.wap.wapp.core.domain.usecase.event.RegisterEventUseCase +import com.wap.wapp.feature.management.registration.event.EventRegistrationState.EVENT_DETAILS import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow @@ -18,7 +19,7 @@ class EventRegistrationViewModel @Inject constructor( private val registerEventUseCase: RegisterEventUseCase, ) : ViewModel() { private val _currentRegistrationState: MutableStateFlow = - MutableStateFlow(EventRegistrationState.EVENT_DETAILS) + MutableStateFlow(EVENT_DETAILS) val currentRegistrationState = _currentRegistrationState.asStateFlow() private val _eventTitle: MutableStateFlow = MutableStateFlow("") @@ -58,11 +59,27 @@ class EventRegistrationViewModel @Inject constructor( _eventTime.value = eventTime } - fun setEventRegistrationState(eventRegistrationState: EventRegistrationState) { - _currentRegistrationState.value = eventRegistrationState + fun setEventRegistrationState() { + if (_currentRegistrationState.value == EVENT_DETAILS) { + if (_eventLocation.value.isEmpty()) { + return + } + if (_eventContent.value.isEmpty()) { + return + } + _currentRegistrationState.value = EVENT_DETAILS + } } fun registerEvent() { + if (_eventLocation.value.isEmpty()) { + return + } + + if (_eventDate.value <= generateNowDate()) { + return + } + viewModelScope.launch { registerEventUseCase( date = generateNowDate(), diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt index f1236ad3..1fb38f06 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt @@ -191,7 +191,7 @@ class SurveyRegistrationViewModel @Inject constructor( private fun isNotValidInformation() = _surveyTitle.value.isBlank() || _surveyContent.value.isBlank() - private fun isValidDeadline() = _surveyDateDeadline.value > LocalDate.now() + private fun isValidDeadline() = _surveyDateDeadline.value > DateUtil.generateNowDate() private fun emitValidationErrorMessage(message: String) { viewModelScope.launch { From 533d391631bfddad2b588da9c4ad90972dc69d49 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 14:31:26 +0900 Subject: [PATCH 15/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=20SharedFlow=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/EventRegistrationEvent.kt | 7 +++++++ .../event/EventRegistrationViewModel.kt | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationEvent.kt diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationEvent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationEvent.kt new file mode 100644 index 00000000..8ea00316 --- /dev/null +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationEvent.kt @@ -0,0 +1,7 @@ +package com.wap.wapp.feature.management.registration.event + +sealed class EventRegistrationEvent { + data class ValidationError(val message: String) : EventRegistrationEvent() + data class Failure(val error: Throwable) : EventRegistrationEvent() + data object Success : EventRegistrationEvent() +} diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt index f3144c91..6d296c25 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt @@ -7,7 +7,9 @@ import com.wap.wapp.core.commmon.util.DateUtil.generateNowDate import com.wap.wapp.core.domain.usecase.event.RegisterEventUseCase import com.wap.wapp.feature.management.registration.event.EventRegistrationState.EVENT_DETAILS import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import java.time.LocalDate @@ -22,6 +24,10 @@ class EventRegistrationViewModel @Inject constructor( MutableStateFlow(EVENT_DETAILS) val currentRegistrationState = _currentRegistrationState.asStateFlow() + private val _eventRegistrationEvent: MutableSharedFlow = + MutableSharedFlow() + val eventRegistrationEvent = _eventRegistrationEvent.asSharedFlow() + private val _eventTitle: MutableStateFlow = MutableStateFlow("") val eventTitle = _eventTitle.asStateFlow() @@ -62,9 +68,11 @@ class EventRegistrationViewModel @Inject constructor( fun setEventRegistrationState() { if (_currentRegistrationState.value == EVENT_DETAILS) { if (_eventLocation.value.isEmpty()) { + emitValidationErrorMessage("장소를 입력하세요.") return } if (_eventContent.value.isEmpty()) { + emitValidationErrorMessage("내용을 입력하세요.") return } _currentRegistrationState.value = EVENT_DETAILS @@ -73,10 +81,12 @@ class EventRegistrationViewModel @Inject constructor( fun registerEvent() { if (_eventLocation.value.isEmpty()) { + emitValidationErrorMessage("장소를 입력하세요.") return } if (_eventDate.value <= generateNowDate()) { + emitValidationErrorMessage("최소 하루 이상 일정 날짜를 지정하세요.") return } @@ -91,4 +101,12 @@ class EventRegistrationViewModel @Inject constructor( ) } } + + private fun emitValidationErrorMessage(message: String) { + viewModelScope.launch { + _eventRegistrationEvent.emit( + EventRegistrationEvent.ValidationError(message), + ) + } + } } From 4b666eb295e465e6119caf17af60f0f8bbfde295 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 29 Dec 2023 14:47:26 +0900 Subject: [PATCH 16/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=9D=BC=EC=A0=95?= =?UTF-8?q?=20=EB=93=B1=EB=A1=9D=20Validation=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/EventRegistrationScreen.kt | 32 +++++++++++++++---- .../event/EventRegistrationViewModel.kt | 14 +++++--- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt index 4598ae55..b3120f09 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt @@ -15,6 +15,7 @@ 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 import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -28,7 +29,9 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappTopBar +import com.wap.wapp.core.commmon.extensions.toSupportingText import com.wap.wapp.feature.management.R +import kotlinx.coroutines.flow.collectLatest import java.time.LocalDate import java.time.LocalTime @@ -38,6 +41,7 @@ internal fun EventRegistrationRoute( viewModel: EventRegistrationViewModel = hiltViewModel(), navigateToManagement: () -> Unit, ) { + val snackBarHostState = remember { SnackbarHostState() } val currentRegistrationState by viewModel.currentRegistrationState.collectAsStateWithLifecycle() val title by viewModel.eventTitle.collectAsStateWithLifecycle() @@ -54,6 +58,24 @@ internal fun EventRegistrationRoute( viewModel::setEventRegistrationState val onRegisterButtonClicked = viewModel::registerEvent + LaunchedEffect(true) { + viewModel.eventRegistrationEvent.collectLatest { + when (it) { + is EventRegistrationEvent.Failure -> { + snackBarHostState.showSnackbar(it.error.toSupportingText()) + } + + is EventRegistrationEvent.ValidationError -> { + snackBarHostState.showSnackbar(it.message) + } + + is EventRegistrationEvent.Success -> { + navigateToManagement() + } + } + } + } + EventRegistrationScreen( currentRegistrationState = currentRegistrationState, title = title, @@ -61,17 +83,15 @@ internal fun EventRegistrationRoute( location = location, date = date, time = time, + snackBarHostState = snackBarHostState, onTitleChanged = onTitleChanged, onContentChanged = onContentChanged, onLocationChanged = onLocationChanged, onDateChanged = onDateChanged, onTimeChanged = onTimeChanged, onNextButtonClicked = onNextButtonClicked, - onRegisterButtonClicked = { - onRegisterButtonClicked() - navigateToManagement() - }, - onBackButtonClicked = { navigateToManagement() }, + onRegisterButtonClicked = onRegisterButtonClicked, + onBackButtonClicked = navigateToManagement, ) } @@ -84,6 +104,7 @@ internal fun EventRegistrationScreen( location: String, date: LocalDate, time: LocalTime, + snackBarHostState: SnackbarHostState, onTitleChanged: (String) -> Unit, onContentChanged: (String) -> Unit, onLocationChanged: (String) -> Unit, @@ -93,7 +114,6 @@ internal fun EventRegistrationScreen( onRegisterButtonClicked: () -> Unit, onBackButtonClicked: () -> Unit, ) { - val snackBarHostState = remember { SnackbarHostState() } var showDatePicker by remember { mutableStateOf(false) } var showTimePicker by remember { mutableStateOf(false) } val timePickerState = rememberTimePickerState() diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt index 6d296c25..f715c49e 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt @@ -6,6 +6,7 @@ import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.commmon.util.DateUtil.generateNowDate import com.wap.wapp.core.domain.usecase.event.RegisterEventUseCase import com.wap.wapp.feature.management.registration.event.EventRegistrationState.EVENT_DETAILS +import com.wap.wapp.feature.management.registration.event.EventRegistrationState.EVENT_SCHEDULE import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -67,15 +68,15 @@ class EventRegistrationViewModel @Inject constructor( fun setEventRegistrationState() { if (_currentRegistrationState.value == EVENT_DETAILS) { - if (_eventLocation.value.isEmpty()) { - emitValidationErrorMessage("장소를 입력하세요.") + if (_eventTitle.value.isEmpty()) { + emitValidationErrorMessage("행사 이름을 입력하세요.") return } if (_eventContent.value.isEmpty()) { - emitValidationErrorMessage("내용을 입력하세요.") + emitValidationErrorMessage("행사 내용을 입력하세요.") return } - _currentRegistrationState.value = EVENT_DETAILS + _currentRegistrationState.value = EVENT_SCHEDULE } } @@ -98,6 +99,11 @@ class EventRegistrationViewModel @Inject constructor( eventLocation = _eventLocation.value, eventDate = _eventDate.value, eventTime = _eventTime.value, + ).fold( + onSuccess = { _eventRegistrationEvent.emit(EventRegistrationEvent.Success) }, + onFailure = { throwable -> + _eventRegistrationEvent.emit(EventRegistrationEvent.Failure(throwable)) + }, ) } } From 2cae0bf842e1011674cf8e7b7890ef1d5f149f0c Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Mon, 1 Jan 2024 22:47:44 +0900 Subject: [PATCH 17/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EB=A7=88=EA=B0=90?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95=EC=9D=84=20=EC=9C=84=ED=95=B4=20StateFlow?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/EventRegistrationScreen.kt | 8 ++-- .../event/EventRegistrationViewModel.kt | 40 +++++++++++++------ 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt index b3120f09..3b390d1c 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt @@ -47,13 +47,13 @@ internal fun EventRegistrationRoute( val title by viewModel.eventTitle.collectAsStateWithLifecycle() val content by viewModel.eventContent.collectAsStateWithLifecycle() val location by viewModel.eventLocation.collectAsStateWithLifecycle() - val date by viewModel.eventDate.collectAsStateWithLifecycle() - val time by viewModel.eventTime.collectAsStateWithLifecycle() + val date by viewModel.eventEndDate.collectAsStateWithLifecycle() + val time by viewModel.eventEndTime.collectAsStateWithLifecycle() val onTitleChanged = viewModel::setEventTitle val onContentChanged = viewModel::setEventContent val onLocationChanged = viewModel::setEventLocation - val onDateChanged = viewModel::setEventDate - val onTimeChanged = viewModel::setEventTime + val onDateChanged = viewModel::setEventEndDate + val onTimeChanged = viewModel::setEventEndTime val onNextButtonClicked = viewModel::setEventRegistrationState val onRegisterButtonClicked = viewModel::registerEvent diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt index f715c49e..283ba820 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt @@ -38,13 +38,21 @@ class EventRegistrationViewModel @Inject constructor( private val _eventLocation: MutableStateFlow = MutableStateFlow("") val eventLocation = _eventLocation.asStateFlow() - private val _eventDate: MutableStateFlow = + private val _eventStartDate: MutableStateFlow = MutableStateFlow(DateUtil.generateNowDate()) - val eventDate = _eventDate.asStateFlow() + val eventStartDate = _eventStartDate.asStateFlow() - private val _eventTime: MutableStateFlow = + private val _eventStartTime: MutableStateFlow = MutableStateFlow(DateUtil.generateNowTime()) - val eventTime = _eventTime.asStateFlow() + val eventStartTime = _eventStartTime.asStateFlow() + + private val _eventEndDate: MutableStateFlow = + MutableStateFlow(DateUtil.generateNowDate()) + val eventEndDate = _eventEndDate.asStateFlow() + + private val _eventEndTime: MutableStateFlow = + MutableStateFlow(DateUtil.generateNowTime()) + val eventEndTime = _eventEndTime.asStateFlow() fun setEventTitle(eventTitle: String) { _eventTitle.value = eventTitle @@ -58,12 +66,20 @@ class EventRegistrationViewModel @Inject constructor( _eventLocation.value = eventLocation } - fun setEventDate(eventDate: LocalDate) { - _eventDate.value = eventDate + fun setEventStartDate(eventDate: LocalDate) { + _eventStartDate.value = eventDate + } + + fun setEventStartTime(eventTime: LocalTime) { + _eventStartTime.value = eventTime + } + + fun setEventEndDate(eventDate: LocalDate) { + _eventEndDate.value = eventDate } - fun setEventTime(eventTime: LocalTime) { - _eventTime.value = eventTime + fun setEventEndTime(eventTime: LocalTime) { + _eventEndTime.value = eventTime } fun setEventRegistrationState() { @@ -86,19 +102,19 @@ class EventRegistrationViewModel @Inject constructor( return } - if (_eventDate.value <= generateNowDate()) { + if (_eventEndDate.value <= generateNowDate()) { emitValidationErrorMessage("최소 하루 이상 일정 날짜를 지정하세요.") return } viewModelScope.launch { registerEventUseCase( - date = generateNowDate(), + date = _eventEndDate.value, eventTitle = _eventTitle.value, eventContent = _eventContent.value, eventLocation = _eventLocation.value, - eventDate = _eventDate.value, - eventTime = _eventTime.value, + eventDate = _eventEndDate.value, + eventTime = _eventEndTime.value, ).fold( onSuccess = { _eventRegistrationEvent.emit(EventRegistrationEvent.Success) }, onFailure = { throwable -> From 22f257b914dd993c3aa40ff351db3faaa19673f2 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Mon, 1 Jan 2024 22:55:06 +0900 Subject: [PATCH 18/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=8B=9C=EC=9E=91?= =?UTF-8?q?=20=EC=8B=9C=EA=B0=84,=20=EC=8B=9C=EC=9E=91=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=B0=8F=20?= =?UTF-8?q?string=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/EventRegistrationContent.kt | 46 +++++++++++------- .../event/EventRegistrationScreen.kt | 48 ++++++++++++------- .../src/main/res/values/strings.xml | 6 ++- 3 files changed, 65 insertions(+), 35 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt index 00536f5f..5d5ee44b 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt @@ -36,16 +36,20 @@ internal fun EventRegistrationContent( eventTitle: String, eventContent: String, location: String, - date: LocalDate, - time: LocalTime, + startDate: LocalDate, + startTime: LocalTime, + endDate: LocalDate, + endTime: LocalTime, showDatePicker: Boolean, showTimePicker: Boolean, timePickerState: TimePickerState, onTitleChanged: (String) -> Unit, onContentChanged: (String) -> Unit, onLocationChanged: (String) -> Unit, - onDateChanged: (LocalDate) -> Unit, - onTimeChanged: (LocalTime) -> Unit, + onEndDateChanged: (LocalDate) -> Unit, + onEndTimeChanged: (LocalTime) -> Unit, + onStartDateChanged: (LocalDate) -> Unit, + onStartTimeChanged: (LocalTime) -> Unit, onDatePickerStateChanged: (Boolean) -> Unit, onTimePickerStateChanged: (Boolean) -> Unit, onNextButtonClicked: () -> Unit, @@ -63,12 +67,16 @@ internal fun EventRegistrationContent( EventRegistrationState.EVENT_SCHEDULE -> EventScheduleContent( location = location, - date = date, - time = time, + startDate = startDate, + startTime = startTime, + endDate = endDate, + endTime = endTime, timePickerState = timePickerState, onLocationChanged = onLocationChanged, - onDateChanged = onDateChanged, - onTimeChanged = onTimeChanged, + onEndDateChanged = onEndDateChanged, + onEndTimeChanged = onEndTimeChanged, + onStartDateChanged = onStartDateChanged, + onStartTimeChanged = onStartTimeChanged, showDatePicker = showDatePicker, showTimePicker = showTimePicker, onDatePickerStateChanged = onDatePickerStateChanged, @@ -141,23 +149,27 @@ private fun EventDetailsContent( @Composable private fun EventScheduleContent( location: String, - date: LocalDate, - time: LocalTime, + startDate: LocalDate, + startTime: LocalTime, + endDate: LocalDate, + endTime: LocalTime, timePickerState: TimePickerState, showDatePicker: Boolean, showTimePicker: Boolean, onDatePickerStateChanged: (Boolean) -> Unit, onTimePickerStateChanged: (Boolean) -> Unit, onLocationChanged: (String) -> Unit, - onDateChanged: (LocalDate) -> Unit, - onTimeChanged: (LocalTime) -> Unit, + onStartDateChanged: (LocalDate) -> Unit, + onStartTimeChanged: (LocalTime) -> Unit, + onEndDateChanged: (LocalDate) -> Unit, + onEndTimeChanged: (LocalTime) -> Unit, onRegisterButtonClicked: () -> Unit, ) { if (showDatePicker) { WappDatePickerDialog( - date = date, + date = endDate, onDismissRequest = { onDatePickerStateChanged(false) }, - onDateChanged = onDateChanged, + onDateChanged = onEndDateChanged, ) } @@ -166,7 +178,7 @@ private fun EventScheduleContent( state = timePickerState, onDismissRequest = { onTimePickerStateChanged(false) }, onConfirmButtonClicked = { localTime -> - onTimeChanged(localTime) + onEndTimeChanged(localTime) onTimePickerStateChanged(false) }, onDismissButtonClicked = { @@ -211,7 +223,7 @@ private fun EventScheduleContent( DeadlineCard( title = stringResource(R.string.date), - hint = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), + hint = endDate.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), onCardClicked = { onDatePickerStateChanged(true) }, @@ -220,7 +232,7 @@ private fun EventScheduleContent( DeadlineCard( title = stringResource(R.string.time), - hint = time.format(DateTimeFormatter.ofPattern("HH.mm")), + hint = endTime.format(DateTimeFormatter.ofPattern("HH.mm")), onCardClicked = { onTimePickerStateChanged(true) }, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt index 3b390d1c..58a9dd7a 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt @@ -47,13 +47,17 @@ internal fun EventRegistrationRoute( val title by viewModel.eventTitle.collectAsStateWithLifecycle() val content by viewModel.eventContent.collectAsStateWithLifecycle() val location by viewModel.eventLocation.collectAsStateWithLifecycle() - val date by viewModel.eventEndDate.collectAsStateWithLifecycle() - val time by viewModel.eventEndTime.collectAsStateWithLifecycle() + val startDate by viewModel.eventStartDate.collectAsStateWithLifecycle() + val startTime by viewModel.eventStartTime.collectAsStateWithLifecycle() + val endDate by viewModel.eventEndDate.collectAsStateWithLifecycle() + val endTime by viewModel.eventEndTime.collectAsStateWithLifecycle() val onTitleChanged = viewModel::setEventTitle val onContentChanged = viewModel::setEventContent val onLocationChanged = viewModel::setEventLocation - val onDateChanged = viewModel::setEventEndDate - val onTimeChanged = viewModel::setEventEndTime + val onStartDateChanged = viewModel::setEventStartDate + val onStartTimeChanged = viewModel::setEventStartTime + val onEndDateChanged = viewModel::setEventEndDate + val onEndTimeChanged = viewModel::setEventEndTime val onNextButtonClicked = viewModel::setEventRegistrationState val onRegisterButtonClicked = viewModel::registerEvent @@ -81,14 +85,18 @@ internal fun EventRegistrationRoute( title = title, content = content, location = location, - date = date, - time = time, + startDate = startDate, + startTime = startTime, + endDate = endDate, + endTime = endTime, snackBarHostState = snackBarHostState, onTitleChanged = onTitleChanged, onContentChanged = onContentChanged, onLocationChanged = onLocationChanged, - onDateChanged = onDateChanged, - onTimeChanged = onTimeChanged, + onStartDateChanged = onStartDateChanged, + onStartTimeChanged = onStartTimeChanged, + onEndDateChanged = onEndDateChanged, + onEndTimeChanged = onEndTimeChanged, onNextButtonClicked = onNextButtonClicked, onRegisterButtonClicked = onRegisterButtonClicked, onBackButtonClicked = navigateToManagement, @@ -102,14 +110,18 @@ internal fun EventRegistrationScreen( title: String, content: String, location: String, - date: LocalDate, - time: LocalTime, + startDate: LocalDate, + startTime: LocalTime, + endDate: LocalDate, + endTime: LocalTime, snackBarHostState: SnackbarHostState, onTitleChanged: (String) -> Unit, onContentChanged: (String) -> Unit, onLocationChanged: (String) -> Unit, - onDateChanged: (LocalDate) -> Unit, - onTimeChanged: (LocalTime) -> Unit, + onStartDateChanged: (LocalDate) -> Unit, + onStartTimeChanged: (LocalTime) -> Unit, + onEndDateChanged: (LocalDate) -> Unit, + onEndTimeChanged: (LocalTime) -> Unit, onNextButtonClicked: () -> Unit, onRegisterButtonClicked: () -> Unit, onBackButtonClicked: () -> Unit, @@ -146,16 +158,20 @@ internal fun EventRegistrationScreen( eventTitle = title, eventContent = content, location = location, - date = date, - time = time, + startDate = startDate, + startTime = startTime, + endDate = endDate, + endTime = endTime, showDatePicker = showDatePicker, showTimePicker = showTimePicker, onTitleChanged = onTitleChanged, onContentChanged = onContentChanged, onLocationChanged = onLocationChanged, timePickerState = timePickerState, - onDateChanged = onDateChanged, - onTimeChanged = onTimeChanged, + onEndDateChanged = onEndDateChanged, + onEndTimeChanged = onEndTimeChanged, + onStartDateChanged = onStartDateChanged, + onStartTimeChanged = onStartTimeChanged, onDatePickerStateChanged = { state -> showDatePicker = state }, onTimePickerStateChanged = { state -> showTimePicker = state }, onNextButtonClicked = onNextButtonClicked, diff --git a/feature/management/src/main/res/values/strings.xml b/feature/management/src/main/res/values/strings.xml index 3844aca5..656b5800 100644 --- a/feature/management/src/main/res/values/strings.xml +++ b/feature/management/src/main/res/values/strings.xml @@ -34,8 +34,10 @@ 선택 설문 기간 설정 설문의 마감 기한을 설정하세요. - 날짜 - 시간 + 시작 날짜 + 시작 시간 + 종료 날짜 + 종료 시간 설문 제목 입력 설문을 이해하기 쉽도록 제목과 소개를 입력해주세요. 설문 제목 From 288da2a5b193e81c0059b18bd36459694be92714 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Mon, 1 Jan 2024 23:01:50 +0900 Subject: [PATCH 19/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=8B=9C=EC=9E=91?= =?UTF-8?q?=20=EC=8B=9C=EA=B0=84,=20=EC=8B=9C=EC=9E=91=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EC=84=A0=ED=83=9D=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/EventRegistrationContent.kt | 66 ++++++++++++++++--- .../event/EventRegistrationScreen.kt | 20 +++--- 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt index 5d5ee44b..a7b25364 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt @@ -40,8 +40,10 @@ internal fun EventRegistrationContent( startTime: LocalTime, endDate: LocalDate, endTime: LocalTime, - showDatePicker: Boolean, - showTimePicker: Boolean, + showStartDatePicker: Boolean, + showStartTimePicker: Boolean, + showEndDatePicker: Boolean, + showEndTimePicker: Boolean, timePickerState: TimePickerState, onTitleChanged: (String) -> Unit, onContentChanged: (String) -> Unit, @@ -77,8 +79,10 @@ internal fun EventRegistrationContent( onEndTimeChanged = onEndTimeChanged, onStartDateChanged = onStartDateChanged, onStartTimeChanged = onStartTimeChanged, - showDatePicker = showDatePicker, - showTimePicker = showTimePicker, + showStartDatePicker = showStartDatePicker, + showStartTimePicker = showStartTimePicker, + showEndDatePicker = showEndDatePicker, + showEndTimePicker = showEndTimePicker, onDatePickerStateChanged = onDatePickerStateChanged, onTimePickerStateChanged = onTimePickerStateChanged, onRegisterButtonClicked = onRegisterButtonClicked, @@ -154,8 +158,10 @@ private fun EventScheduleContent( endDate: LocalDate, endTime: LocalTime, timePickerState: TimePickerState, - showDatePicker: Boolean, - showTimePicker: Boolean, + showStartDatePicker: Boolean, + showStartTimePicker: Boolean, + showEndDatePicker: Boolean, + showEndTimePicker: Boolean, onDatePickerStateChanged: (Boolean) -> Unit, onTimePickerStateChanged: (Boolean) -> Unit, onLocationChanged: (String) -> Unit, @@ -165,7 +171,7 @@ private fun EventScheduleContent( onEndTimeChanged: (LocalTime) -> Unit, onRegisterButtonClicked: () -> Unit, ) { - if (showDatePicker) { + if (showEndDatePicker) { WappDatePickerDialog( date = endDate, onDismissRequest = { onDatePickerStateChanged(false) }, @@ -173,7 +179,7 @@ private fun EventScheduleContent( ) } - if (showTimePicker) { + if (showEndTimePicker) { WappTimePickerDialog( state = timePickerState, onDismissRequest = { onTimePickerStateChanged(false) }, @@ -187,6 +193,28 @@ private fun EventScheduleContent( ) } + if (showStartDatePicker) { + WappDatePickerDialog( + date = startDate, + onDismissRequest = { onDatePickerStateChanged(false) }, + onDateChanged = onStartDateChanged, + ) + } + + if (showStartTimePicker) { + WappTimePickerDialog( + state = timePickerState, + onDismissRequest = { onTimePickerStateChanged(false) }, + onConfirmButtonClicked = { localTime -> + onStartTimeChanged(localTime) + onTimePickerStateChanged(false) + }, + onDismissButtonClicked = { + onTimePickerStateChanged(false) + }, + ) + } + RegistrationTitle( title = stringResource(id = R.string.event_schedule_title), content = stringResource(id = R.string.event_schedule_content), @@ -222,7 +250,25 @@ private fun EventScheduleContent( } DeadlineCard( - title = stringResource(R.string.date), + title = stringResource(R.string.start_date), + hint = startDate.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), + onCardClicked = { + onDatePickerStateChanged(true) + }, + modifier = Modifier.padding(top = 20.dp), + ) + + DeadlineCard( + title = stringResource(R.string.start_time), + hint = startTime.format(DateTimeFormatter.ofPattern("HH.mm")), + onCardClicked = { + onTimePickerStateChanged(true) + }, + modifier = Modifier.padding(top = 20.dp), + ) + + DeadlineCard( + title = stringResource(R.string.end_date), hint = endDate.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), onCardClicked = { onDatePickerStateChanged(true) @@ -231,7 +277,7 @@ private fun EventScheduleContent( ) DeadlineCard( - title = stringResource(R.string.time), + title = stringResource(R.string.end_time), hint = endTime.format(DateTimeFormatter.ofPattern("HH.mm")), onCardClicked = { onTimePickerStateChanged(true) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt index 58a9dd7a..25eebb55 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt @@ -126,8 +126,10 @@ internal fun EventRegistrationScreen( onRegisterButtonClicked: () -> Unit, onBackButtonClicked: () -> Unit, ) { - var showDatePicker by remember { mutableStateOf(false) } - var showTimePicker by remember { mutableStateOf(false) } + var showStartDatePicker by remember { mutableStateOf(false) } + var showStartTimePicker by remember { mutableStateOf(false) } + var showEndDatePicker by remember { mutableStateOf(false) } + var showEndTimePicker by remember { mutableStateOf(false) } val timePickerState = rememberTimePickerState() Scaffold( @@ -162,18 +164,20 @@ internal fun EventRegistrationScreen( startTime = startTime, endDate = endDate, endTime = endTime, - showDatePicker = showDatePicker, - showTimePicker = showTimePicker, + showStartDatePicker = showStartDatePicker, + showStartTimePicker = showStartTimePicker, + showEndDatePicker = showEndDatePicker, + showEndTimePicker = showEndTimePicker, onTitleChanged = onTitleChanged, onContentChanged = onContentChanged, onLocationChanged = onLocationChanged, timePickerState = timePickerState, - onEndDateChanged = onEndDateChanged, - onEndTimeChanged = onEndTimeChanged, onStartDateChanged = onStartDateChanged, onStartTimeChanged = onStartTimeChanged, - onDatePickerStateChanged = { state -> showDatePicker = state }, - onTimePickerStateChanged = { state -> showTimePicker = state }, + onEndDateChanged = onEndDateChanged, + onEndTimeChanged = onEndTimeChanged, + onDatePickerStateChanged = { state -> showEndDatePicker = state }, + onTimePickerStateChanged = { state -> showEndTimePicker = state }, onNextButtonClicked = onNextButtonClicked, onRegisterButtonClicked = onRegisterButtonClicked, ) From d45b4ce1da40f64e4845319526da5367a12be580 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Mon, 1 Jan 2024 23:11:29 +0900 Subject: [PATCH 20/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=8B=9C=EC=9E=91,?= =?UTF-8?q?=20=EC=A2=85=EB=A3=8C=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EA=B5=AC=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/EventRegistrationContent.kt | 42 +++++++++++-------- .../event/EventRegistrationScreen.kt | 6 ++- .../src/main/res/values/strings.xml | 2 + 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt index a7b25364..3615fbe7 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt @@ -52,8 +52,10 @@ internal fun EventRegistrationContent( onEndTimeChanged: (LocalTime) -> Unit, onStartDateChanged: (LocalDate) -> Unit, onStartTimeChanged: (LocalTime) -> Unit, - onDatePickerStateChanged: (Boolean) -> Unit, - onTimePickerStateChanged: (Boolean) -> Unit, + onStartDatePickerStateChanged: (Boolean) -> Unit, + onStartTimePickerStateChanged: (Boolean) -> Unit, + onEndDatePickerStateChanged: (Boolean) -> Unit, + onEndTimePickerStateChanged: (Boolean) -> Unit, onNextButtonClicked: () -> Unit, onRegisterButtonClicked: () -> Unit, ) { @@ -83,8 +85,10 @@ internal fun EventRegistrationContent( showStartTimePicker = showStartTimePicker, showEndDatePicker = showEndDatePicker, showEndTimePicker = showEndTimePicker, - onDatePickerStateChanged = onDatePickerStateChanged, - onTimePickerStateChanged = onTimePickerStateChanged, + onStartDatePickerStateChanged = onStartDatePickerStateChanged, + onStartTimePickerStateChanged = onStartTimePickerStateChanged, + onEndDatePickerStateChanged = onEndDatePickerStateChanged, + onEndTimePickerStateChanged = onEndTimePickerStateChanged, onRegisterButtonClicked = onRegisterButtonClicked, ) } @@ -162,8 +166,10 @@ private fun EventScheduleContent( showStartTimePicker: Boolean, showEndDatePicker: Boolean, showEndTimePicker: Boolean, - onDatePickerStateChanged: (Boolean) -> Unit, - onTimePickerStateChanged: (Boolean) -> Unit, + onStartDatePickerStateChanged: (Boolean) -> Unit, + onStartTimePickerStateChanged: (Boolean) -> Unit, + onEndDatePickerStateChanged: (Boolean) -> Unit, + onEndTimePickerStateChanged: (Boolean) -> Unit, onLocationChanged: (String) -> Unit, onStartDateChanged: (LocalDate) -> Unit, onStartTimeChanged: (LocalTime) -> Unit, @@ -174,7 +180,7 @@ private fun EventScheduleContent( if (showEndDatePicker) { WappDatePickerDialog( date = endDate, - onDismissRequest = { onDatePickerStateChanged(false) }, + onDismissRequest = { onEndDatePickerStateChanged(false) }, onDateChanged = onEndDateChanged, ) } @@ -182,13 +188,13 @@ private fun EventScheduleContent( if (showEndTimePicker) { WappTimePickerDialog( state = timePickerState, - onDismissRequest = { onTimePickerStateChanged(false) }, + onDismissRequest = { onEndTimePickerStateChanged(false) }, onConfirmButtonClicked = { localTime -> onEndTimeChanged(localTime) - onTimePickerStateChanged(false) + onEndTimePickerStateChanged(false) }, onDismissButtonClicked = { - onTimePickerStateChanged(false) + onEndTimePickerStateChanged(false) }, ) } @@ -196,7 +202,7 @@ private fun EventScheduleContent( if (showStartDatePicker) { WappDatePickerDialog( date = startDate, - onDismissRequest = { onDatePickerStateChanged(false) }, + onDismissRequest = { onStartDatePickerStateChanged(false) }, onDateChanged = onStartDateChanged, ) } @@ -204,13 +210,13 @@ private fun EventScheduleContent( if (showStartTimePicker) { WappTimePickerDialog( state = timePickerState, - onDismissRequest = { onTimePickerStateChanged(false) }, + onDismissRequest = { onStartTimePickerStateChanged(false) }, onConfirmButtonClicked = { localTime -> onStartTimeChanged(localTime) - onTimePickerStateChanged(false) + onStartTimePickerStateChanged(false) }, onDismissButtonClicked = { - onTimePickerStateChanged(false) + onStartTimePickerStateChanged(false) }, ) } @@ -253,7 +259,7 @@ private fun EventScheduleContent( title = stringResource(R.string.start_date), hint = startDate.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), onCardClicked = { - onDatePickerStateChanged(true) + onStartDatePickerStateChanged(true) }, modifier = Modifier.padding(top = 20.dp), ) @@ -262,7 +268,7 @@ private fun EventScheduleContent( title = stringResource(R.string.start_time), hint = startTime.format(DateTimeFormatter.ofPattern("HH.mm")), onCardClicked = { - onTimePickerStateChanged(true) + onStartTimePickerStateChanged(true) }, modifier = Modifier.padding(top = 20.dp), ) @@ -271,7 +277,7 @@ private fun EventScheduleContent( title = stringResource(R.string.end_date), hint = endDate.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), onCardClicked = { - onDatePickerStateChanged(true) + onEndDatePickerStateChanged(true) }, modifier = Modifier.padding(top = 20.dp), ) @@ -280,7 +286,7 @@ private fun EventScheduleContent( title = stringResource(R.string.end_time), hint = endTime.format(DateTimeFormatter.ofPattern("HH.mm")), onCardClicked = { - onTimePickerStateChanged(true) + onEndTimePickerStateChanged(true) }, modifier = Modifier.padding(top = 20.dp), ) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt index 25eebb55..8e5c8b8e 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt @@ -176,8 +176,10 @@ internal fun EventRegistrationScreen( onStartTimeChanged = onStartTimeChanged, onEndDateChanged = onEndDateChanged, onEndTimeChanged = onEndTimeChanged, - onDatePickerStateChanged = { state -> showEndDatePicker = state }, - onTimePickerStateChanged = { state -> showEndTimePicker = state }, + onStartDatePickerStateChanged = { state -> showStartDatePicker = state }, + onStartTimePickerStateChanged = { state -> showStartTimePicker = state }, + onEndDatePickerStateChanged = { state -> showEndDatePicker = state }, + onEndTimePickerStateChanged = { state -> showEndTimePicker = state }, onNextButtonClicked = onNextButtonClicked, onRegisterButtonClicked = onRegisterButtonClicked, ) diff --git a/feature/management/src/main/res/values/strings.xml b/feature/management/src/main/res/values/strings.xml index 656b5800..3e9c5b56 100644 --- a/feature/management/src/main/res/values/strings.xml +++ b/feature/management/src/main/res/values/strings.xml @@ -38,6 +38,8 @@ 시작 시간 종료 날짜 종료 시간 + 날짜 + 시간 설문 제목 입력 설문을 이해하기 쉽도록 제목과 소개를 입력해주세요. 설문 제목 From 92241e1cdb323c10b83016f5f06c83961e47fe11 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Mon, 1 Jan 2024 23:20:04 +0900 Subject: [PATCH 21/31] =?UTF-8?q?[FEATURE]=20#69=20:=20DB=20Entity=20?= =?UTF-8?q?=EC=8B=9C=EC=9E=91=20=EB=82=A0=EC=A7=9C=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/event/EventRepository.kt | 4 ++-- .../repository/event/EventRepositoryImpl.kt | 8 ++++---- .../usecase/event/RegisterEventUseCase.kt | 11 +++++----- .../core/network/model/event/EventRequest.kt | 3 ++- .../network/source/event/EventDataSource.kt | 4 ++-- .../source/event/EventDataSourceImpl.kt | 10 ++++++---- .../event/EventRegistrationScreen.kt | 1 - .../event/EventRegistrationViewModel.kt | 20 ++++++++++++++++--- 8 files changed, 39 insertions(+), 22 deletions(-) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt index bbb377d7..dad4bd44 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt @@ -8,10 +8,10 @@ interface EventRepository { suspend fun getMonthEvents(date: LocalDate): Result> suspend fun postEvent( - date: LocalDate, eventTitle: String, eventContent: String, eventLocation: String, - eventDateTime: LocalDateTime, + eventStartDateTime: LocalDateTime, + eventEndDateTime: LocalDateTime, ): Result } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index 2e5dd73d..656676cc 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -18,17 +18,17 @@ class EventRepositoryImpl @Inject constructor( } override suspend fun postEvent( - date: LocalDate, eventTitle: String, eventContent: String, eventLocation: String, - eventDateTime: LocalDateTime, + eventStartDateTime: LocalDateTime, + eventEndDateTime: LocalDateTime, ): Result = eventDataSource.postEvent( - date = date, title = eventTitle, content = eventContent, location = eventLocation, - dateTime = eventDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), + startDateTime = eventStartDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), + endDateTime = eventEndDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), ) } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/RegisterEventUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/RegisterEventUseCase.kt index 5922d769..6950ad1b 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/RegisterEventUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/RegisterEventUseCase.kt @@ -10,19 +10,20 @@ class RegisterEventUseCase @Inject constructor( private val eventRepository: EventRepository, ) { suspend operator fun invoke( - date: LocalDate, eventTitle: String, eventContent: String, eventLocation: String, - eventDate: LocalDate, - eventTime: LocalTime, + eventStartDate: LocalDate, + eventStartTime: LocalTime, + eventEndDate: LocalDate, + eventEndTime: LocalTime, ): Result = runCatching { eventRepository.postEvent( - date = date, eventTitle = eventTitle, eventContent = eventContent, eventLocation = eventLocation, - eventDateTime = LocalDateTime.of(eventDate, eventTime), + eventStartDateTime = LocalDateTime.of(eventStartDate, eventStartTime), + eventEndDateTime = LocalDateTime.of(eventEndDate, eventEndTime), ) } } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt index fb9ce9d9..fde307bd 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventRequest.kt @@ -4,6 +4,7 @@ data class EventRequest( val title: String = "", val content: String = "", val location: String = "", - val dateTime: String = "", + val startDateTime: String = "", + val endDateTime: String = "", val eventId: String = "", ) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt index 4980b388..9687e62a 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt @@ -6,10 +6,10 @@ import java.time.LocalDate interface EventDataSource { suspend fun getMonthEvents(date: LocalDate): Result> suspend fun postEvent( - date: LocalDate, title: String, content: String, location: String, - dateTime: String, + startDateTime: String, + endDateTime: String, ): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index 79d56bef..771d8dbc 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -7,6 +7,7 @@ import com.wap.wapp.core.network.constant.SURVEY_COLLECTION import com.wap.wapp.core.network.model.event.EventRequest import com.wap.wapp.core.network.model.event.EventResponse import com.wap.wapp.core.network.utils.await +import com.wap.wapp.core.network.utils.toISOLocalDateTime import java.time.LocalDate import java.time.format.DateTimeFormatter import javax.inject.Inject @@ -34,11 +35,11 @@ class EventDataSourceImpl @Inject constructor( } override suspend fun postEvent( - date: LocalDate, title: String, content: String, location: String, - dateTime: String, + startDateTime: String, + endDateTime: String, ): Result = runCatching { val documentId = firebaseFirestore.collection(SURVEY_COLLECTION).document().id @@ -47,12 +48,13 @@ class EventDataSourceImpl @Inject constructor( title = title, content = content, location = location, - dateTime = dateTime, + startDateTime = startDateTime, + endDateTime = endDateTime, eventId = documentId, ) firebaseFirestore.collection(EVENT_COLLECTION) - .document(getMonth(date)) + .document(getMonth(startDateTime.toISOLocalDateTime().toLocalDate())) .collection(EVENT_COLLECTION) .document(documentId) .set(eventRequest) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt index 8e5c8b8e..bfec2f2d 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationScreen.kt @@ -35,7 +35,6 @@ import kotlinx.coroutines.flow.collectLatest import java.time.LocalDate import java.time.LocalTime -@OptIn(ExperimentalMaterial3Api::class) @Composable internal fun EventRegistrationRoute( viewModel: EventRegistrationViewModel = hiltViewModel(), diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt index 283ba820..3d7b6bcc 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt @@ -102,6 +102,19 @@ class EventRegistrationViewModel @Inject constructor( return } + if (_eventEndDate.value < _eventStartDate.value) { + emitValidationErrorMessage("종료 날짜는 시작 날짜와 같거나 더 늦어야 합니다.") + return + } + + if ( + (_eventEndDate.value == _eventStartDate.value) && + (_eventEndTime.value <= _eventStartTime.value) + ) { + emitValidationErrorMessage("종료 날짜는 시작 날짜와 같거나 더 늦어야 합니다.") + return + } + if (_eventEndDate.value <= generateNowDate()) { emitValidationErrorMessage("최소 하루 이상 일정 날짜를 지정하세요.") return @@ -109,12 +122,13 @@ class EventRegistrationViewModel @Inject constructor( viewModelScope.launch { registerEventUseCase( - date = _eventEndDate.value, eventTitle = _eventTitle.value, eventContent = _eventContent.value, eventLocation = _eventLocation.value, - eventDate = _eventEndDate.value, - eventTime = _eventEndTime.value, + eventStartDate = _eventStartDate.value, + eventStartTime = _eventStartTime.value, + eventEndDate = _eventEndDate.value, + eventEndTime = _eventEndTime.value, ).fold( onSuccess = { _eventRegistrationEvent.emit(EventRegistrationEvent.Success) }, onFailure = { throwable -> From ce1e79cbdec96719e31453ffb28f157d1856b12e Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 14:50:03 +0900 Subject: [PATCH 22/31] =?UTF-8?q?[FEATURE]=20#69=20:=20EventResponse?= =?UTF-8?q?=EB=8F=84=20StartDateTime,=20EndDateTime=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/model/event/Event.kt | 3 +- .../core/network/model/event/EventResponse.kt | 6 ++-- .../management/ManagementEventContent.kt | 2 +- .../event/EventRegistrationViewModel.kt | 35 +++++++++---------- .../survey/SurveyRegistrationViewModel.kt | 3 +- .../wapp/feature/notice/BottomSheetContent.kt | 4 +-- .../com/wap/wapp/feature/notice/Calendar.kt | 2 +- .../wapp/feature/notice/NoticeViewModel.kt | 2 +- .../wapp/feature/profile/ProfileViewModel.kt | 2 +- .../wapp/feature/survey/SurveyViewModel.kt | 2 -- 10 files changed, 30 insertions(+), 31 deletions(-) diff --git a/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt b/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt index 5dd04b88..af1a0cea 100644 --- a/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt +++ b/core/model/src/main/java/com/wap/wapp/core/model/event/Event.kt @@ -7,5 +7,6 @@ data class Event( val eventId: String, val location: String, val title: String, - val dateTime: LocalDateTime, + val startDateTime: LocalDateTime, + val endDateTime: LocalDateTime, ) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt index 9fe5af2d..468bc9fa 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/model/event/EventResponse.kt @@ -9,7 +9,8 @@ data class EventResponse( val eventId: String = "", val location: String = "", val title: String = "", - val dateTime: String = "", + val startDateTime: String = "", + val endDateTime: String = "", ) { private val formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd") @@ -18,6 +19,7 @@ data class EventResponse( eventId = eventId, location = location, title = title, - dateTime = dateTime.toISOLocalDateTime(), + startDateTime = startDateTime.toISOLocalDateTime(), + endDateTime = endDateTime.toISOLocalDateTime(), ) } diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt index 347ead74..0ada7463 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt @@ -120,7 +120,7 @@ private fun ManagementEventItem( ) Text( - text = item.dateTime.toString(), + text = item.endDateTime.toString(), style = WappTheme.typography.captionMedium, color = WappTheme.colors.white, maxLines = 1, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt index 3d7b6bcc..dbfc74da 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt @@ -51,7 +51,7 @@ class EventRegistrationViewModel @Inject constructor( val eventEndDate = _eventEndDate.asStateFlow() private val _eventEndTime: MutableStateFlow = - MutableStateFlow(DateUtil.generateNowTime()) + MutableStateFlow(DateUtil.generateNowTime().plusHours(1)) val eventEndTime = _eventEndTime.asStateFlow() fun setEventTitle(eventTitle: String) { @@ -67,6 +67,10 @@ class EventRegistrationViewModel @Inject constructor( } fun setEventStartDate(eventDate: LocalDate) { + if (eventDate <= generateNowDate()) { + emitValidationErrorMessage("최소 하루 이상 일정 날짜를 지정하세요.") + return + } _eventStartDate.value = eventDate } @@ -75,10 +79,21 @@ class EventRegistrationViewModel @Inject constructor( } fun setEventEndDate(eventDate: LocalDate) { + if (eventDate < _eventStartDate.value) { + emitValidationErrorMessage("종료 날짜는 시작 날짜와 같거나 더 늦어야 합니다.") + return + } _eventEndDate.value = eventDate } fun setEventEndTime(eventTime: LocalTime) { + if ( + (_eventEndDate.value == _eventStartDate.value) && + (eventTime <= _eventStartTime.value) + ) { + emitValidationErrorMessage("종료 날짜는 시작 날짜와 같거나 더 늦어야 합니다.") + return + } _eventEndTime.value = eventTime } @@ -102,24 +117,6 @@ class EventRegistrationViewModel @Inject constructor( return } - if (_eventEndDate.value < _eventStartDate.value) { - emitValidationErrorMessage("종료 날짜는 시작 날짜와 같거나 더 늦어야 합니다.") - return - } - - if ( - (_eventEndDate.value == _eventStartDate.value) && - (_eventEndTime.value <= _eventStartTime.value) - ) { - emitValidationErrorMessage("종료 날짜는 시작 날짜와 같거나 더 늦어야 합니다.") - return - } - - if (_eventEndDate.value <= generateNowDate()) { - emitValidationErrorMessage("최소 하루 이상 일정 날짜를 지정하세요.") - return - } - viewModelScope.launch { registerEventUseCase( eventTitle = _eventTitle.value, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt index 1fb38f06..98ca457b 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt @@ -209,6 +209,7 @@ class SurveyRegistrationViewModel @Inject constructor( companion object { const val EMPTY = "" - val EVENT_SELECTION_INIT: Event = Event("", "", "", "", DateUtil.generateNowDateTime()) + val EVENT_SELECTION_INIT: Event = + Event("", "", "", "", DateUtil.generateNowDateTime(), DateUtil.generateNowDateTime()) } } diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt index a06d9890..2340afb6 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt @@ -119,7 +119,7 @@ private fun EventItem(event: Event) { verticalAlignment = Alignment.CenterVertically, ) { Text( - text = event.dateTime.toString(), + text = event.endDateTime.toString(), style = WappTheme.typography.contentBold, color = WappTheme.colors.white, ) @@ -140,7 +140,7 @@ private fun EventItem(event: Event) { color = WappTheme.colors.white, ) Text( - text = event.dateTime.toString(), + text = event.endDateTime.toString(), style = WappTheme.typography.captionRegular, color = WappTheme.colors.grayBD, ) diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt index ca63a71d..6ecc2a95 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt @@ -141,7 +141,7 @@ private fun handleMonthEventsState( is NoticeViewModel.EventsState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) is NoticeViewModel.EventsState.Success -> { val eventDates = eventsState.events.map { - it.dateTime.toLocalDate() + it.endDateTime.toLocalDate() } CalendarBody( selectedDate = selectedDate, diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index 4ac18706..a9744e40 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -50,7 +50,7 @@ class NoticeViewModel @Inject constructor( _selectedDateEvents.value = EventsState.Success( it.filter { - it.dateTime.toLocalDate() == _selectedDate.value + it.endDateTime.toLocalDate() == _selectedDate.value }, ) }, diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 127e4a59..032bb038 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -31,7 +31,7 @@ class ProfileViewModel @Inject constructor( _todayEvents.value = EventsState.Success( it.filter { - it.dateTime == DateUtil.generateNowDateTime() + it.endDateTime == DateUtil.generateNowDateTime() }, ) }, diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyViewModel.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyViewModel.kt index 443c064f..f94f0d41 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyViewModel.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyViewModel.kt @@ -64,9 +64,7 @@ class SurveyViewModel @Inject constructor( sealed class SurveyUiEvent { data class Failure(val throwable: Throwable) : SurveyUiEvent() - data object AlreadySubmitted : SurveyUiEvent() - data class NotSubmitted(val eventId: String) : SurveyUiEvent() } } From ba26ef5dd3cb3478d6c0563a8d6500ca457fa268 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 14:58:43 +0900 Subject: [PATCH 23/31] =?UTF-8?q?[FEATURE]=20#69=20:=20=EC=9D=BC=EC=A0=95?= =?UTF-8?q?=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=94=94=EC=9E=90=EC=9D=B8?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=ED=99=94=EB=A9=B4=EC=97=90=20?= =?UTF-8?q?=EB=B3=B4=EC=97=AC=EC=A3=BC=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/wap/wapp/core/commmon/util/DateUtil.kt | 3 +++ .../wapp/feature/management/ManagementEventContent.kt | 2 +- .../com/wap/wapp/feature/notice/BottomSheetContent.kt | 9 ++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt b/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt index 1a502e2e..896aa9b5 100644 --- a/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt +++ b/core/common/src/main/java/com/wap/wapp/core/commmon/util/DateUtil.kt @@ -20,6 +20,9 @@ object DateUtil { const val MONTH_DATE_START_INDEX = 5 const val DAYS_IN_WEEK = 7 + // 현재 날짜에서 시간, 분만 반환해주는 포맷 ex 19:00 + val HHmmFormatter = DateTimeFormatter.ofPattern("HH:mm") + // 현재 날짜에서 일만 반환해주는 포맷 ex 2023-11-20 -> 20 val ddFormatter = DateTimeFormatter.ofPattern("dd") diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt index 0ada7463..e0bbf3b8 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementEventContent.kt @@ -120,7 +120,7 @@ private fun ManagementEventItem( ) Text( - text = item.endDateTime.toString(), + text = item.startDateTime.toLocalDate().toString(), style = WappTheme.typography.captionMedium, color = WappTheme.colors.white, maxLines = 1, diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt index 2340afb6..df47cf48 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt @@ -27,6 +27,8 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.wap.designsystem.WappTheme import com.wap.designsystem.component.CircleLoader +import com.wap.wapp.core.commmon.util.DateUtil +import com.wap.wapp.core.commmon.util.DateUtil.HHmmFormatter import com.wap.wapp.core.commmon.util.DateUtil.MONTH_DATE_START_INDEX import com.wap.wapp.core.commmon.util.DateUtil.yyyyMMddFormatter import com.wap.wapp.core.model.event.Event @@ -119,7 +121,7 @@ private fun EventItem(event: Event) { verticalAlignment = Alignment.CenterVertically, ) { Text( - text = event.endDateTime.toString(), + text = event.startDateTime.toLocalTime().format(DateUtil.HHmmFormatter), style = WappTheme.typography.contentBold, color = WappTheme.colors.white, ) @@ -140,7 +142,8 @@ private fun EventItem(event: Event) { color = WappTheme.colors.white, ) Text( - text = event.endDateTime.toString(), + text = event.startDateTime.format(HHmmFormatter) + " ~ " + + event.endDateTime.format(HHmmFormatter), style = WappTheme.typography.captionRegular, color = WappTheme.colors.grayBD, ) @@ -148,7 +151,7 @@ private fun EventItem(event: Event) { } Divider( color = WappTheme.colors.gray82, - thickness = (0.5).dp, + thickness = 1.dp, modifier = Modifier.padding(top = 15.dp), ) } From 6af73f3ec2b82a5c43c589971bbb28d3100accd4 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 17:49:04 +0900 Subject: [PATCH 24/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20=EB=84=88=EB=AC=B4?= =?UTF-8?q?=20=EA=B8=B4=20=EA=B5=AC=EB=AC=B8=20=EB=B3=80=EC=88=98=EB=A1=9C?= =?UTF-8?q?=20=EB=B9=BC=EC=84=9C=20=EA=B5=AC=EB=B6=84=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=89=BD=EB=8F=84=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 --- .../wap/wapp/core/network/source/event/EventDataSourceImpl.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index 771d8dbc..61c36d12 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -53,8 +53,10 @@ class EventDataSourceImpl @Inject constructor( eventId = documentId, ) + val startDate = startDateTime.toISOLocalDateTime().toLocalDate() + firebaseFirestore.collection(EVENT_COLLECTION) - .document(getMonth(startDateTime.toISOLocalDateTime().toLocalDate())) + .document(getMonth(startDate)) .collection(EVENT_COLLECTION) .document(documentId) .set(eventRequest) From 5163eaa7d9a141969e41080c054a26c823b6c29d Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 17:58:25 +0900 Subject: [PATCH 25/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20=EB=8B=AC=EB=A0=A5?= =?UTF-8?q?=20=EB=B6=80=EB=B6=84=20=EC=95=BD=EA=B0=84=EC=9D=98=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../registration/component/WappDatePickerDialog.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt index a27d4b41..239dea1d 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt @@ -55,10 +55,14 @@ internal fun WappDatePickerDialog( ) { var selectedDate by remember { mutableStateOf(date) } +// CalendarHeader는 2024-01과 같이 년 - 달을 표시해주고, +// 달을 이동할 수 있도록 해줍니다. CalendarHeader( selectedDate = selectedDate, onDateSelected = { date -> selectedDate = date }, ) + +// CalendarBody는 월,화,수,목,금,토,일의 상단 요일들을 포함한 캘린더가 들어가는 부분입니다. CalendarBody( selectedDate = selectedDate, onDateSelected = { date -> selectedDate = date }, @@ -139,7 +143,10 @@ private fun CalendarBody( selectedDate: LocalDate, onDateSelected: (LocalDate) -> Unit, ) { +// DayOfWeek는 일,월,화,수,목,금,토일과 같은 요일을 나타내주는 Composable입니다. DayOfWeek() + +// 실질적인 동적인 달력 데이터가 들어가는 부분입니다. CalendarMonthItem( selectedDate = selectedDate, onDateSelected = onDateSelected, @@ -177,6 +184,7 @@ private fun CalendarMonthItem( columns = GridCells.Fixed(DateUtil.DAYS_IN_WEEK), modifier = Modifier.fillMaxWidth(), ) { +// 이번 달 달력에 약간 보여지는 지난 달 데이터를 보여줍니다. val visibleDaysFromLastMonth = calculateVisibleDaysFromLastMonth(selectedDate) val beforeMonthDaysToShow = generateBeforeMonthDaysToShow( visibleDaysFromLastMonth, @@ -189,6 +197,7 @@ private fun CalendarMonthItem( ) } +// 이번 달 달력을 보여줍니다. val thisMonthLastDate = selectedDate.lengthOfMonth() val thisMonthFirstDayOfWeek = selectedDate.withDayOfMonth(1).dayOfWeek val thisMonthDaysToShow: List = (1..thisMonthLastDate).toList() @@ -209,6 +218,7 @@ private fun CalendarMonthItem( ) } +// 이번 달 달력에 약간 보여지는 다음 달 데이터를 보여줍니다. val remainingDays = DateUtil.DAYS_IN_WEEK - (visibleDaysFromLastMonth + thisMonthDaysToShow.size) % DateUtil.DAYS_IN_WEEK From f285487fb87857da2018644b07ec3c2d5c195fbb Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 18:01:30 +0900 Subject: [PATCH 26/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20DateTimeFormatter?= =?UTF-8?q?=20=EB=AF=B8=EB=A6=AC=20Util=EC=97=90=20=EB=A7=8C=EB=93=A4?= =?UTF-8?q?=EC=96=B4=EC=A7=84=20Formatter=20=ED=99=9C=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../registration/event/EventRegistrationContent.kt | 10 +++++----- .../survey/deadline/SurveyDeadlineContent.kt | 14 +++----------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt index 3615fbe7..4aa396b1 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationContent.kt @@ -18,6 +18,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappButton +import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.feature.management.R import com.wap.wapp.feature.management.registration.component.DeadlineCard import com.wap.wapp.feature.management.registration.component.RegistrationTextField @@ -26,7 +27,6 @@ import com.wap.wapp.feature.management.registration.component.WappDatePickerDial import com.wap.wapp.feature.management.registration.component.WappTimePickerDialog import java.time.LocalDate import java.time.LocalTime -import java.time.format.DateTimeFormatter @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -257,7 +257,7 @@ private fun EventScheduleContent( DeadlineCard( title = stringResource(R.string.start_date), - hint = startDate.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), + hint = startDate.format(DateUtil.yyyyMMddFormatter), onCardClicked = { onStartDatePickerStateChanged(true) }, @@ -266,7 +266,7 @@ private fun EventScheduleContent( DeadlineCard( title = stringResource(R.string.start_time), - hint = startTime.format(DateTimeFormatter.ofPattern("HH.mm")), + hint = startTime.format(DateUtil.HHmmFormatter), onCardClicked = { onStartTimePickerStateChanged(true) }, @@ -275,7 +275,7 @@ private fun EventScheduleContent( DeadlineCard( title = stringResource(R.string.end_date), - hint = endDate.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), + hint = endDate.format(DateUtil.yyyyMMddFormatter), onCardClicked = { onEndDatePickerStateChanged(true) }, @@ -284,7 +284,7 @@ private fun EventScheduleContent( DeadlineCard( title = stringResource(R.string.end_time), - hint = endTime.format(DateTimeFormatter.ofPattern("HH.mm")), + hint = endTime.format(DateUtil.HHmmFormatter), onCardClicked = { onEndTimePickerStateChanged(true) }, diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt index 23c73286..f1c55291 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/deadline/SurveyDeadlineContent.kt @@ -12,15 +12,13 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.wap.designsystem.component.WappButton import com.wap.designsystem.component.WappTitle +import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.feature.management.R import com.wap.wapp.feature.management.registration.component.DeadlineCard import com.wap.wapp.feature.management.registration.component.WappDatePickerDialog import com.wap.wapp.feature.management.registration.component.WappTimePickerDialog -import java.time.Instant import java.time.LocalDate import java.time.LocalTime -import java.time.ZoneId -import java.time.format.DateTimeFormatter @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -73,7 +71,7 @@ internal fun SurveyDeadlineContent( DeadlineCard( title = stringResource(R.string.date), - hint = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), + hint = date.format(DateUtil.yyyyMMddFormatter), onCardClicked = { onDatePickerStateChanged(true) }, @@ -82,7 +80,7 @@ internal fun SurveyDeadlineContent( DeadlineCard( title = stringResource(R.string.time), - hint = time.format(DateTimeFormatter.ofPattern("HH.mm")), + hint = time.format(DateUtil.HHmmFormatter), onCardClicked = { onTimePickerStateChanged(true) }, @@ -97,9 +95,3 @@ internal fun SurveyDeadlineContent( ) } } - -private fun Long.toLocalDate(): LocalDate { - val instant = Instant.ofEpochMilli(this) - val instantAtSeoul = instant.atZone(ZoneId.of("Asia/Seoul")) - return instantAtSeoul.toLocalDate() -} From a11d24763a5377470d94d60b268b13122dcbae52 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 18:16:12 +0900 Subject: [PATCH 27/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20Result=20fold=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/EventRegistrationViewModel.kt | 27 ++++----- .../survey/SurveyRegistrationViewModel.kt | 58 +++++++++---------- .../wapp/feature/notice/NoticeViewModel.kt | 15 ++--- 3 files changed, 43 insertions(+), 57 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt index dbfc74da..23634690 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/event/EventRegistrationViewModel.kt @@ -2,8 +2,8 @@ package com.wap.wapp.feature.management.registration.event import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.commmon.util.DateUtil.generateNowDate +import com.wap.wapp.core.commmon.util.DateUtil.generateNowTime import com.wap.wapp.core.domain.usecase.event.RegisterEventUseCase import com.wap.wapp.feature.management.registration.event.EventRegistrationState.EVENT_DETAILS import com.wap.wapp.feature.management.registration.event.EventRegistrationState.EVENT_SCHEDULE @@ -39,19 +39,19 @@ class EventRegistrationViewModel @Inject constructor( val eventLocation = _eventLocation.asStateFlow() private val _eventStartDate: MutableStateFlow = - MutableStateFlow(DateUtil.generateNowDate()) + MutableStateFlow(generateNowDate()) val eventStartDate = _eventStartDate.asStateFlow() private val _eventStartTime: MutableStateFlow = - MutableStateFlow(DateUtil.generateNowTime()) + MutableStateFlow(generateNowTime()) val eventStartTime = _eventStartTime.asStateFlow() private val _eventEndDate: MutableStateFlow = - MutableStateFlow(DateUtil.generateNowDate()) + MutableStateFlow(generateNowDate()) val eventEndDate = _eventEndDate.asStateFlow() private val _eventEndTime: MutableStateFlow = - MutableStateFlow(DateUtil.generateNowTime().plusHours(1)) + MutableStateFlow(generateNowTime().plusHours(1)) val eventEndTime = _eventEndTime.asStateFlow() fun setEventTitle(eventTitle: String) { @@ -87,10 +87,7 @@ class EventRegistrationViewModel @Inject constructor( } fun setEventEndTime(eventTime: LocalTime) { - if ( - (_eventEndDate.value == _eventStartDate.value) && - (eventTime <= _eventStartTime.value) - ) { + if (_eventEndDate.value == _eventStartDate.value && eventTime <= _eventStartTime.value) { emitValidationErrorMessage("종료 날짜는 시작 날짜와 같거나 더 늦어야 합니다.") return } @@ -116,7 +113,6 @@ class EventRegistrationViewModel @Inject constructor( emitValidationErrorMessage("장소를 입력하세요.") return } - viewModelScope.launch { registerEventUseCase( eventTitle = _eventTitle.value, @@ -126,12 +122,11 @@ class EventRegistrationViewModel @Inject constructor( eventStartTime = _eventStartTime.value, eventEndDate = _eventEndDate.value, eventEndTime = _eventEndTime.value, - ).fold( - onSuccess = { _eventRegistrationEvent.emit(EventRegistrationEvent.Success) }, - onFailure = { throwable -> - _eventRegistrationEvent.emit(EventRegistrationEvent.Failure(throwable)) - }, - ) + ).onSuccess { + _eventRegistrationEvent.emit(EventRegistrationEvent.Success) + }.onFailure { throwable -> + _eventRegistrationEvent.emit(EventRegistrationEvent.Failure(throwable)) + } } } diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt index 98ca457b..5c3a07a7 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/survey/SurveyRegistrationViewModel.kt @@ -95,41 +95,35 @@ class SurveyRegistrationViewModel @Inject constructor( _currentRegistrationState.value = surveyRegistrationState } - fun getEventList() { - viewModelScope.launch { - getEventListUseCase(DateUtil.generateNowDate()).fold( - onSuccess = { eventList -> - _eventList.value = eventList - }, - onFailure = { throwable -> - _surveyRegistrationEvent.emit(SurveyRegistrationEvent.Failure(throwable)) - }, - ) - } + fun getEventList() = viewModelScope.launch { + getEventListUseCase(DateUtil.generateNowDate()) + .onSuccess { eventList -> + _eventList.value = eventList + }.onFailure { throwable -> + _surveyRegistrationEvent.emit(SurveyRegistrationEvent.Failure(throwable)) + } } - fun registerSurvey() { - viewModelScope.launch { - if (isValidDeadline()) { - registerSurveyUseCase( - event = surveyEventSelection.value, - title = _surveyTitle.value, - content = _surveyContent.value, - surveyQuestionList = _surveyQuestionList.value, - deadlineDate = _surveyDateDeadline.value, - deadlineTime = _surveyTimeDeadline.value, - ).onSuccess { - _surveyRegistrationEvent.emit(SurveyRegistrationEvent.Success) - }.onFailure { throwable -> - _surveyRegistrationEvent.emit(SurveyRegistrationEvent.Failure(throwable)) - } - } else { - _surveyRegistrationEvent.emit( - SurveyRegistrationEvent.ValidationError( - "최소 하루 이상 설문 날짜를 지정하세요.", - ), - ) + fun registerSurvey() = viewModelScope.launch { + if (isValidDeadline()) { + registerSurveyUseCase( + event = surveyEventSelection.value, + title = _surveyTitle.value, + content = _surveyContent.value, + surveyQuestionList = _surveyQuestionList.value, + deadlineDate = _surveyDateDeadline.value, + deadlineTime = _surveyTimeDeadline.value, + ).onSuccess { + _surveyRegistrationEvent.emit(SurveyRegistrationEvent.Success) + }.onFailure { throwable -> + _surveyRegistrationEvent.emit(SurveyRegistrationEvent.Failure(throwable)) } + } else { + _surveyRegistrationEvent.emit( + SurveyRegistrationEvent.ValidationError( + "최소 하루 이상 설문 날짜를 지정하세요.", + ), + ) } } diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index a9744e40..dc6625c4 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -35,27 +35,24 @@ class NoticeViewModel @Inject constructor( private fun getMonthEvents() { _monthEvents.value = EventsState.Loading viewModelScope.launch { - getEventListUseCase(_selectedDate.value).fold( - onSuccess = { _monthEvents.value = EventsState.Success(it) }, - onFailure = { _monthEvents.value = EventsState.Failure(it) }, - ) + getEventListUseCase(_selectedDate.value) + .onSuccess { _monthEvents.value = EventsState.Success(it) } + .onFailure { _monthEvents.value = EventsState.Failure(it) } } } fun getSelectedDateEvents() { _selectedDateEvents.value = EventsState.Loading viewModelScope.launch { - getEventListUseCase(_selectedDate.value).fold( - onSuccess = { + getEventListUseCase(_selectedDate.value) + .onSuccess { _selectedDateEvents.value = EventsState.Success( it.filter { it.endDateTime.toLocalDate() == _selectedDate.value }, ) - }, - onFailure = { _selectedDateEvents.value = EventsState.Failure(it) }, - ) + }.onFailure { _selectedDateEvents.value = EventsState.Failure(it) } } } From 7e6b4bc06b543094d3b02621ed207aefdaa4b40f Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 18:21:39 +0900 Subject: [PATCH 28/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EA=B0=9C=ED=96=89=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/domain/usecase/auth/SignInUseCase.kt | 5 +---- .../management/ValidateManagementCodeUseCase.kt | 11 +++-------- .../usecase/survey/IsSubmittedSurveyUseCase.kt | 5 +---- .../com/wap/wapp/feature/notice/NoticeViewModel.kt | 14 +++++--------- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt index 6abb2d36..c66764a7 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt @@ -6,7 +6,6 @@ import com.wap.wapp.core.domain.model.AuthState import com.wap.wapp.core.domain.model.AuthState.SIGN_IN import com.wap.wapp.core.domain.model.AuthState.SIGN_UP import dagger.hilt.android.scopes.ActivityScoped -import java.lang.IllegalStateException import javax.inject.Inject @ActivityScoped @@ -29,9 +28,7 @@ class SignInUseCase @Inject constructor( // 그 외의 예외인 경우 throw (exception) }, - onSuccess = { - SIGN_IN - }, + onSuccess = { SIGN_IN }, ) } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt index 6ff6d627..f28f3be2 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt @@ -22,14 +22,9 @@ class ValidateManagementCodeUseCase @Inject constructor( // 운영진 등록 val userId = userRepository.getUserId().getOrThrow() - managementRepository.postManager(userId) - .fold( - onSuccess = { - CodeValidation.VALID - }, - onFailure = { exception -> - throw(exception) - }, + managementRepository.postManager(userId).fold( + onSuccess = { CodeValidation.VALID }, + onFailure = { exception -> throw(exception) }, ) } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt index 5b81e5f0..babd4b20 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt @@ -12,10 +12,7 @@ class IsSubmittedSurveyUseCase @Inject constructor( return runCatching { val userId = userRepository.getUserId().getOrThrow() - surveyRepository.isSubmittedSurvey( - userId = userId, - eventId = eventId, - ).getOrThrow() + surveyRepository.isSubmittedSurvey(userId = userId, eventId = eventId).getOrThrow() } } } diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index dc6625c4..8cd9ee81 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -44,15 +44,11 @@ class NoticeViewModel @Inject constructor( fun getSelectedDateEvents() { _selectedDateEvents.value = EventsState.Loading viewModelScope.launch { - getEventListUseCase(_selectedDate.value) - .onSuccess { - _selectedDateEvents.value = - EventsState.Success( - it.filter { - it.endDateTime.toLocalDate() == _selectedDate.value - }, - ) - }.onFailure { _selectedDateEvents.value = EventsState.Failure(it) } + getEventListUseCase(_selectedDate.value).onSuccess { + _selectedDateEvents.value = EventsState.Success( + it.filter { it.endDateTime.toLocalDate() == _selectedDate.value }, + ) + }.onFailure { _selectedDateEvents.value = EventsState.Failure(it) } } } From 3f87779811a2f898aa2499e5ee9725ea865d913e Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 18:27:43 +0900 Subject: [PATCH 29/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20Kotlin=20=EB=8B=A8?= =?UTF-8?q?=EC=9D=BC=20=ED=91=9C=ED=98=84=EC=8B=9D=20=EC=BD=94=ED=8B=80?= =?UTF-8?q?=EB=A6=B0=20=EC=BB=A8=EB=B2=A4=EC=85=98=20=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?=EC=95=88=EB=90=9C=20=EB=B6=80=EB=B6=84=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/auth/AuthRepositoryImpl.kt | 16 +--- .../management/ManagementRepositoryImpl.kt | 15 ++-- .../survey/SurveyFormRepositoryImpl.kt | 10 +-- .../repository/survey/SurveyRepositoryImpl.kt | 33 +++---- .../repository/user/UserRepositoryImpl.kt | 27 +++--- .../core/domain/usecase/auth/SignInUseCase.kt | 32 ++++--- .../management/HasManagerStateUseCase.kt | 14 ++- .../management/RegisterSurveyUseCase.kt | 22 +++-- .../ValidateManagementCodeUseCase.kt | 26 +++--- .../survey/IsSubmittedSurveyUseCase.kt | 8 +- .../usecase/survey/PostSurveyUseCase.kt | 22 +++-- .../usecase/user/PostUserProfileUseCase.kt | 18 ++-- .../management/ManagementDataSourceImpl.kt | 44 ++++----- .../source/survey/SurveyDataSourceImpl.kt | 90 +++++++++---------- .../source/survey/SurveyFormDataSourceImpl.kt | 56 ++++++------ 15 files changed, 188 insertions(+), 245 deletions(-) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepositoryImpl.kt index e7b7815f..364c189f 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/auth/AuthRepositoryImpl.kt @@ -6,19 +6,11 @@ import javax.inject.Inject class AuthRepositoryImpl @Inject constructor( private val authDataSource: AuthDataSource, ) : AuthRepository { - override suspend fun hasPendingResult(): Boolean { - return authDataSource.hasPendingResult() - } + override suspend fun hasPendingResult(): Boolean = authDataSource.hasPendingResult() - override suspend fun signIn(email: String): Result { - return authDataSource.signIn(email) - } + override suspend fun signIn(email: String): Result = authDataSource.signIn(email) - override suspend fun signOut(): Result { - return authDataSource.signOut() - } + override suspend fun signOut(): Result = authDataSource.signOut() - override suspend fun deleteUser(): Result { - return authDataSource.deleteUser() - } + override suspend fun deleteUser(): Result = authDataSource.deleteUser() } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepositoryImpl.kt index ee000570..05e3afed 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/management/ManagementRepositoryImpl.kt @@ -6,15 +6,12 @@ import javax.inject.Inject class ManagementRepositoryImpl @Inject constructor( private val managementDataSource: ManagementDataSource, ) : ManagementRepository { - override suspend fun getManager(userId: String): Result { - return managementDataSource.getManager(userId) - } + override suspend fun getManager(userId: String): Result = + managementDataSource.getManager(userId) - override suspend fun postManager(userId: String): Result { - return managementDataSource.postManager(userId) - } + override suspend fun postManager(userId: String): Result = + managementDataSource.postManager(userId) - override suspend fun getManagementCode(code: String): Result { - return managementDataSource.getManagementCode(code) - } + override suspend fun getManagementCode(code: String): Result = + managementDataSource.getManagementCode(code) } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyFormRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyFormRepositoryImpl.kt index 1bb911f7..a7706b46 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyFormRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyFormRepositoryImpl.kt @@ -14,16 +14,15 @@ class SurveyFormRepositoryImpl @Inject constructor( surveyFormResponse.toDomain() } - override suspend fun getSurveyFormList(): Result> { - return surveyFormDataSource.getSurveyFormList().mapCatching { surveyFormResponseList -> + override suspend fun getSurveyFormList(): Result> = + surveyFormDataSource.getSurveyFormList().mapCatching { surveyFormResponseList -> surveyFormResponseList.map { surveyFormResponse -> surveyFormResponse.toDomain() } } - } - override suspend fun postSurveyForm(surveyForm: SurveyForm): Result { - return surveyFormDataSource.postSurveyForm( + override suspend fun postSurveyForm(surveyForm: SurveyForm): Result = + surveyFormDataSource.postSurveyForm( surveyFormRequest = SurveyFormRequest( eventId = surveyForm.eventId, title = surveyForm.title, @@ -32,5 +31,4 @@ class SurveyFormRepositoryImpl @Inject constructor( deadline = surveyForm.deadline.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), ), ) - } } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt index 5dc0ecc5..bc65affb 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt @@ -12,8 +12,8 @@ class SurveyRepositoryImpl @Inject constructor( private val surveyDataSource: SurveyDataSource, private val userDataSource: UserDataSource, ) : SurveyRepository { - override suspend fun getSurveyList(): Result> { - return surveyDataSource.getSurveyList().mapCatching { surveyList -> + override suspend fun getSurveyList(): Result> = + surveyDataSource.getSurveyList().mapCatching { surveyList -> surveyList.map { surveyResponse -> userDataSource.getUserProfile(userId = surveyResponse.userId) .mapCatching { userProfileResponse -> @@ -27,10 +27,9 @@ class SurveyRepositoryImpl @Inject constructor( }.getOrThrow() } } - } - override suspend fun getSurvey(surveyId: String): Result { - return surveyDataSource.getSurvey(surveyId).mapCatching { surveyResponse -> + override suspend fun getSurvey(surveyId: String): Result = + surveyDataSource.getSurvey(surveyId).mapCatching { surveyResponse -> userDataSource.getUserProfile(userId = surveyResponse.userId) .mapCatching { userProfileResponse -> val userName = userProfileResponse.toDomain().userName @@ -42,7 +41,6 @@ class SurveyRepositoryImpl @Inject constructor( }.getOrThrow() }.getOrThrow() } - } override suspend fun postSurvey( eventId: String, @@ -51,20 +49,17 @@ class SurveyRepositoryImpl @Inject constructor( content: String, surveyAnswerList: List, surveyedAt: LocalDateTime, - ): Result { - return surveyDataSource.postSurvey( - eventId = eventId, - userId = userId, - title = title, - content = content, - surveyAnswerList = surveyAnswerList, - surveyedAt = surveyedAt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), - ) - } + ): Result = surveyDataSource.postSurvey( + eventId = eventId, + userId = userId, + title = title, + content = content, + surveyAnswerList = surveyAnswerList, + surveyedAt = surveyedAt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), + ) - override suspend fun isSubmittedSurvey(eventId: String, userId: String): Result { - return surveyDataSource.isSubmittedSurvey(eventId, userId) - } + override suspend fun isSubmittedSurvey(eventId: String, userId: String): Result = + surveyDataSource.isSubmittedSurvey(eventId, userId) private val noticeNameResponse: Result = Result.success("notice datasource dummy data") diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.kt index efa25af4..d4255759 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.kt @@ -8,29 +8,24 @@ import javax.inject.Inject class UserRepositoryImpl @Inject constructor( private val userDataSource: UserDataSource, ) : UserRepository { - override suspend fun getUserProfile(userId: String): Result { - return userDataSource.getUserProfile(userId).mapCatching { response -> + override suspend fun getUserProfile(userId: String): Result = + userDataSource.getUserProfile(userId).mapCatching { response -> response.toDomain() } - } - override suspend fun getUserId(): Result { - return userDataSource.getUserId() - } + override suspend fun getUserId(): Result = userDataSource.getUserId() override suspend fun postUserProfile( userId: String, userName: String, studentId: String, registeredAt: String, - ): Result { - return userDataSource.postUserProfile( - UserProfileRequest( - userId = userId, - userName = userName, - studentId = studentId, - registeredAt = registeredAt, - ), - ) - } + ): Result = userDataSource.postUserProfile( + UserProfileRequest( + userId = userId, + userName = userName, + studentId = studentId, + registeredAt = registeredAt, + ), + ) } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt index c66764a7..d8d570bd 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.kt @@ -13,23 +13,21 @@ class SignInUseCase @Inject constructor( private val authRepository: AuthRepository, private val userRepository: UserRepository, ) { - suspend operator fun invoke(email: String): Result { - return runCatching { - val userId = authRepository.signIn(email) - .getOrThrow() + suspend operator fun invoke(email: String): Result = runCatching { + val userId = authRepository.signIn(email) + .getOrThrow() - userRepository.getUserProfile(userId) - .fold( - onFailure = { exception -> - // 등록되지 않은 사용자인 경우 - if (exception is IllegalStateException) { - return@fold SIGN_UP - } - // 그 외의 예외인 경우 - throw (exception) - }, - onSuccess = { SIGN_IN }, - ) - } + userRepository.getUserProfile(userId) + .fold( + onFailure = { exception -> + // 등록되지 않은 사용자인 경우 + if (exception is IllegalStateException) { + return@fold SIGN_UP + } + // 그 외의 예외인 경우 + throw (exception) + }, + onSuccess = { SIGN_IN }, + ) } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/HasManagerStateUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/HasManagerStateUseCase.kt index acf326eb..23c3c573 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/HasManagerStateUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/HasManagerStateUseCase.kt @@ -10,14 +10,12 @@ class HasManagerStateUseCase @Inject constructor( private val managementRepository: ManagementRepository, private val userRepository: UserRepository, ) { - suspend operator fun invoke(): Result { - return runCatching { - val userId = userRepository.getUserId().getOrThrow() + suspend operator fun invoke(): Result = runCatching { + val userId = userRepository.getUserId().getOrThrow() - managementRepository.getManager(userId).fold( - onSuccess = { hasManagerState -> hasManagerState }, - onFailure = { throw(it) }, - ) - } + managementRepository.getManager(userId).fold( + onSuccess = { hasManagerState -> hasManagerState }, + onFailure = { throw (it) }, + ) } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/RegisterSurveyUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/RegisterSurveyUseCase.kt index de3693f1..3ad997fb 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/RegisterSurveyUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/RegisterSurveyUseCase.kt @@ -19,17 +19,15 @@ class RegisterSurveyUseCase @Inject constructor( surveyQuestionList: List, deadlineDate: LocalDate, deadlineTime: LocalTime, - ): Result { - return runCatching { - surveyFormRepository.postSurveyForm( - SurveyForm( - eventId = event.eventId, - title = title, - content = content, - surveyQuestionList = surveyQuestionList, - deadline = LocalDateTime.of(deadlineDate, deadlineTime), - ), - ) - } + ): Result = runCatching { + surveyFormRepository.postSurveyForm( + SurveyForm( + eventId = event.eventId, + title = title, + content = content, + surveyQuestionList = surveyQuestionList, + deadline = LocalDateTime.of(deadlineDate, deadlineTime), + ), + ) } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt index f28f3be2..d9a52fcb 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/management/ValidateManagementCodeUseCase.kt @@ -11,21 +11,19 @@ class ValidateManagementCodeUseCase @Inject constructor( private val managementRepository: ManagementRepository, private val userRepository: UserRepository, ) { - suspend operator fun invoke(code: String): Result { - return runCatching { - managementRepository.getManagementCode(code) - .onSuccess { isValid -> - if (isValid.not()) { // 코드가 틀렸을 경우 - return@runCatching CodeValidation.INVALID - } + suspend operator fun invoke(code: String): Result = runCatching { + managementRepository.getManagementCode(code) + .onSuccess { isValid -> + if (isValid.not()) { // 코드가 틀렸을 경우 + return@runCatching CodeValidation.INVALID } + } - // 운영진 등록 - val userId = userRepository.getUserId().getOrThrow() - managementRepository.postManager(userId).fold( - onSuccess = { CodeValidation.VALID }, - onFailure = { exception -> throw(exception) }, - ) - } + // 운영진 등록 + val userId = userRepository.getUserId().getOrThrow() + managementRepository.postManager(userId).fold( + onSuccess = { CodeValidation.VALID }, + onFailure = { exception -> throw (exception) }, + ) } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt index babd4b20..f30f31ff 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/IsSubmittedSurveyUseCase.kt @@ -8,11 +8,9 @@ class IsSubmittedSurveyUseCase @Inject constructor( private val userRepository: UserRepository, private val surveyRepository: SurveyRepository, ) { - suspend operator fun invoke(eventId: String): Result { - return runCatching { - val userId = userRepository.getUserId().getOrThrow() + suspend operator fun invoke(eventId: String): Result = runCatching { + val userId = userRepository.getUserId().getOrThrow() - surveyRepository.isSubmittedSurvey(userId = userId, eventId = eventId).getOrThrow() - } + surveyRepository.isSubmittedSurvey(userId = userId, eventId = eventId).getOrThrow() } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/PostSurveyUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/PostSurveyUseCase.kt index 8e89f014..48436af4 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/PostSurveyUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/PostSurveyUseCase.kt @@ -15,18 +15,16 @@ class PostSurveyUseCase @Inject constructor( title: String, content: String, surveyAnswerList: List, - ): Result { - return runCatching { - val userId = userRepository.getUserId().getOrThrow() + ): Result = runCatching { + val userId = userRepository.getUserId().getOrThrow() - surveyRepository.postSurvey( - userId = userId, - eventId = eventId, - title = title, - content = content, - surveyAnswerList = surveyAnswerList, - surveyedAt = LocalDateTime.now(), - ) - } + surveyRepository.postSurvey( + userId = userId, + eventId = eventId, + title = title, + content = content, + surveyAnswerList = surveyAnswerList, + surveyedAt = LocalDateTime.now(), + ) } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt index b72ade90..d6c9b71a 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.kt @@ -12,16 +12,14 @@ class PostUserProfileUseCase @Inject constructor( userName: String, studentId: String, registeredAt: String, - ): Result { - return runCatching { - val userId = userRepository.getUserId().getOrThrow() + ): Result = runCatching { + val userId = userRepository.getUserId().getOrThrow() - userRepository.postUserProfile( - userId = userId, - userName = userName, - studentId = studentId, - registeredAt = registeredAt, - ) - } + userRepository.postUserProfile( + userId = userId, + userName = userName, + studentId = studentId, + registeredAt = registeredAt, + ) } } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSourceImpl.kt index adbcb187..1d166301 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/management/ManagementDataSourceImpl.kt @@ -10,37 +10,31 @@ import javax.inject.Inject class ManagementDataSourceImpl @Inject constructor( private val firebaseFirestore: FirebaseFirestore, ) : ManagementDataSource { - override suspend fun getManager(userId: String): Result { - return runCatching { - val result = firebaseFirestore.collection(MANAGER_COLLECTION) - .whereEqualTo("userId", userId) - .get() - .await() + override suspend fun getManager(userId: String): Result = runCatching { + val result = firebaseFirestore.collection(MANAGER_COLLECTION) + .whereEqualTo("userId", userId) + .get() + .await() - result.isEmpty.not() - } + result.isEmpty.not() } - override suspend fun postManager(userId: String): Result { - return runCatching { - val userIdMap = mapOf("userId" to userId) - val setOption = SetOptions.merge() + override suspend fun postManager(userId: String): Result = runCatching { + val userIdMap = mapOf("userId" to userId) + val setOption = SetOptions.merge() - firebaseFirestore.collection(MANAGER_COLLECTION) - .document(userId) - .set(userIdMap, setOption) - .await() - } + firebaseFirestore.collection(MANAGER_COLLECTION) + .document(userId) + .set(userIdMap, setOption) + .await() } - override suspend fun getManagementCode(code: String): Result { - return runCatching { - val result = firebaseFirestore.collection(CODES_COLLECTION) - .whereEqualTo("management", code) - .get() - .await() + override suspend fun getManagementCode(code: String): Result = runCatching { + val result = firebaseFirestore.collection(CODES_COLLECTION) + .whereEqualTo("management", code) + .get() + .await() - result.isEmpty.not() - } + result.isEmpty.not() } } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt index 8fcef26a..8d292bec 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt @@ -12,35 +12,31 @@ import javax.inject.Inject class SurveyDataSourceImpl @Inject constructor( private val firebaseFirestore: FirebaseFirestore, ) : SurveyDataSource { - override suspend fun getSurveyList(): Result> { - return runCatching { - val result: MutableList = mutableListOf() + override suspend fun getSurveyList(): Result> = runCatching { + val result: MutableList = mutableListOf() - val task = firebaseFirestore.collection(SURVEY_COLLECTION) - .get() - .await() + val task = firebaseFirestore.collection(SURVEY_COLLECTION) + .get() + .await() - for (document in task.documents) { - val surveyResponse = document.toObject(SurveyResponse::class.java) - checkNotNull(surveyResponse) - - result.add(surveyResponse) - } + for (document in task.documents) { + val surveyResponse = document.toObject(SurveyResponse::class.java) + checkNotNull(surveyResponse) - result + result.add(surveyResponse) } + + result } - override suspend fun getSurvey(surveyId: String): Result { - return runCatching { - val result = firebaseFirestore.collection(SURVEY_COLLECTION) - .document(surveyId) - .get() - .await() + override suspend fun getSurvey(surveyId: String): Result = runCatching { + val result = firebaseFirestore.collection(SURVEY_COLLECTION) + .document(surveyId) + .get() + .await() - val surveyResponse = result.toObject(SurveyResponse::class.java) - checkNotNull(surveyResponse) - } + val surveyResponse = result.toObject(SurveyResponse::class.java) + checkNotNull(surveyResponse) } override suspend fun postSurvey( @@ -50,40 +46,36 @@ class SurveyDataSourceImpl @Inject constructor( content: String, surveyAnswerList: List, surveyedAt: String, - ): Result { - return runCatching { - val documentId = firebaseFirestore.collection(SURVEY_COLLECTION).document().id + ): Result = runCatching { + val documentId = firebaseFirestore.collection(SURVEY_COLLECTION).document().id - val surveyRequest = SurveyRequest( - surveyId = documentId, - eventId = eventId, - userId = userId, - title = title, - content = content, - surveyAnswerList = surveyAnswerList, - surveyedAt = surveyedAt, - ) - val setOption = SetOptions.merge() + val surveyRequest = SurveyRequest( + surveyId = documentId, + eventId = eventId, + userId = userId, + title = title, + content = content, + surveyAnswerList = surveyAnswerList, + surveyedAt = surveyedAt, + ) + val setOption = SetOptions.merge() - firebaseFirestore.collection(SURVEY_COLLECTION) - .document(documentId) - .set(surveyRequest, setOption) - .await() - } + firebaseFirestore.collection(SURVEY_COLLECTION) + .document(documentId) + .set(surveyRequest, setOption) + .await() } override suspend fun isSubmittedSurvey( eventId: String, userId: String, - ): Result { - return runCatching { - val result = firebaseFirestore.collection(SURVEY_COLLECTION) - .whereEqualTo("eventId", eventId) - .whereEqualTo("userId", userId) - .get() - .await() + ): Result = runCatching { + val result = firebaseFirestore.collection(SURVEY_COLLECTION) + .whereEqualTo("eventId", eventId) + .whereEqualTo("userId", userId) + .get() + .await() - result.isEmpty.not() - } + result.isEmpty.not() } } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyFormDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyFormDataSourceImpl.kt index 6d11af78..227308af 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyFormDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyFormDataSourceImpl.kt @@ -11,46 +11,40 @@ import javax.inject.Inject class SurveyFormDataSourceImpl @Inject constructor( private val firebaseFirestore: FirebaseFirestore, ) : SurveyFormDataSource { - override suspend fun getSurveyForm(eventId: Int): Result { - return runCatching { - val result = firebaseFirestore.collection(SURVEY_FORM_COLLECTION) - .document(eventId.toString()) - .get() - .await() - - val surveyFormResponse = result.toObject(SurveyFormResponse::class.java) - checkNotNull(surveyFormResponse) - } + override suspend fun getSurveyForm(eventId: Int): Result = runCatching { + val result = firebaseFirestore.collection(SURVEY_FORM_COLLECTION) + .document(eventId.toString()) + .get() + .await() + + val surveyFormResponse = result.toObject(SurveyFormResponse::class.java) + checkNotNull(surveyFormResponse) } - override suspend fun getSurveyFormList(): Result> { - return runCatching { - val result: MutableList = mutableListOf() - - val task = firebaseFirestore.collection(SURVEY_FORM_COLLECTION) - .get() - .await() + override suspend fun getSurveyFormList(): Result> = runCatching { + val result: MutableList = mutableListOf() - for (document in task.documents) { - val surveyFormResponse = document.toObject(SurveyFormResponse::class.java) - checkNotNull(surveyFormResponse) + val task = firebaseFirestore.collection(SURVEY_FORM_COLLECTION) + .get() + .await() - result.add(surveyFormResponse) - } + for (document in task.documents) { + val surveyFormResponse = document.toObject(SurveyFormResponse::class.java) + checkNotNull(surveyFormResponse) - result + result.add(surveyFormResponse) } + + result } override suspend fun postSurveyForm( surveyFormRequest: SurveyFormRequest, - ): Result { - return runCatching { - val setOption = SetOptions.merge() - firebaseFirestore.collection(SURVEY_FORM_COLLECTION) - .document(surveyFormRequest.eventId.toString()) - .set(surveyFormRequest, setOption) - .await() - } + ): Result = runCatching { + val setOption = SetOptions.merge() + firebaseFirestore.collection(SURVEY_FORM_COLLECTION) + .document(surveyFormRequest.eventId.toString()) + .set(surveyFormRequest, setOption) + .await() } } From fc17542f590cf9ea244f4fa6e42c19daa1d0edc5 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 18:33:41 +0900 Subject: [PATCH 30/31] =?UTF-8?q?[REFACTOR]=20#69=20:=20LocalDateTime=20->?= =?UTF-8?q?=20String=20Uitl=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/data/repository/event/EventRepositoryImpl.kt | 6 +++--- .../data/repository/survey/SurveyFormRepositoryImpl.kt | 4 ++-- .../core/data/repository/survey/SurveyRepositoryImpl.kt | 4 ++-- .../java/com/wap/wapp/core/data/utils/LocalDateTime.kt | 7 +++++++ 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 core/data/src/main/java/com/wap/wapp/core/data/utils/LocalDateTime.kt diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index 656676cc..c2327f7e 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -1,10 +1,10 @@ package com.wap.wapp.core.data.repository.event +import com.wap.wapp.core.data.utils.toISOLocalDateTimeString import com.wap.wapp.core.model.event.Event import com.wap.wapp.core.network.source.event.EventDataSource import java.time.LocalDate import java.time.LocalDateTime -import java.time.format.DateTimeFormatter import javax.inject.Inject class EventRepositoryImpl @Inject constructor( @@ -28,7 +28,7 @@ class EventRepositoryImpl @Inject constructor( title = eventTitle, content = eventContent, location = eventLocation, - startDateTime = eventStartDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), - endDateTime = eventEndDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), + startDateTime = eventStartDateTime.toISOLocalDateTimeString(), + endDateTime = eventEndDateTime.toISOLocalDateTimeString(), ) } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyFormRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyFormRepositoryImpl.kt index a7706b46..38fe5848 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyFormRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyFormRepositoryImpl.kt @@ -1,9 +1,9 @@ package com.wap.wapp.core.data.repository.survey +import com.wap.wapp.core.data.utils.toISOLocalDateTimeString import com.wap.wapp.core.model.survey.SurveyForm import com.wap.wapp.core.network.model.survey.form.SurveyFormRequest import com.wap.wapp.core.network.source.survey.SurveyFormDataSource -import java.time.format.DateTimeFormatter import javax.inject.Inject class SurveyFormRepositoryImpl @Inject constructor( @@ -28,7 +28,7 @@ class SurveyFormRepositoryImpl @Inject constructor( title = surveyForm.title, content = surveyForm.content, surveyQuestionList = surveyForm.surveyQuestionList, - deadline = surveyForm.deadline.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), + deadline = surveyForm.deadline.toISOLocalDateTimeString(), ), ) } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt index bc65affb..349d9c4f 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt @@ -1,11 +1,11 @@ package com.wap.wapp.core.data.repository.survey +import com.wap.wapp.core.data.utils.toISOLocalDateTimeString import com.wap.wapp.core.model.survey.Survey import com.wap.wapp.core.model.survey.SurveyAnswer import com.wap.wapp.core.network.source.survey.SurveyDataSource import com.wap.wapp.core.network.source.user.UserDataSource import java.time.LocalDateTime -import java.time.format.DateTimeFormatter import javax.inject.Inject class SurveyRepositoryImpl @Inject constructor( @@ -55,7 +55,7 @@ class SurveyRepositoryImpl @Inject constructor( title = title, content = content, surveyAnswerList = surveyAnswerList, - surveyedAt = surveyedAt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), + surveyedAt = surveyedAt.toISOLocalDateTimeString(), ) override suspend fun isSubmittedSurvey(eventId: String, userId: String): Result = diff --git a/core/data/src/main/java/com/wap/wapp/core/data/utils/LocalDateTime.kt b/core/data/src/main/java/com/wap/wapp/core/data/utils/LocalDateTime.kt new file mode 100644 index 00000000..b80ec5bc --- /dev/null +++ b/core/data/src/main/java/com/wap/wapp/core/data/utils/LocalDateTime.kt @@ -0,0 +1,7 @@ +package com.wap.wapp.core.data.utils + +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +internal fun LocalDateTime.toISOLocalDateTimeString(): String = + this.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) From f027b29b8e4e58ec28015a189840fd968a223340 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 2 Jan 2024 18:39:25 +0900 Subject: [PATCH 31/31] [REFACTOR] #69 : DayOfWeek -> CalendarWeekDays --- .../registration/component/WappDatePickerDialog.kt | 6 +++--- .../src/main/java/com/wap/wapp/feature/notice/Calendar.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt index 239dea1d..45de1bcc 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/registration/component/WappDatePickerDialog.kt @@ -143,8 +143,8 @@ private fun CalendarBody( selectedDate: LocalDate, onDateSelected: (LocalDate) -> Unit, ) { -// DayOfWeek는 일,월,화,수,목,금,토일과 같은 요일을 나타내주는 Composable입니다. - DayOfWeek() +// CalendarWeekDays는 일,월,화,수,목,금,토일과 같은 요일을 나타내주는 Composable입니다. + CalendarWeekDays() // 실질적인 동적인 달력 데이터가 들어가는 부분입니다. CalendarMonthItem( @@ -154,7 +154,7 @@ private fun CalendarBody( } @Composable -private fun DayOfWeek(modifier: Modifier = Modifier) { +private fun CalendarWeekDays(modifier: Modifier = Modifier) { Row(modifier = modifier) { DateUtil.DaysOfWeek.values().forEach { dayOfWeek -> val textColor = when (dayOfWeek) { diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt index 6ecc2a95..42b1c869 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/Calendar.kt @@ -159,7 +159,7 @@ private fun CalendarBody( eventsDate: List, onDateSelected: (LocalDate) -> Unit, ) { - DayOfWeek() + CalendarWeekDays() CalendarMonthItem( eventDates = eventsDate, selectedDate = selectedDate, @@ -168,7 +168,7 @@ private fun CalendarBody( } @Composable -private fun DayOfWeek(modifier: Modifier = Modifier) { +private fun CalendarWeekDays(modifier: Modifier = Modifier) { Row(modifier = modifier) { DaysOfWeek.values().forEach { dayOfWeek -> val textColor = when (dayOfWeek) {