From be714d5265ce4401619e32a49050c73dfbe8b16e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Mon, 6 Jan 2025 16:19:11 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[FEAT/#324]=20=EB=8B=AC=EB=A0=A5=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=9A=94=EC=86=8C=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/calendar/calendar/CalendarRoute.kt | 15 ++++++++++++++- .../calendar/calendar/CalendarViewModel.kt | 8 ++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) 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..d6afa555 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,8 +14,10 @@ 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.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier @@ -47,6 +49,7 @@ fun CalendarRoute( val uiState by viewModel.uiState.collectAsStateWithLifecycle() val amplitudeTracker = LocalTracker.current + CalendarScreen( uiState = uiState, navigateToAnnouncement = navigateToAnnouncement, @@ -65,6 +68,12 @@ fun CalendarRoute( }, modifier = modifier, ) + + DisposableEffect(true) { + onDispose { + viewModel.resetUiState() + } + } } @Composable @@ -90,6 +99,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 +128,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 From ee81389b2d9b77d7173af51359fc53895ff66c2e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Mon, 6 Jan 2025 16:25:15 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[CHORE/#324]=20=EB=B0=94=ED=85=80=EB=B0=94?= =?UTF-8?q?=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=ED=8C=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/main/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ 캘린더 탐색 - 마이페이지 + 마이 From 4067f17f22509741a4b16598ae0853e23ecf962c Mon Sep 17 00:00:00 2001 From: boiledegg Date: Mon, 6 Jan 2025 16:25:39 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[DEL/#324]=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/feature/calendar/calendar/CalendarRoute.kt | 1 - 1 file changed, 1 deletion(-) 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 d6afa555..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 @@ -17,7 +17,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier From d6fc57aad638ce39ffb2c88d3a332264b377925b Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 7 Jan 2025 02:35:25 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[MOD/#324]=20=EB=B0=94=ED=85=80=EB=B0=94=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 그림자 추가 - 패키지 위치 수정 --- .../com/terning/feature/main/MainScreen.kt | 64 +----------- .../feature/main/component/MainBottomBar.kt | 98 +++++++++++++++++++ 2 files changed, 99 insertions(+), 63 deletions(-) create mode 100644 feature/main/src/main/java/com/terning/feature/main/component/MainBottomBar.kt 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