diff --git a/feature/calendar/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt b/feature/calendar/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt index fe3db7cb..8a050444 100644 --- a/feature/calendar/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt +++ b/feature/calendar/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope @@ -47,6 +48,7 @@ fun CalendarRoute( val uiState by viewModel.uiState.collectAsStateWithLifecycle() val amplitudeTracker = LocalTracker.current + CalendarScreen( uiState = uiState, navigateToAnnouncement = navigateToAnnouncement, @@ -65,6 +67,12 @@ fun CalendarRoute( }, modifier = modifier, ) + + DisposableEffect(true) { + onDispose { + viewModel.resetUiState() + } + } } @Composable @@ -90,6 +98,10 @@ private fun CalendarScreen( pageCount = { uiState.calendarModel.pageCount } ) + LaunchedEffect(true) { + pagerState.scrollToPage(uiState.calendarModel.initialPage) + } + LaunchedEffect(key1 = pagerState, key2 = uiState.selectedDate) { snapshotFlow { pagerState.currentPage } .collect { current -> @@ -115,7 +127,7 @@ private fun CalendarScreen( date = uiState.calendarModel.getYearMonthByPage(pagerState.settledPage), isListExpanded = uiState.isListEnabled, onListButtonClicked = { - if(!calendarListTransition.isRunning) + if (!calendarListTransition.isRunning) onClickListButton() }, onMonthNavigationButtonClicked = { direction -> diff --git a/feature/calendar/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt b/feature/calendar/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt index b8787976..263ea6cf 100644 --- a/feature/calendar/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt +++ b/feature/calendar/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt @@ -27,6 +27,14 @@ class CalendarViewModel @Inject constructor() : ViewModel() { } } + fun resetUiState() = _uiState.update { currentState -> + currentState.copy( + selectedDate = DayModel(), + isListEnabled = false, + isWeekEnabled = false + ) + } + fun updateSelectedDate(value: DayModel) = _uiState.update { currentState -> currentState.copy( selectedDate = value diff --git a/feature/main/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/main/src/main/java/com/terning/feature/main/MainScreen.kt index 2a741d9f..94ce146a 100644 --- a/feature/main/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/main/src/main/java/com/terning/feature/main/MainScreen.kt @@ -3,20 +3,11 @@ package com.terning.feature.main import android.app.Activity import android.content.Intent import androidx.activity.compose.BackHandler -import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.EnterTransition import androidx.compose.animation.ExitTransition -import androidx.compose.animation.fadeIn -import androidx.compose.animation.fadeOut -import androidx.compose.animation.slideIn -import androidx.compose.animation.slideOut import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Icon -import androidx.compose.material3.NavigationBar -import androidx.compose.material3.NavigationBarItem -import androidx.compose.material3.NavigationBarItemDefaults import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarDuration import androidx.compose.material3.SnackbarHost @@ -30,20 +21,13 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import androidx.navigation.NavOptions import androidx.navigation.compose.NavHost import androidx.navigation.navOptions import com.terning.core.analytics.EventType import com.terning.core.designsystem.component.snackbar.TerningBasicSnackBar -import com.terning.core.designsystem.theme.Grey300 -import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.White -import com.terning.core.designsystem.util.NoRippleInteractionSource import com.terning.feature.calendar.calendar.navigation.calendarNavGraph import com.terning.feature.calendar.calendar.navigation.navigateCalendar import com.terning.feature.filtering.filteringone.navigation.filteringOneNavGraph @@ -57,6 +41,7 @@ import com.terning.feature.home.navigation.homeNavGraph import com.terning.feature.home.navigation.navigateHome import com.terning.feature.intern.navigation.internNavGraph import com.terning.feature.intern.navigation.navigateIntern +import com.terning.feature.main.component.MainBottomBar import com.terning.feature.mypage.mypage.navigation.myPageNavGraph import com.terning.feature.mypage.profileedit.navigation.profileEditNavGraph import com.terning.feature.onboarding.signin.navigation.navigateSignIn @@ -68,7 +53,6 @@ import com.terning.feature.onboarding.splash.navigation.splashNavGraph import com.terning.feature.search.search.navigation.searchNavGraph import com.terning.feature.search.searchprocess.navigation.navigateSearchProcess import com.terning.feature.search.searchprocess.navigation.searchProcessNavGraph -import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.launch @@ -277,49 +261,3 @@ fun MainScreen( } } } - -@Composable -private fun MainBottomBar( - isVisible: Boolean, - tabs: ImmutableList, - currentTab: MainTab?, - onTabSelected: (MainTab) -> Unit, -) { - AnimatedVisibility( - visible = isVisible, - enter = fadeIn() + slideIn { IntOffset(0, 0) }, - exit = fadeOut() + slideOut { IntOffset(0, 0) } - ) { - NavigationBar(containerColor = White) { - tabs.forEach { itemType -> - NavigationBarItem( - interactionSource = NoRippleInteractionSource, - selected = currentTab == itemType, - onClick = { - onTabSelected(itemType) - }, - icon = { - Icon( - painter = painterResource(id = (itemType.icon)), - contentDescription = stringResource(id = itemType.contentDescription) - ) - }, - label = { - Text( - stringResource(id = itemType.contentDescription), - fontSize = 9.sp - ) - }, - colors = NavigationBarItemDefaults - .colors( - selectedIconColor = TerningMain, - selectedTextColor = TerningMain, - unselectedIconColor = Grey300, - unselectedTextColor = Grey300, - indicatorColor = White - ) - ) - } - } - } -} diff --git a/feature/main/src/main/java/com/terning/feature/main/component/MainBottomBar.kt b/feature/main/src/main/java/com/terning/feature/main/component/MainBottomBar.kt new file mode 100644 index 00000000..f2e32d04 --- /dev/null +++ b/feature/main/src/main/java/com/terning/feature/main/component/MainBottomBar.kt @@ -0,0 +1,98 @@ +package com.terning.feature.main.component + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.slideIn +import androidx.compose.animation.slideOut +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Icon +import androidx.compose.material3.NavigationBar +import androidx.compose.material3.NavigationBarItem +import androidx.compose.material3.NavigationBarItemDefaults +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.terning.core.designsystem.extension.customShadow +import com.terning.core.designsystem.theme.Grey300 +import com.terning.core.designsystem.theme.TerningMain +import com.terning.core.designsystem.theme.TerningPointTheme +import com.terning.core.designsystem.theme.White +import com.terning.core.designsystem.util.NoRippleInteractionSource +import com.terning.feature.main.MainTab +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.toImmutableList + +@Composable +internal fun MainBottomBar( + isVisible: Boolean, + tabs: ImmutableList, + currentTab: MainTab?, + onTabSelected: (MainTab) -> Unit, + modifier: Modifier = Modifier, +) { + AnimatedVisibility( + visible = isVisible, + enter = fadeIn() + slideIn { IntOffset(0, 0) }, + exit = fadeOut() + slideOut { IntOffset(0, 0) } + ) { + NavigationBar( + containerColor = White, + modifier = modifier.customShadow( + shadowWidth = 2.dp, + ), + ) { + tabs.forEach { itemType -> + NavigationBarItem( + interactionSource = NoRippleInteractionSource, + selected = currentTab == itemType, + onClick = { onTabSelected(itemType) }, + icon = { + Icon( + painter = painterResource(id = (itemType.icon)), + contentDescription = stringResource(id = itemType.contentDescription) + ) + }, + label = { + Text( + stringResource(id = itemType.contentDescription), + fontSize = 9.sp + ) + }, + colors = NavigationBarItemDefaults + .colors( + selectedIconColor = TerningMain, + selectedTextColor = TerningMain, + unselectedIconColor = Grey300, + unselectedTextColor = Grey300, + indicatorColor = White + ) + ) + } + } + } +} + +@Preview(showBackground = true) +@Composable +private fun MainBottomBarPreview() { + TerningPointTheme { + Column { + Spacer(Modifier.height(20.dp)) + MainBottomBar( + isVisible = true, + tabs = MainTab.entries.toImmutableList(), + currentTab = MainTab.HOME, + onTabSelected = {} + ) + } + } +} \ No newline at end of file diff --git a/feature/main/src/main/res/values/strings.xml b/feature/main/src/main/res/values/strings.xml index 7c269044..be7bdb64 100644 --- a/feature/main/src/main/res/values/strings.xml +++ b/feature/main/src/main/res/values/strings.xml @@ -6,6 +6,6 @@ 캘린더 탐색 - 마이페이지 + 마이