diff --git a/.idea/misc.xml b/.idea/misc.xml index cd7974cb..25b9e42b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4bd29bf8..7488122a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -21,6 +21,7 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) + signingConfig = signingConfigs.getByName("debug") } } } 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 02999c1a..b2a33ae3 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 @@ -1,21 +1,28 @@ package com.wap.wapp.feature.notice +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.animateContentSize import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Divider import androidx.compose.material.Text +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.SheetState +import androidx.compose.material3.SheetValue import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -27,7 +34,6 @@ 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 @@ -36,9 +42,11 @@ import java.time.LocalDate import java.time.format.TextStyle import java.util.Locale +@OptIn(ExperimentalMaterial3Api::class) @Composable internal fun BottomSheetContent( expandableHeight: Dp, + bottomSheetState: SheetState, events: NoticeViewModel.EventsState, selectedDate: LocalDate, ) { @@ -56,21 +64,29 @@ internal fun BottomSheetContent( text = "$date $dayOfWeek", style = WappTheme.typography.titleBold, color = WappTheme.colors.white, - modifier = Modifier.padding(start = 15.dp, bottom = 15.dp), + modifier = Modifier.padding(start = 15.dp, bottom = 5.dp), ) - HandleEventsState(events = events) - } -} -@Composable -private fun HandleEventsState(events: NoticeViewModel.EventsState) = when (events) { - is NoticeViewModel.EventsState.Loading -> CircleLoader(modifier = Modifier.fillMaxWidth()) - is NoticeViewModel.EventsState.Success -> EventsList(events.events) - is NoticeViewModel.EventsState.Failure -> Unit + when (events) { + is NoticeViewModel.EventsState.Loading -> + CircleLoader(modifier = Modifier.fillMaxWidth()) + + is NoticeViewModel.EventsState.Success -> EventsList( + bottomSheetState = bottomSheetState, + events = events.events, + ) + + is NoticeViewModel.EventsState.Failure -> Unit + } + } } +@OptIn(ExperimentalMaterial3Api::class) @Composable -private fun EventsList(events: List) { +private fun EventsList( + bottomSheetState: SheetState, + events: List, +) { if (events.isNotEmpty()) { LazyColumn( contentPadding = PaddingValues(horizontal = 15.dp), @@ -81,7 +97,10 @@ private fun EventsList(events: List) { items = events, key = { event -> event.eventId }, ) { event -> - EventItem(event = event) + EventItem( + bottomSheetState = bottomSheetState, + event = event, + ) } } } else { @@ -107,49 +126,69 @@ private fun EventsList(events: List) { } } +@OptIn(ExperimentalMaterial3Api::class) @Composable -private fun EventItem(event: Event) { - Column { +private fun EventItem( + bottomSheetState: SheetState, + event: Event, +) { + Column(modifier = Modifier.animateContentSize()) { Row( - modifier = Modifier - .background(WappTheme.colors.black25) - .fillMaxWidth() - .padding(top = 5.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp), verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .animateContentSize() + .padding(vertical = 10.dp) + .height(IntrinsicSize.Min) + .fillMaxWidth(), ) { Text( - text = event.startDateTime.toLocalTime().format(DateUtil.HHmmFormatter), + text = event.startDateTime.toLocalTime().format(HHmmFormatter), style = WappTheme.typography.contentBold, color = WappTheme.colors.white, ) - Box( + + Spacer( modifier = Modifier - .padding(10.dp) - .size(width = 4.dp, height = 20.dp) + .width(4.dp) + .animateContentSize() + .fillMaxHeight() .clip(RoundedCornerShape(10.dp)) .background(WappTheme.colors.yellow34), ) - Column( - horizontalAlignment = Alignment.Start, - modifier = Modifier.padding(start = 12.dp), - ) { + + Column(horizontalAlignment = Alignment.Start) { Text( text = event.title, style = WappTheme.typography.contentRegular, color = WappTheme.colors.white, ) + + AnimatedVisibility(bottomSheetState.currentValue == SheetValue.Expanded) { + Column(horizontalAlignment = Alignment.Start) { + Text( + text = event.location, + style = WappTheme.typography.captionRegular, + color = WappTheme.colors.yellow34, + ) + + Text( + text = event.content, + style = WappTheme.typography.captionRegular, + color = WappTheme.colors.grayBD, + ) + } + } + Text( text = event.startDateTime.format(HHmmFormatter) + " ~ " + event.endDateTime.format(HHmmFormatter), style = WappTheme.typography.captionRegular, - color = WappTheme.colors.grayBD, + color = WappTheme.colors.yellow34, ) } } - Divider( - color = WappTheme.colors.gray82, - thickness = 1.dp, - modifier = Modifier.padding(top = 15.dp), - ) + + Divider(color = WappTheme.colors.gray82) } } 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 1ff3b2e4..9e410423 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 @@ -53,6 +53,7 @@ internal fun Calendar( measureDefaultModifier: Modifier, measureExpandableModifier: Modifier, onDateSelected: (LocalDate) -> Unit, + onCalendarMonthChanged: () -> Unit, ) { Column( modifier = measureDefaultModifier, @@ -62,14 +63,27 @@ internal fun Calendar( bottomSheetState = bottomSheetState, selectedDate = selectedDate, onDateSelected = onDateSelected, + onCalendarMonthChanged = onCalendarMonthChanged, modifier = measureExpandableModifier, ) - handleMonthEventsState( - eventsState = monthEventsState, - selectedDate = selectedDate, - onDateSelected = onDateSelected, - ) + when (monthEventsState) { + is NoticeViewModel.EventsState.Loading -> + CircleLoader(modifier = Modifier.fillMaxSize()) + + is NoticeViewModel.EventsState.Success -> { + val eventDates = monthEventsState.events.map { + it.startDateTime.toLocalDate() + } + CalendarBody( + selectedDate = selectedDate, + eventsDate = eventDates, + onDateSelected = onDateSelected, + ) + } + + is NoticeViewModel.EventsState.Failure -> {} + } } } @@ -80,6 +94,7 @@ private fun CalendarHeader( bottomSheetState: SheetState, selectedDate: LocalDate, onDateSelected: (LocalDate) -> Unit, + onCalendarMonthChanged: () -> Unit, modifier: Modifier, ) = Box( modifier = modifier, @@ -110,7 +125,10 @@ private fun CalendarHeader( contentDescription = stringResource(id = R.string.backMonthArrowContentDescription), modifier = Modifier .padding(end = 20.dp) - .clickable { onDateSelected(selectedDate.minusMonths(1)) }, + .clickable { + onDateSelected(selectedDate.minusMonths(1)) + onCalendarMonthChanged() + }, ) Text( @@ -127,32 +145,14 @@ private fun CalendarHeader( contentDescription = stringResource(id = R.string.forwardMonthArrowContentDescription), modifier = Modifier .padding(start = 20.dp) - .clickable { onDateSelected(selectedDate.plusMonths(1)) }, + .clickable { + onDateSelected(selectedDate.plusMonths(1)) + onCalendarMonthChanged() + }, ) } } -@Composable -private fun handleMonthEventsState( - eventsState: NoticeViewModel.EventsState, - selectedDate: LocalDate, - onDateSelected: (LocalDate) -> Unit, -) = when (eventsState) { - is NoticeViewModel.EventsState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) - is NoticeViewModel.EventsState.Success -> { - val eventDates = eventsState.events.map { - it.startDateTime.toLocalDate() - } - CalendarBody( - selectedDate = selectedDate, - eventsDate = eventDates, - onDateSelected = onDateSelected, - ) - } - - is NoticeViewModel.EventsState.Failure -> {} -} - @Composable private fun CalendarBody( selectedDate: LocalDate, diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeScreen.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeScreen.kt index 066077c3..b1179017 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeScreen.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeScreen.kt @@ -34,8 +34,15 @@ internal fun NoticeRoute( val selectedDateEvents by viewModel.selectedDateEvents.collectAsStateWithLifecycle() val selectedDate by viewModel.selectedDate.collectAsStateWithLifecycle() val onDateSelected = viewModel::updateSelectedDate + val onCalendarMonthChanged = viewModel::getMonthEvents - NoticeScreen(MonthEvents, selectedDateEvents, selectedDate, onDateSelected) + NoticeScreen( + monthEvents = MonthEvents, + selectedDateEvents = selectedDateEvents, + selectedDate = selectedDate, + onDateSelected = onDateSelected, + onCalendarMonthChanged = onCalendarMonthChanged, + ) } @OptIn(ExperimentalMaterial3Api::class) @@ -45,6 +52,7 @@ internal fun NoticeScreen( selectedDateEvents: EventsState, selectedDate: LocalDate, onDateSelected: (LocalDate) -> Unit, + onCalendarMonthChanged: () -> Unit, ) { var defaultHeight: Dp by remember { mutableStateOf(0.dp) } var expandableHeight: Dp by remember { mutableStateOf(0.dp) } @@ -68,9 +76,10 @@ internal fun NoticeScreen( sheetPeekHeight = defaultHeight, sheetContent = { BottomSheetContent( - expandableHeight, - selectedDateEvents, - selectedDate, + expandableHeight = expandableHeight, + bottomSheetState = scaffoldState.bottomSheetState, + events = selectedDateEvents, + selectedDate = selectedDate, ) }, ) { @@ -80,6 +89,7 @@ internal fun NoticeScreen( selectedDate = selectedDate, monthEventsState = monthEvents, onDateSelected = onDateSelected, + onCalendarMonthChanged = onCalendarMonthChanged, measureDefaultModifier = Modifier .fillMaxWidth() .background(WappTheme.colors.black25) 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 fc3dfd97..01b8a132 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 @@ -33,7 +33,7 @@ class NoticeViewModel @Inject constructor( getSelectedDateEvents() } - private fun getMonthEvents() { + fun getMonthEvents() { _monthEvents.value = EventsState.Loading viewModelScope.launch { getMonthEventListUseCase(_selectedDate.value) @@ -42,7 +42,7 @@ class NoticeViewModel @Inject constructor( } } - fun getSelectedDateEvents() { + private fun getSelectedDateEvents() { _selectedDateEvents.value = EventsState.Loading viewModelScope.launch { getDateEventListUseCase(_selectedDate.value).onSuccess { eventList ->