From e287e268878dc2eb6b28c8f78b5d001dfa0f92bb Mon Sep 17 00:00:00 2001 From: easyhz Date: Sat, 20 Jul 2024 13:51:04 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B7=B8=EB=A3=B9=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=20=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EC=A2=85=EB=A3=8C=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20#20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/calendar/MonthCalendarView.kt | 132 ++++++++++++++++++ .../component/calendar/MonthDay.kt | 55 ++++++++ .../component/calendar/MonthHeader.kt | 53 +++++++ .../core/design_system/extension/Modifier.kt | 5 +- .../noffice/core/design_system/theme/Color.kt | 5 +- .../design_system/util/calendar/Constant.kt | 8 ++ .../util/calendar/DisplayText.kt | 16 +++ .../util/calendar/MonthCalendar.kt | 77 ++++++++++ .../src/main/res/values/strings.xml | 1 + .../component/creation/EndDateView.kt | 58 ++++++++ .../contract/creation/CreationIntent.kt | 2 + .../contract/creation/CreationState.kt | 7 +- .../creation/OrganizationCreationScreen.kt | 3 +- .../creation/OrganizationCreationViewModel.kt | 7 + 14 files changed, 424 insertions(+), 5 deletions(-) create mode 100644 core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthCalendarView.kt create mode 100644 core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthDay.kt create mode 100644 core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthHeader.kt create mode 100644 core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/Constant.kt create mode 100644 core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/DisplayText.kt create mode 100644 core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/MonthCalendar.kt create mode 100644 feature/organization/src/main/java/com/easyhz/noffice/feature/organization/component/creation/EndDateView.kt diff --git a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthCalendarView.kt b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthCalendarView.kt new file mode 100644 index 00000000..4a834bac --- /dev/null +++ b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthCalendarView.kt @@ -0,0 +1,132 @@ +package com.easyhz.noffice.core.design_system.component.calendar + +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.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.Stable +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import com.easyhz.noffice.core.design_system.theme.Grey700 +import com.easyhz.noffice.core.design_system.theme.SubBody14 +import com.easyhz.noffice.core.design_system.util.calendar.RANGE_MONTH +import com.easyhz.noffice.core.design_system.util.calendar.displayText +import com.easyhz.noffice.core.design_system.util.calendar.rememberFirstMostVisibleMonth +import com.kizitonwose.calendar.compose.CalendarState +import com.kizitonwose.calendar.compose.HorizontalCalendar +import com.kizitonwose.calendar.compose.rememberCalendarState +import com.kizitonwose.calendar.core.OutDateStyle +import com.kizitonwose.calendar.core.daysOfWeek +import com.kizitonwose.calendar.core.firstDayOfWeekFromLocale +import com.kizitonwose.calendar.core.yearMonth +import kotlinx.coroutines.launch +import java.time.LocalDate + +@Composable +fun MonthCalendarView( + modifier: Modifier = Modifier, + selection: LocalDate, + calendarPadding: Dp, + onChangeDate: (LocalDate) -> Unit +) { + val scope = rememberCoroutineScope() + val today = remember { LocalDate.now() } + val startMonth = remember { today.yearMonth } + val endMonth = remember { today.yearMonth.plusMonths(RANGE_MONTH) } + val monthState = rememberCalendarState( + startMonth = startMonth, + endMonth = endMonth, + firstDayOfWeek = firstDayOfWeekFromLocale(), + outDateStyle = OutDateStyle.EndOfRow, + ) + val title = rememberFirstMostVisibleMonth(state = monthState) + + LaunchedEffect(selection) { + if(title.yearMonth == selection.yearMonth) return@LaunchedEffect + monthState.animateScrollToMonth(selection.yearMonth) + } + Column( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(24.dp) + ) { + MonthHeader( + modifier = Modifier + .fillMaxWidth() + .align(Alignment.CenterHorizontally), + title = title.yearMonth.displayText(), + onClickBefore = { + scope.launch { + monthState.animateScrollToMonth(title.yearMonth.minusMonths(1)) + } + }, + onClickNext = { + scope.launch { + monthState.animateScrollToMonth(title.yearMonth.plusMonths(1)) + } + } + ) + MonthCalendarContent( + modifier = Modifier + .align(Alignment.CenterHorizontally) + .padding(horizontal = calendarPadding), + monthState = monthState, + selection = selection, + today = today, + onChangeDate = onChangeDate + ) + } +} + +@Composable +fun MonthCalendarContent( + modifier: Modifier = Modifier, + monthState: CalendarState, + selection: LocalDate, + today: LocalDate, + onChangeDate: (LocalDate) -> Unit +) { + HorizontalCalendar( + modifier = modifier, + state = monthState, + monthHeader = { CalendarHeader() }, + dayContent = {day -> + Day( + day = day, + isSelected = selection == day.date, + today = today, + ) { clickedDay -> + onChangeDate(clickedDay) + } + }, + ) +} + +@Stable +@Composable +internal fun CalendarHeader() { + val daysOfWeek = remember { daysOfWeek() } + Row( + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 8.dp), + ) { + for (dayOfWeek in daysOfWeek) { + Text( + modifier = Modifier.weight(1f), + text = dayOfWeek.displayText(), + style = SubBody14, + color = Grey700, + textAlign = TextAlign.Center + ) + } + } +} \ No newline at end of file diff --git a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthDay.kt b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthDay.kt new file mode 100644 index 00000000..1baace03 --- /dev/null +++ b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthDay.kt @@ -0,0 +1,55 @@ +package com.easyhz.noffice.core.design_system.component.calendar + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +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.draw.clip +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import com.easyhz.noffice.core.design_system.extension.noRippleClickable +import com.easyhz.noffice.core.design_system.theme.SemiBold14 +import com.easyhz.noffice.core.design_system.util.calendar.dateFormatter +import com.easyhz.noffice.core.design_system.util.calendar.getSelectionBoxColor +import com.easyhz.noffice.core.design_system.util.calendar.getTextColor +import com.kizitonwose.calendar.core.CalendarDay +import java.time.LocalDate + +@Composable +internal fun Day( + modifier: Modifier = Modifier, + day: CalendarDay, + today: LocalDate, + isSelected: Boolean, + onClick: (LocalDate) -> Unit +) { + val enabled = day.date >= today + val selectionBoxColor = getSelectionBoxColor(isSelected) + val textColor = getTextColor(day, isSelected, enabled) + Box( + modifier = modifier + .fillMaxWidth() + .noRippleClickable(enabled = enabled) { onClick(day.date) }, + contentAlignment = Alignment.TopCenter, + ) { + Box(modifier = Modifier.padding(bottom = 6.dp) + .size(40.dp) + .clip(RoundedCornerShape(8.dp)) + .background(selectionBoxColor), + ) { + Text( + modifier = Modifier.align(Alignment.TopCenter).padding(top = 4.dp), + text = dateFormatter.format(day.date), + style = SemiBold14, + textAlign = TextAlign.Center, + color = textColor + ) + } + } +} \ No newline at end of file diff --git a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthHeader.kt b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthHeader.kt new file mode 100644 index 00000000..9a150335 --- /dev/null +++ b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/component/calendar/MonthHeader.kt @@ -0,0 +1,53 @@ +package com.easyhz.noffice.core.design_system.component.calendar + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import com.easyhz.noffice.core.design_system.R +import com.easyhz.noffice.core.design_system.extension.noRippleClickable +import com.easyhz.noffice.core.design_system.theme.Grey500 +import com.easyhz.noffice.core.design_system.theme.InputDialogTitle + +@Composable +internal fun MonthHeader( + modifier: Modifier = Modifier, + title: String, + onClickBefore: () -> Unit, + onClickNext: () -> Unit +) { + Row( + modifier = modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center + ) { + Box(modifier = Modifier.size(32.dp).noRippleClickable { onClickBefore() }) { + Icon( + modifier = Modifier.align(Alignment.CenterStart).size(24.dp), + painter = painterResource(id = R.drawable.ic_chevron_left), + contentDescription = "before", + tint = Grey500 + ) + } + Text( + text = title, + style = InputDialogTitle + ) + Box(modifier = Modifier.size(32.dp).noRippleClickable { onClickNext() }) { + Icon( + modifier = Modifier.align(Alignment.CenterEnd).size(24.dp), + painter = painterResource(id = R.drawable.ic_chevron_right), + contentDescription = "next", + tint = Grey500 + ) + } + } +} \ No newline at end of file diff --git a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/extension/Modifier.kt b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/extension/Modifier.kt index ce2a0ae7..49b8af55 100644 --- a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/extension/Modifier.kt +++ b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/extension/Modifier.kt @@ -15,9 +15,12 @@ fun Modifier.screenHorizonPadding(): Modifier = padding(horizontal = 16.dp) inline fun Modifier.noRippleClickable( interactionSource: MutableInteractionSource? = null, + enabled: Boolean = true, crossinline onClick: () -> Unit, ): Modifier = composed { - clickable(indication = null, + clickable( + indication = null, + enabled = enabled, interactionSource = interactionSource ?: remember { MutableInteractionSource() }) { onClick() } diff --git a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/theme/Color.kt b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/theme/Color.kt index 159b190b..6856a841 100644 --- a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/theme/Color.kt +++ b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/theme/Color.kt @@ -84,4 +84,7 @@ val Blue600 = Color(0xFF00A0EB) val Blue700 = Color(0xFF007DB8) @Stable -val DimColor = Color(0xFF121212).copy(alpha = 0.5f) \ No newline at end of file +val DimColor = Color(0xFF121212).copy(alpha = 0.5f) + +@Stable +val Red = Color(0xFFFF5757) \ No newline at end of file diff --git a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/Constant.kt b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/Constant.kt new file mode 100644 index 00000000..be9ea889 --- /dev/null +++ b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/Constant.kt @@ -0,0 +1,8 @@ +package com.easyhz.noffice.core.design_system.util.calendar + +internal const val CONTENT_SIZE = 40 +internal const val NUM_OF_DAYS_IN_WEEK = 7 +internal const val PADDING_NUM_OF_DAYS_IN_WEEK = NUM_OF_DAYS_IN_WEEK * 2 +internal const val WITHOUT_PADDING_NUM = PADDING_NUM_OF_DAYS_IN_WEEK - 2 +fun getCalendarPadding(target: Int, screenWidth: Int) = + (((PADDING_NUM_OF_DAYS_IN_WEEK * target) + (NUM_OF_DAYS_IN_WEEK * CONTENT_SIZE) - screenWidth) / WITHOUT_PADDING_NUM).coerceAtLeast(0) \ No newline at end of file diff --git a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/DisplayText.kt b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/DisplayText.kt new file mode 100644 index 00000000..1f83d1ca --- /dev/null +++ b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/DisplayText.kt @@ -0,0 +1,16 @@ +package com.easyhz.noffice.core.design_system.util.calendar + +import java.time.DayOfWeek +import java.time.YearMonth +import java.time.format.DateTimeFormatter +import java.time.format.TextStyle +import java.util.Locale + +internal val dateFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("d") + +internal fun YearMonth.displayText(): String = + "${year}.${month.value}" +internal fun DayOfWeek.displayText(uppercase: Boolean = false): String = + getDisplayName(TextStyle.SHORT, Locale.KOREA).let { value -> + if (uppercase) value.uppercase(Locale.KOREA) else value + } \ No newline at end of file diff --git a/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/MonthCalendar.kt b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/MonthCalendar.kt new file mode 100644 index 00000000..134cc9b1 --- /dev/null +++ b/core/design-system/src/main/java/com/easyhz/noffice/core/design_system/util/calendar/MonthCalendar.kt @@ -0,0 +1,77 @@ +package com.easyhz.noffice.core.design_system.util.calendar + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.snapshotFlow +import androidx.compose.ui.graphics.Color +import com.easyhz.noffice.core.design_system.theme.Green500 +import com.easyhz.noffice.core.design_system.theme.Grey300 +import com.easyhz.noffice.core.design_system.theme.Grey700 +import com.easyhz.noffice.core.design_system.theme.Red +import com.easyhz.noffice.core.design_system.theme.White +import com.kizitonwose.calendar.compose.CalendarLayoutInfo +import com.kizitonwose.calendar.compose.CalendarState +import com.kizitonwose.calendar.core.CalendarDay +import com.kizitonwose.calendar.core.CalendarMonth +import com.kizitonwose.calendar.core.DayPosition +import com.kizitonwose.calendar.core.Week +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.filterNotNull +import java.time.DayOfWeek + +const val RANGE_MONTH = 500L + + +/** + * 스크롤 감지하고 해당 월 반환 + * + * @param state HorizontalCalendar 의 상태인 [CalendarState] + * @param viewportPercent 넘어오는 정도 default : 50f + * + * @return 해당 주 [Week] + */ +@Composable +internal fun rememberFirstMostVisibleMonth( + state: CalendarState, + viewportPercent: Float = 50f, +): CalendarMonth { + val visibleMonth = remember(state) { mutableStateOf(state.firstVisibleMonth) } + LaunchedEffect(state) { + snapshotFlow { state.layoutInfo.firstMostVisibleMonth(viewportPercent) } + .distinctUntilChanged() + .filterNotNull() + .collect { month -> visibleMonth.value = month } + } + return visibleMonth.value +} + + +private fun CalendarLayoutInfo.firstMostVisibleMonth(viewportPercent: Float = 50f): CalendarMonth? { + return if (visibleMonthsInfo.isEmpty()) { + null + } else { + val viewportSize = (viewportEndOffset + viewportStartOffset) * viewportPercent / 100f + visibleMonthsInfo.firstOrNull { itemInfo -> + if (itemInfo.offset < 0) { + itemInfo.offset + itemInfo.size >= viewportSize + } else { + itemInfo.size - itemInfo.offset >= viewportSize + } + }?.month + } +} + +internal fun getSelectionBoxColor(isSelected: Boolean): Color { + return if (isSelected) Green500 else White +} + +internal fun getTextColor(day: CalendarDay, isSelected: Boolean, enabled: Boolean): Color { + return when { + isSelected -> White + !enabled || day.position != DayPosition.MonthDate -> Grey300 + day.date.dayOfWeek == DayOfWeek.SUNDAY -> Red + else -> Grey700 + } +} \ No newline at end of file diff --git a/core/design-system/src/main/res/values/strings.xml b/core/design-system/src/main/res/values/strings.xml index 9a20e3b1..cc0f917d 100644 --- a/core/design-system/src/main/res/values/strings.xml +++ b/core/design-system/src/main/res/values/strings.xml @@ -65,4 +65,5 @@ 이름을 입력해 주세요. 그룹의 카테고리를 모두 선택해 주세요 대표 이미지를 설정해 주세요 + 활동 종료 날짜가 언제인가요? \ No newline at end of file diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/component/creation/EndDateView.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/component/creation/EndDateView.kt new file mode 100644 index 00000000..6c3b6a74 --- /dev/null +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/component/creation/EndDateView.kt @@ -0,0 +1,58 @@ +package com.easyhz.noffice.feature.organization.component.creation + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.easyhz.noffice.core.design_system.R +import com.easyhz.noffice.core.design_system.component.button.MediumButton +import com.easyhz.noffice.core.design_system.component.calendar.MonthCalendarView +import com.easyhz.noffice.core.design_system.extension.screenHorizonPadding +import com.easyhz.noffice.core.design_system.util.calendar.getCalendarPadding +import com.easyhz.noffice.feature.organization.contract.creation.CreationIntent +import com.easyhz.noffice.feature.organization.screen.creation.OrganizationCreationViewModel + +@Composable +internal fun EndDateView( + modifier: Modifier = Modifier, + viewModel: OrganizationCreationViewModel = hiltViewModel() +) { + val uiState by viewModel.uiState.collectAsStateWithLifecycle() + val screenWidth = LocalConfiguration.current.screenWidthDp + val calendarPadding = getCalendarPadding(16, screenWidth).dp + + Column( + modifier = modifier + ) { + CommonHeader( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 16.dp, horizontal = 24.dp), + title = stringResource(id = R.string.organization_creation_end_date_title) + ) + MonthCalendarView( + modifier = Modifier.weight(1f), + selection = uiState.endDate, + calendarPadding = calendarPadding + ) { + viewModel.postIntent(CreationIntent.ChangeEndDate(it)) + } + MediumButton( + modifier = Modifier + .screenHorizonPadding() + .fillMaxWidth() + .padding(bottom = 16.dp), + text = stringResource(id = R.string.sign_up_button), + enabled = uiState.enabledStepButton[uiState.step.currentStep] ?: false + ) { + viewModel.postIntent(CreationIntent.ClickNextButton) + } + } +} \ No newline at end of file diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/creation/CreationIntent.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/creation/CreationIntent.kt index 78c0e1c8..8f5335ec 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/creation/CreationIntent.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/creation/CreationIntent.kt @@ -2,6 +2,7 @@ package com.easyhz.noffice.feature.organization.contract.creation import android.net.Uri import com.easyhz.noffice.core.common.base.UiIntent +import java.time.LocalDate sealed class CreationIntent: UiIntent() { data object ClickBackButton: CreationIntent() @@ -12,4 +13,5 @@ sealed class CreationIntent: UiIntent() { data class ClickCategoryItem(val selectedIndex: Int): CreationIntent() data object ClickImageView : CreationIntent() data class PickImage(val uri: Uri?) : CreationIntent() + data class ChangeEndDate(val date: LocalDate): CreationIntent() } \ No newline at end of file diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/creation/CreationState.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/creation/CreationState.kt index e7391b08..3a48cae3 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/creation/CreationState.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/creation/CreationState.kt @@ -8,6 +8,7 @@ import com.easyhz.noffice.core.common.util.toEnabledStepButton import com.easyhz.noffice.feature.organization.util.creation.Category import com.easyhz.noffice.feature.organization.util.creation.CreationStep import com.easyhz.noffice.feature.organization.util.creation.toState +import java.time.LocalDate import java.util.EnumMap data class CreationState( @@ -15,7 +16,8 @@ data class CreationState( val enabledStepButton: EnumMap, val organizationName: String, val category: List, - val organizationImage: Uri + val organizationImage: Uri, + val endDate: LocalDate, ): UiState() { companion object { const val ORGANIZATION_NAME_MAX = 10 @@ -24,7 +26,8 @@ data class CreationState( enabledStepButton = CreationStep.entries.toEnabledStepButton(), organizationName = "", category = Category.toState(), - organizationImage = Uri.EMPTY + organizationImage = Uri.EMPTY, + endDate = LocalDate.now() ) } diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationScreen.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationScreen.kt index 3d4bd0f7..ba6f6d65 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationScreen.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationScreen.kt @@ -32,6 +32,7 @@ import com.easyhz.noffice.core.design_system.theme.Grey400 import com.easyhz.noffice.core.design_system.theme.White import com.easyhz.noffice.core.design_system.util.topBar.DetailTopBarMenu import com.easyhz.noffice.feature.organization.component.creation.CategoryView +import com.easyhz.noffice.feature.organization.component.creation.EndDateView import com.easyhz.noffice.feature.organization.component.creation.OrganizationNameView import com.easyhz.noffice.feature.organization.component.creation.ImageView import com.easyhz.noffice.feature.organization.contract.creation.CreationIntent @@ -93,7 +94,7 @@ fun OrganizationCreationScreen( CreationStep.ORGANIZATION_NAME -> { OrganizationNameView(modifier = Modifier.screenHorizonPadding()) } CreationStep.CATEGORY -> { CategoryView(modifier = Modifier.screenHorizonPadding()) } CreationStep.IMAGE -> { ImageView(modifier = Modifier.screenHorizonPadding()) } - CreationStep.END_DATE -> { } + CreationStep.END_DATE -> { EndDateView() } CreationStep.PROMOTION -> { } CreationStep.SUCCESS -> { } } diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationViewModel.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationViewModel.kt index d92a28df..55598c87 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationViewModel.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationViewModel.kt @@ -8,6 +8,7 @@ import com.easyhz.noffice.feature.organization.contract.creation.CreationSideEff import com.easyhz.noffice.feature.organization.contract.creation.CreationState import com.easyhz.noffice.feature.organization.contract.creation.CreationState.Companion.ORGANIZATION_NAME_MAX import dagger.hilt.android.lifecycle.HiltViewModel +import java.time.LocalDate import javax.inject.Inject @HiltViewModel @@ -26,6 +27,7 @@ class OrganizationCreationViewModel @Inject constructor( is CreationIntent.ClickCategoryItem -> { onClickCategoryItem(intent.selectedIndex) } is CreationIntent.ClickImageView -> { onClickImageView() } is CreationIntent.PickImage -> { onPickImage(intent.uri) } + is CreationIntent.ChangeEndDate -> { onChangeEndDate(intent.date) } } } @@ -73,9 +75,14 @@ class OrganizationCreationViewModel @Inject constructor( private fun onClickImageView() { postSideEffect { CreationSideEffect.NavigateToGallery } } + private fun onPickImage(uri: Uri?) { uri?.let { reduce { copy(organizationImage = it) } } } + + private fun onChangeEndDate(date: LocalDate) { + reduce { copy(endDate = date) } + } } \ No newline at end of file