Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#324] 바텀바, 달력 / 3차 스프린트 QA 반영 #325

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
}
Comment on lines +71 to +75
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

역시 대견한 석준씨...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

대견한 석준씨...

}

@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>
Loading