Skip to content

Commit

Permalink
[MERGE] #324 -> develop
Browse files Browse the repository at this point in the history
[FIX/#324] ๋ฐ”ํ…€๋ฐ”, ๋‹ฌ๋ ฅ / 3์ฐจ ์Šคํ”„๋ฆฐํŠธ QA ๋ฐ˜์˜
  • Loading branch information
boiledEgg-s authored Jan 9, 2025
2 parents 1ca3117 + 7c249c3 commit f51f632
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -47,6 +48,7 @@ fun CalendarRoute(
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val amplitudeTracker = LocalTracker.current


CalendarScreen(
uiState = uiState,
navigateToAnnouncement = navigateToAnnouncement,
Expand All @@ -65,6 +67,12 @@ fun CalendarRoute(
},
modifier = modifier,
)

DisposableEffect(true) {
onDispose {
viewModel.resetUiState()
}
}
}

@Composable
Expand All @@ -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 ->
Expand All @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -277,49 +261,3 @@ fun MainScreen(
}
}
}

@Composable
private fun MainBottomBar(
isVisible: Boolean,
tabs: ImmutableList<MainTab>,
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
)
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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<MainTab>,
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 = {}
)
}
}
}
2 changes: 1 addition & 1 deletion feature/main/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<string name="bottom_nav_home">ํ™ˆ</string>
<string name="bottom_nav_calendar">์บ˜๋ฆฐ๋”</string>
<string name="bottom_nav_search">ํƒ์ƒ‰</string>
<string name="bottom_nav_my_page">๋งˆ์ดํŽ˜์ด์ง€</string>
<string name="bottom_nav_my_page">๋งˆ์ด</string>

</resources>

0 comments on commit f51f632

Please sign in to comment.