From 3a9f66390665e3a158ed0a84c258ed048c3cc1bc Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 03:46:07 +0900 Subject: [PATCH 01/19] =?UTF-8?q?[UI/#216]=20=ED=95=84=ED=84=B0=EB=A7=81?= =?UTF-8?q?=20=EC=8B=9C=EC=9E=91=20=ED=99=94=EB=A9=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...teringScreen.kt => StartFilteringRoute.kt} | 51 ++++++++++++------- .../startfiltering/StartFilteringState.kt | 5 ++ .../startfiltering/StartFilteringViewModel.kt | 18 +++++++ .../navigation/StartFilteringNavigation.kt | 4 +- .../signup/navigation/SignUpNavigation.kt | 3 +- 5 files changed, 61 insertions(+), 20 deletions(-) rename feature/src/main/java/com/terning/feature/filtering/startfiltering/{StartFilteringScreen.kt => StartFilteringRoute.kt} (71%) create mode 100644 feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringState.kt create mode 100644 feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringViewModel.kt diff --git a/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringScreen.kt b/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringRoute.kt similarity index 71% rename from feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringScreen.kt rename to feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringRoute.kt index e8e1128b2..0efc87a2d 100644 --- a/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringScreen.kt +++ b/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringRoute.kt @@ -2,6 +2,7 @@ package com.terning.feature.filtering.startfiltering import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.fadeIn +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer @@ -13,40 +14,53 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.terning.core.designsystem.component.button.RectangleButton -import com.terning.core.designsystem.component.image.TerningImage import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.feature.R import kotlinx.coroutines.delay @Composable -fun StartFilteringScreen( - modifier: Modifier = Modifier, - onNextClick: () -> Unit +fun StartFilteringRoute( + onNextClick: () -> Unit, + viewModel: StartFilteringViewModel = hiltViewModel() ) { - var isVisible by remember { mutableStateOf(false) } + val state by viewModel.state.collectAsStateWithLifecycle() val configuration = LocalConfiguration.current val screenHeight = 780f / configuration.screenHeightDp LaunchedEffect(key1 = true) { delay(DELAY) - isVisible = true + viewModel.updateButtonState() } + StartFilteringScreen( + onNextClick = onNextClick, + buttonState = state.isButtonVisible, + screenHeight = screenHeight + ) + +} + +@Composable +fun StartFilteringScreen( + onNextClick: () -> Unit, + buttonState: Boolean, + screenHeight: Float +) { Box( - modifier = modifier.fillMaxSize() + modifier = Modifier.fillMaxSize() ) { Column( modifier = Modifier.fillMaxSize(), @@ -59,11 +73,12 @@ fun StartFilteringScreen( modifier = Modifier.padding(bottom = 35.dp), textAlign = TextAlign.Center ) - TerningImage( - painter = R.drawable.ic_terning_onboarding, + Image( + painter = painterResource(id = R.drawable.ic_terning_onboarding), modifier = Modifier .fillMaxWidth() - .padding(horizontal = 24.dp) + .padding(horizontal = 24.dp), + contentDescription = "terning image" ) Spacer(modifier = Modifier.weight(2f)) } @@ -73,14 +88,14 @@ fun StartFilteringScreen( .padding(bottom = 12.dp) ) { AnimatedVisibility( - visible = isVisible, + visible = buttonState, enter = fadeIn(initialAlpha = 0.3f), ) { RectangleButton( style = TerningTheme.typography.button0, paddingVertical = 20.dp, text = R.string.start_filtering_button, - onButtonClick = { onNextClick() }, + onButtonClick = onNextClick, ) } } @@ -94,7 +109,9 @@ private const val DELAY: Long = 1000 fun StartFilteringScreenPreview() { TerningPointTheme { StartFilteringScreen( - onNextClick = {} + onNextClick = {}, + buttonState = true, + screenHeight = 1f ) } -} +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringState.kt b/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringState.kt new file mode 100644 index 000000000..005cb40f8 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringState.kt @@ -0,0 +1,5 @@ +package com.terning.feature.filtering.startfiltering + +data class StartFilteringState( + val isButtonVisible: Boolean = false +) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringViewModel.kt new file mode 100644 index 000000000..3cfc06193 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/startfiltering/StartFilteringViewModel.kt @@ -0,0 +1,18 @@ +package com.terning.feature.filtering.startfiltering + +import androidx.lifecycle.ViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow + +class StartFilteringViewModel : ViewModel() { + + private val _state: MutableStateFlow = + MutableStateFlow(StartFilteringState()) + val state: StateFlow get() = _state.asStateFlow() + + fun updateButtonState() { + _state.value = _state.value.copy(isButtonVisible = true) + } + +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/startfiltering/navigation/StartFilteringNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/startfiltering/navigation/StartFilteringNavigation.kt index e70d98afa..f217cf39e 100644 --- a/feature/src/main/java/com/terning/feature/filtering/startfiltering/navigation/StartFilteringNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/startfiltering/navigation/StartFilteringNavigation.kt @@ -8,7 +8,7 @@ import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route import com.terning.feature.filtering.filtering.navigation.navigateFilteringOne -import com.terning.feature.filtering.startfiltering.StartFilteringScreen +import com.terning.feature.filtering.startfiltering.StartFilteringRoute import kotlinx.serialization.Serializable fun NavController.navigateStartFiltering( @@ -26,7 +26,7 @@ fun NavGraphBuilder.startFilteringNavGraph( ) { composable { val args = it.toRoute() - StartFilteringScreen( + StartFilteringRoute( onNextClick = { navHostController.navigateFilteringOne(args.name) } diff --git a/feature/src/main/java/com/terning/feature/onboarding/signup/navigation/SignUpNavigation.kt b/feature/src/main/java/com/terning/feature/onboarding/signup/navigation/SignUpNavigation.kt index 479e02eda..95932966e 100644 --- a/feature/src/main/java/com/terning/feature/onboarding/signup/navigation/SignUpNavigation.kt +++ b/feature/src/main/java/com/terning/feature/onboarding/signup/navigation/SignUpNavigation.kt @@ -8,6 +8,7 @@ import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route import com.terning.feature.filtering.filtering.navigation.navigateFilteringOne +import com.terning.feature.filtering.startfiltering.navigation.navigateStartFiltering import com.terning.feature.onboarding.signup.SignUpRoute import kotlinx.serialization.Serializable @@ -28,7 +29,7 @@ fun NavGraphBuilder.signUpNavGraph( val args = it.toRoute() SignUpRoute( authId = args.authId, - navigateToStartFiltering = { name -> navHostController.navigateFilteringOne(name) } + navigateToStartFiltering = { name -> navHostController.navigateStartFiltering(name) } ) } From b65f7732d118bfda58d12f327be1fdd6a05e05a4 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 03:54:18 +0900 Subject: [PATCH 02/19] =?UTF-8?q?[UI/#216]=20=ED=99=88=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=20=ED=99=94=EB=A9=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{StartHomeScreen.kt => StartHomeRoute.kt} | 50 +++++++++++-------- .../filtering/starthome/StartHomeState.kt | 5 ++ .../filtering/starthome/StartHomeViewModel.kt | 16 ++++++ .../navigation/StartHomeNavigation.kt | 4 +- 4 files changed, 51 insertions(+), 24 deletions(-) rename feature/src/main/java/com/terning/feature/filtering/starthome/{StartHomeScreen.kt => StartHomeRoute.kt} (79%) create mode 100644 feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeState.kt create mode 100644 feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeViewModel.kt diff --git a/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeScreen.kt b/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeRoute.kt similarity index 79% rename from feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeScreen.kt rename to feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeRoute.kt index 63b92593f..19dfda750 100644 --- a/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeScreen.kt +++ b/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeRoute.kt @@ -14,9 +14,6 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalConfiguration @@ -24,9 +21,8 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.navigation.NavController -import androidx.navigation.NavOptions -import androidx.navigation.compose.rememberNavController +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.airbnb.lottie.compose.LottieAnimation import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.LottieConstants @@ -35,29 +31,39 @@ import com.terning.core.designsystem.component.button.RectangleButton import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.feature.R -import com.terning.feature.home.home.navigation.navigateHome -import com.terning.feature.main.MainNavigator -import com.terning.feature.main.rememberMainNavigator -import com.terning.feature.onboarding.signin.navigation.SignIn import kotlinx.coroutines.delay @Composable -fun StartHomeScreen( - modifier: Modifier = Modifier, - navigateToHome: () -> Unit +fun StartHomeRoute( + navigateToHome: () -> Unit, + viewModel: StartHomeViewModel = hiltViewModel() ) { - var isVisible by remember { mutableStateOf(false) } + val state by viewModel.state.collectAsStateWithLifecycle() val configuration = LocalConfiguration.current val screenHeight = 780f / configuration.screenHeightDp LaunchedEffect(key1 = true) { delay(DELAY) - isVisible = true + viewModel.updateButtonState() } + StartHomeScreen( + navigateToHome = navigateToHome, + buttonState = state.isButtonVisible, + screenHeight = screenHeight + ) +} + +@Composable +fun StartHomeScreen( + navigateToHome: () -> Unit, + buttonState: Boolean, + screenHeight: Float +) { + Box( - modifier = modifier.fillMaxSize() + modifier = Modifier.fillMaxSize() ) { Column( modifier = Modifier.fillMaxSize(), @@ -79,23 +85,21 @@ fun StartHomeScreen( contentAlignment = Alignment.BottomCenter ) { AnimatedVisibility( - visible = isVisible, + visible = buttonState, enter = fadeIn(initialAlpha = 0.3f), ) { RectangleButton( style = TerningTheme.typography.button0, paddingVertical = 20.dp, text = R.string.start_home_next_button, - onButtonClick = { - navigateToHome() - }, + onButtonClick = navigateToHome, ) } } } } -private const val DELAY : Long = 1000 +private const val DELAY: Long = 1000 @Composable fun StartHomeLottieAnimation( @@ -122,7 +126,9 @@ fun StartHomeLottieAnimation( fun StartHomeScreenPreview() { TerningPointTheme { StartHomeScreen( - navigateToHome = {} + navigateToHome = {}, + buttonState = true, + screenHeight = 1f ) } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeState.kt b/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeState.kt new file mode 100644 index 000000000..d847568bc --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeState.kt @@ -0,0 +1,5 @@ +package com.terning.feature.filtering.starthome + +data class StartHomeState( + val isButtonVisible: Boolean = false +) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeViewModel.kt new file mode 100644 index 000000000..e0e038372 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/starthome/StartHomeViewModel.kt @@ -0,0 +1,16 @@ +package com.terning.feature.filtering.starthome + +import androidx.lifecycle.ViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow + +class StartHomeViewModel : ViewModel() { + private val _state: MutableStateFlow = + MutableStateFlow(StartHomeState()) + val state: StateFlow get() = _state.asStateFlow() + + fun updateButtonState() { + _state.value = _state.value.copy(isButtonVisible = true) + } +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/starthome/navigation/StartHomeNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/starthome/navigation/StartHomeNavigation.kt index ed29bcf97..fb3369a51 100644 --- a/feature/src/main/java/com/terning/feature/filtering/starthome/navigation/StartHomeNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/starthome/navigation/StartHomeNavigation.kt @@ -8,7 +8,7 @@ import androidx.navigation.NavHostController import androidx.navigation.NavOptions import androidx.navigation.compose.composable import com.terning.core.navigation.Route -import com.terning.feature.filtering.starthome.StartHomeScreen +import com.terning.feature.filtering.starthome.StartHomeRoute import com.terning.feature.home.home.navigation.navigateHome import com.terning.feature.onboarding.signin.navigation.SignIn import kotlinx.serialization.Serializable @@ -37,7 +37,7 @@ fun NavGraphBuilder.startHomeNavGraph( ExitTransition.None } ) { - StartHomeScreen(navigateToHome = { + StartHomeRoute(navigateToHome = { navHostController.navigateHome( navOptions = NavOptions.Builder().setPopUpTo( route = SignIn, From 34542d3d2c091504f40f4a57c38323d28a401863 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 04:15:27 +0900 Subject: [PATCH 03/19] =?UTF-8?q?[UI/#216]=20=ED=95=84=ED=84=B0=EB=A7=81?= =?UTF-8?q?=20=EB=B2=84=ED=8A=BC=20UI=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/button/FilteringButton.kt | 30 +++++++--------- .../terning/core/designsystem/theme/Color.kt | 1 + .../filtering/filtering/FilteringOneScreen.kt | 34 +++++++++---------- .../component/StatusOneRadioGroup.kt | 2 +- feature/src/main/res/values/strings.xml | 2 +- 5 files changed, 32 insertions(+), 37 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/button/FilteringButton.kt b/core/src/main/java/com/terning/core/designsystem/component/button/FilteringButton.kt index 69560b6dc..f0c50d820 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/button/FilteringButton.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/button/FilteringButton.kt @@ -23,13 +23,11 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.terning.core.R -import com.terning.core.designsystem.theme.Grey400 +import com.terning.core.designsystem.theme.Grey150 +import com.terning.core.designsystem.theme.Grey200 +import com.terning.core.designsystem.theme.Grey375 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningPointTheme -import com.terning.core.designsystem.theme.TerningSub1 -import com.terning.core.designsystem.theme.TerningSub3 -import com.terning.core.designsystem.theme.TerningSub4 -import com.terning.core.designsystem.theme.TerningSub5 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.util.NoRippleTheme @@ -58,19 +56,15 @@ fun FilteringButton( ) { val interactionSource = remember { MutableInteractionSource() } val isPressed by interactionSource.collectIsPressedAsState() - val backgroundColor = when { - !isSelected && !isPressed -> White - !isSelected && isPressed -> TerningSub5 - isSelected && !isPressed -> TerningSub4 - else -> TerningSub3 - } + val backgroundColor = White val textColor = when { - !isSelected -> Grey400 - else -> TerningMain + isSelected -> TerningMain + else -> Grey375 } val borderColor = when { - !isSelected -> TerningMain - else -> TerningSub1 + !isSelected && !isPressed -> Grey150 + isPressed -> Grey200 + else -> TerningMain } CompositionLocalProvider(LocalRippleTheme provides NoRippleTheme) { @@ -87,7 +81,7 @@ fun FilteringButton( color = borderColor ), shape = RoundedCornerShape(cornerRadius), - onClick = { onButtonClick() } + onClick = onButtonClick ) { Text( text = stringResource(id = text), @@ -104,14 +98,14 @@ fun FilteringButtonPreview() { TerningPointTheme { Column { FilteringButton( - isSelected = true, + isSelected = false, text = R.string.button_preview, cornerRadius = 15.dp, paddingVertical = 10.dp, onButtonClick = {} ) FilteringButton( - isSelected = false, + isSelected = true, text = R.string.button_preview, cornerRadius = 15.dp, paddingVertical = 10.dp, diff --git a/core/src/main/java/com/terning/core/designsystem/theme/Color.kt b/core/src/main/java/com/terning/core/designsystem/theme/Color.kt index bea5eb805..807bc9813 100644 --- a/core/src/main/java/com/terning/core/designsystem/theme/Color.kt +++ b/core/src/main/java/com/terning/core/designsystem/theme/Color.kt @@ -9,6 +9,7 @@ val Grey150 = Color(0xFFE9E9E9) val Grey200 = Color(0xFFDDDDDD) val Grey300 = Color(0xFFBCBCBC) val Grey350 = Color(0xFFADADAD) +val Grey375 = Color(0xFF898989) val Grey400 = Color(0xFF666666) val Grey500 = Color(0xFF373737) val Black = Color(0xFF171717) diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringOneScreen.kt b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringOneScreen.kt index 3f4a28c8c..a8065f029 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringOneScreen.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringOneScreen.kt @@ -1,5 +1,6 @@ package com.terning.feature.filtering.filtering +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -12,11 +13,11 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue 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.dp import com.terning.core.designsystem.component.button.RectangleButton -import com.terning.core.designsystem.component.image.TerningImage import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningPointTheme @@ -29,15 +30,13 @@ fun FilteringOneScreen( name: String, onNextClick: (Int) -> Unit, navigateUp: () -> Unit, - modifier: Modifier = Modifier, onButtonClick: (Int) -> Unit = {}, ) { val isButtonValid = remember { mutableStateOf(false) } - var grade by remember { mutableIntStateOf(-1) } Column( - modifier = modifier + modifier = Modifier ) { BackButtonTopAppBar( onBackButtonClick = { navigateUp() } @@ -45,12 +44,13 @@ fun FilteringOneScreen( Column( modifier = Modifier.fillMaxSize() ) { - TerningImage( - painter = R.drawable.ic_filtering_status1, - modifier = modifier.padding( - top = 20.dp, + Image( + painter = painterResource(id = R.drawable.ic_filtering_status1), + modifier = Modifier.padding( + top = 28.dp, start = 24.dp - ) + ), + contentDescription = "filtering one status" ) Text( text = stringResource( @@ -58,8 +58,8 @@ fun FilteringOneScreen( name ), style = TerningTheme.typography.title3, - modifier = modifier.padding( - top = 19.dp, + modifier = Modifier.padding( + top = 20.dp, start = 24.dp ) ) @@ -70,10 +70,10 @@ fun FilteringOneScreen( ), style = TerningTheme.typography.body5, color = Grey300, - modifier = modifier.padding( - top = 3.dp, + modifier = Modifier.padding( + top = 4.dp, start = 24.dp, - bottom = 25.dp + bottom = 24.dp ) ) StatusOneRadioGroup( @@ -86,18 +86,18 @@ fun FilteringOneScreen( Text( text = stringResource(id = R.string.filtering_status1_warning), style = TerningTheme.typography.detail3, - modifier = modifier.padding( + modifier = Modifier.padding( start = 24.dp, top = 9.dp ) ) - Spacer(modifier = modifier.weight(1f)) + Spacer(modifier = Modifier.weight(1f)) RectangleButton( style = TerningTheme.typography.button0, paddingVertical = 20.dp, text = R.string.filtering_button, onButtonClick = { onNextClick(grade) }, - modifier = modifier.padding(bottom = 12.dp), + modifier = Modifier.padding(bottom = 12.dp), isEnabled = isButtonValid.value ) } diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusOneRadioGroup.kt b/feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusOneRadioGroup.kt index 9aa695c6a..d37dc6471 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusOneRadioGroup.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusOneRadioGroup.kt @@ -55,7 +55,7 @@ fun StatusOneRadioGroup( onButtonClick(index) }, cornerRadius = 15.dp, - paddingVertical = 15.dp + paddingVertical = 14.dp ) } } diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 187a825d0..f900df251 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -100,7 +100,7 @@ 대학생 인턴, 누구보다 빠르게 시작해 보세요! 인턴이라는 좋은 기회로 단숨에 스펙업하세요! 지금까지 준비한 역량을 인턴으로 발휘해 보세요! - 사회초년생으로 도약하기 위한 마지막 단계를 경험하세요! + 사회초년생으로 도약하는 마지막 단계를 경험하세요! 희망하는 인턴 근무 기간을 선택해 주세요 선택한 기간 동안 근무할 수 있는 인턴 공고를 찾아드릴게요 1개월 ~ 3개월 From 6211928481e2a503e24687912b45e8f90c8f11db Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 04:22:29 +0900 Subject: [PATCH 04/19] =?UTF-8?q?[UI/#216]=20=ED=95=84=ED=84=B0=EB=A7=81?= =?UTF-8?q?=20=EB=B2=84=ED=8A=BC=20UI=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filtering/FilteringThreeRoute.kt | 39 ++++++++++--------- ...eEffect.kt => FilteringThreeSideEffect.kt} | 6 +-- .../filtering/filtering/FilteringTwoScreen.kt | 32 +++++++-------- .../filtering/filtering/FilteringViewModel.kt | 8 ++-- 4 files changed, 43 insertions(+), 42 deletions(-) rename feature/src/main/java/com/terning/feature/filtering/filtering/{FilteringSideEffect.kt => FilteringThreeSideEffect.kt} (55%) diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt index b51640a80..c6b5d9c79 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt @@ -1,5 +1,6 @@ package com.terning.feature.filtering.filtering +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -13,6 +14,7 @@ import androidx.compose.runtime.remember 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.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -21,7 +23,6 @@ import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.flowWithLifecycle import com.terning.core.designsystem.component.button.RectangleButton import com.terning.core.designsystem.component.datepicker.DatePickerUI -import com.terning.core.designsystem.component.image.TerningImage import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningPointTheme @@ -61,8 +62,8 @@ fun FilteringThreeRoute( viewModel.sideEffects.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) .collect { sideEffect -> when (sideEffect) { - is FilteringSideEffect.NavigateToStartHome -> navigateToStartHome() - is FilteringSideEffect.ShowToast -> context.toast(sideEffect.message) + is FilteringThreeSideEffect.NavigateToStartHome -> navigateToStartHome() + is FilteringThreeSideEffect.ShowToast -> context.toast(sideEffect.message) } } } @@ -79,7 +80,6 @@ fun FilteringThreeRoute( @Composable fun FilteringThreeScreen( - modifier: Modifier = Modifier, navigateUp: () -> Unit, chosenYear: Int, chosenMonth: Int, @@ -88,7 +88,7 @@ fun FilteringThreeScreen( onNextClick: () -> Unit, ) { Column( - modifier = modifier, + modifier = Modifier, ) { BackButtonTopAppBar( onBackButtonClick = { navigateUp() } @@ -96,18 +96,19 @@ fun FilteringThreeScreen( Column( modifier = Modifier.fillMaxSize() ) { - TerningImage( - painter = R.drawable.ic_filtering_status3, - modifier = modifier.padding( - top = 20.dp, + Image( + painter = painterResource(id = R.drawable.ic_filtering_status3), + modifier = Modifier.padding( + top = 28.dp, start = 24.dp - ) + ), + contentDescription = "filtering three status" ) Text( text = stringResource(id = R.string.filtering_status3_title), style = TerningTheme.typography.title3, - modifier = modifier.padding( - top = 19.dp, + modifier = Modifier.padding( + top = 20.dp, start = 24.dp ) ) @@ -115,26 +116,26 @@ fun FilteringThreeScreen( text = stringResource(id = R.string.filtering_status3_sub), style = TerningTheme.typography.body5, color = Grey300, - modifier = modifier.padding( - top = 3.dp, + modifier = Modifier.padding( + top = 4.dp, start = 24.dp, - bottom = 25.dp + bottom = 24.dp ) ) - Spacer(modifier = modifier.weight(1f)) + Spacer(modifier = Modifier.weight(1f)) DatePickerUI( chosenYear = chosenYear, chosenMonth = chosenMonth, onYearChosen = { onYearChosen(it) }, onMonthChosen = { onMonthChosen(it) }, ) - Spacer(modifier = modifier.weight(3f)) + Spacer(modifier = Modifier.weight(3f)) RectangleButton( style = TerningTheme.typography.button0, paddingVertical = 20.dp, text = R.string.filtering_button, - onButtonClick = { onNextClick() }, - modifier = modifier.padding(bottom = 12.dp), + onButtonClick = onNextClick, + modifier = Modifier.padding(bottom = 12.dp), ) } } diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringSideEffect.kt b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeSideEffect.kt similarity index 55% rename from feature/src/main/java/com/terning/feature/filtering/filtering/FilteringSideEffect.kt rename to feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeSideEffect.kt index 52c9b3a68..da8d3dfa8 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringSideEffect.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeSideEffect.kt @@ -2,7 +2,7 @@ package com.terning.feature.filtering.filtering import androidx.annotation.StringRes -sealed class FilteringSideEffect { - data object NavigateToStartHome : FilteringSideEffect() - data class ShowToast(@StringRes val message: Int) : FilteringSideEffect() +sealed class FilteringThreeSideEffect { + data object NavigateToStartHome : FilteringThreeSideEffect() + data class ShowToast(@StringRes val message: Int) : FilteringThreeSideEffect() } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringTwoScreen.kt b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringTwoScreen.kt index e66df12e8..2f1e8c643 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringTwoScreen.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringTwoScreen.kt @@ -1,5 +1,6 @@ package com.terning.feature.filtering.filtering +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -12,11 +13,11 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue 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.dp import com.terning.core.designsystem.component.button.RectangleButton -import com.terning.core.designsystem.component.image.TerningImage import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningPointTheme @@ -29,15 +30,13 @@ fun FilteringTwoScreen( grade: Int, onNextClick: (Int, Int) -> Unit, navigateUp: () -> Unit, - modifier: Modifier = Modifier, onButtonClick: (Int) -> Unit = {}, ) { val isButtonValid = remember { mutableStateOf(false) } - var workingPeriod by remember { mutableIntStateOf(-1) } Column( - modifier = modifier + modifier = Modifier ) { BackButtonTopAppBar( onBackButtonClick = { navigateUp() } @@ -45,18 +44,19 @@ fun FilteringTwoScreen( Column( modifier = Modifier.fillMaxSize() ) { - TerningImage( - painter = R.drawable.ic_filtering_status2, - modifier = modifier.padding( - top = 20.dp, + Image( + painter = painterResource(id = R.drawable.ic_filtering_status2), + modifier = Modifier.padding( + top = 28.dp, start = 24.dp - ) + ), + contentDescription = "filtering two status" ) Text( text = stringResource(id = R.string.filtering_status2_title), style = TerningTheme.typography.title3, - modifier = modifier.padding( - top = 19.dp, + modifier = Modifier.padding( + top = 20.dp, start = 24.dp ) ) @@ -64,10 +64,10 @@ fun FilteringTwoScreen( text = stringResource(id = R.string.filtering_status2_sub), style = TerningTheme.typography.body5, color = Grey300, - modifier = modifier.padding( - top = 3.dp, + modifier = Modifier.padding( + top = 4.dp, start = 24.dp, - bottom = 25.dp + bottom = 24.dp ) ) StatusTwoRadioGroup( @@ -77,13 +77,13 @@ fun FilteringTwoScreen( workingPeriod = index } ) - Spacer(modifier = modifier.weight(1f)) + Spacer(modifier = Modifier.weight(1f)) RectangleButton( style = TerningTheme.typography.button0, paddingVertical = 20.dp, text = R.string.filtering_button, onButtonClick = { onNextClick(grade, workingPeriod) }, - modifier = modifier.padding(bottom = 12.dp), + modifier = Modifier.padding(bottom = 12.dp), isEnabled = isButtonValid.value ) } diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringViewModel.kt index 692117fab..b4b85b1a5 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringViewModel.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringViewModel.kt @@ -25,8 +25,8 @@ class FilteringViewModel @Inject constructor( private val _state = MutableStateFlow(FilteringState()) val state: StateFlow get() = _state.asStateFlow() - private val _sideEffects = MutableSharedFlow() - val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() + private val _sideEffects = MutableSharedFlow() + val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() fun fetchGrade(grade: Int) { _state.value = _state.value.copy(grade = grade) @@ -57,9 +57,9 @@ class FilteringViewModel @Inject constructor( ) } ).onSuccess { - _sideEffects.emit(FilteringSideEffect.NavigateToStartHome) + _sideEffects.emit(FilteringThreeSideEffect.NavigateToStartHome) }.onFailure { - _sideEffects.emit(FilteringSideEffect.ShowToast(R.string.server_failure)) + _sideEffects.emit(FilteringThreeSideEffect.ShowToast(R.string.server_failure)) } } } From df3752641887484aa06e31606fa58dda418c9e17 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 05:59:25 +0900 Subject: [PATCH 05/19] =?UTF-8?q?[UI/#218]=20YearMonthPicker=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/build.gradle.kts | 3 +- .../filtering/FilteringThreeRoute.kt | 19 +- .../filtering/component/YearMonthPicker.kt | 162 ++++++++++++++++++ gradle/libs.versions.toml | 6 +- 4 files changed, 179 insertions(+), 11 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/filtering/filtering/component/YearMonthPicker.kt diff --git a/feature/build.gradle.kts b/feature/build.gradle.kts index 6b56a6904..00c9bc09d 100644 --- a/feature/build.gradle.kts +++ b/feature/build.gradle.kts @@ -70,6 +70,7 @@ dependencies { implementation(libs.hilt.compiler) implementation(libs.androidx.lifecycle.runtime.compose.android) implementation(libs.androidx.compose.saveable) + implementation(libs.androidx.compose.material) // KspDependencies ksp(libs.hilt.android.compiler) @@ -94,11 +95,11 @@ dependencies { implementation(libs.accompanist.systemuicontroller) implementation (libs.androidx.core.splashscreen) implementation (libs.androidx.browser) + implementation(libs.compose.date.time.picker) // Compose Preview implementation(libs.compose.ui.tooling) // KakaoDependencies implementation(libs.kakao.user) - } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt index c6b5d9c79..387dc519a 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt @@ -22,13 +22,13 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.flowWithLifecycle import com.terning.core.designsystem.component.button.RectangleButton -import com.terning.core.designsystem.component.datepicker.DatePickerUI import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.toast import com.terning.feature.R +import com.terning.feature.filtering.filtering.component.YearMonthPicker import java.util.Calendar @Composable @@ -119,17 +119,20 @@ fun FilteringThreeScreen( modifier = Modifier.padding( top = 4.dp, start = 24.dp, - bottom = 24.dp ) ) Spacer(modifier = Modifier.weight(1f)) - DatePickerUI( - chosenYear = chosenYear, - chosenMonth = chosenMonth, - onYearChosen = { onYearChosen(it) }, - onMonthChosen = { onMonthChosen(it) }, + YearMonthPicker( + years = (2010..2030).map { it.toString() }, + months = (1..12).map { it.toString() }, ) - Spacer(modifier = Modifier.weight(3f)) +// DatePickerUI( +// chosenYear = chosenYear, +// chosenMonth = chosenMonth, +// onYearChosen = { onYearChosen(it) }, +// onMonthChosen = { onMonthChosen(it) }, +// ) + Spacer(modifier = Modifier.weight(6f)) RectangleButton( style = TerningTheme.typography.button0, paddingVertical = 20.dp, diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/component/YearMonthPicker.kt b/feature/src/main/java/com/terning/feature/filtering/filtering/component/YearMonthPicker.kt new file mode 100644 index 000000000..12e46a0b6 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/filtering/component/YearMonthPicker.kt @@ -0,0 +1,162 @@ +package com.terning.feature.filtering.filtering.component + +import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshotFlow +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.IntSize +import androidx.compose.ui.unit.dp +import com.kez.picker.PickerState +import com.kez.picker.rememberPickerState +import com.terning.core.designsystem.theme.Grey300 +import com.terning.core.designsystem.theme.Grey500 +import com.terning.core.designsystem.theme.TerningMain +import com.terning.core.designsystem.theme.TerningTheme +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.map + +@Composable +fun YearMonthPicker( + years: List, + months: List, + modifier: Modifier = Modifier, + yearPickerState: PickerState = rememberPickerState(), + monthPickerState: PickerState = rememberPickerState(), + startYearIndex: Int = 5, + startMonthIndex: Int = 2, +) { + Row( + modifier = modifier + .fillMaxWidth() + .padding(95.dp), + horizontalArrangement = Arrangement.SpaceBetween + ) { + DatePicker( + modifier = Modifier.weight(1f), + pickerState = yearPickerState, + items = years, + startIndex = startYearIndex, + ) + Spacer(modifier = Modifier.width(25.dp)) + DatePicker( + modifier = Modifier.weight(1f), + pickerState = monthPickerState, + items = months, + startIndex = startMonthIndex, + ) + } +} + +@Composable +fun DatePicker( + items: List, + modifier: Modifier = Modifier, + pickerState: PickerState = rememberPickerState(), + startIndex: Int = 0, + visibleItemCount: Int = 3, +) { + var itemHeightPixel by remember { mutableIntStateOf(0) } + val itemHeightDp = with(LocalDensity.current) { itemHeightPixel.toDp() } + + val visibleItemsMiddle = visibleItemCount / 2 + val scrollState = rememberLazyListState(initialFirstVisibleItemIndex = startIndex) + val flingBehavior = rememberSnapFlingBehavior(lazyListState = scrollState) + + LaunchedEffect(itemHeightPixel) { + if (itemHeightPixel > 0) scrollState.scrollToItem(startIndex) + } + + LaunchedEffect(scrollState) { + snapshotFlow { scrollState.firstVisibleItemIndex } + .map { index -> items.getOrNull(index) } + .distinctUntilChanged() + .collect { item -> + if (item != null) { + pickerState.selectedItem = item + } + } + } + + Box( + modifier = modifier + ) { + LazyColumn( + modifier = Modifier + .fillMaxWidth() + .height(itemHeightDp * visibleItemCount), + flingBehavior = flingBehavior, + state = scrollState, + horizontalAlignment = Alignment.CenterHorizontally + ) { + items(visibleItemsMiddle) { + Spacer(modifier = Modifier.height(itemHeightDp)) + } + items(items.size) { index -> + DatePickerContent( + modifier = Modifier + .onSizeChanged { intSize: IntSize -> itemHeightPixel = intSize.height }, + text = items[index], + color = if (pickerState.selectedItem == items[index]) Grey500 else Grey300 + ) + } + items(visibleItemsMiddle) { + Spacer(modifier = Modifier.height(itemHeightDp)) + } + } + HorizontalDivider( + modifier = Modifier + .offset(y = itemHeightDp * visibleItemsMiddle) + .padding(horizontal = 7.dp), + color = TerningMain, + thickness = 1.dp + ) + HorizontalDivider( + modifier = Modifier + .offset(y = itemHeightDp * (visibleItemsMiddle + 1)) + .padding(horizontal = 7.dp), + color = TerningMain, + thickness = 1.dp + ) + } +} + +@Composable +fun DatePickerContent( + color: Color, + text: String, + modifier: Modifier = Modifier, +) { + Box( + modifier = modifier.padding(vertical = 11.dp) + ) { + Text( + text = text, + textAlign = TextAlign.Center, + style = TerningTheme.typography.title3, + color = color, + ) + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 33b6c185d..27a38941f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,11 +23,10 @@ ksp = "1.9.0-1.0.12" ## Compose androidxComposeBom = "2024.04.01" -androidxComposeCompiler = "1.5.14" androidxComposeMaterial3 = "1.2.1" composeNavigation = "2.8.0-beta04" composeSavable = "1.4.3" -composeFlowRow = "0.30.0" +composeDateTimePicker = "0.0.2" ## Hilt hilt = "2.48.1" @@ -92,11 +91,13 @@ browser = "1.4.0" ## dokka dokka = "1.9.0" +composeMaterial = "1.3.1" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" } androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreen" } +compose-date-time-picker = { module = "io.github.kez-lab:compose-date-time-picker", version.ref = "composeDateTimePicker" } junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" } @@ -171,6 +172,7 @@ kakao-user = {group = "com.kakao.sdk", name = "v2-user", version.ref = "kakaoVer process-phoenix = {group = "com.jakewharton", name = "process-phoenix", version.ref = "processPhoenix"} accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanistSystemuicontroller" } +androidx-compose-material = { group = "androidx.wear.compose", name = "compose-material", version.ref = "composeMaterial" } [plugins] android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } From 90f1c9e2c2bf98806bedb1ea9b09a60e78ccb419 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 06:09:45 +0900 Subject: [PATCH 06/19] =?UTF-8?q?[MOVE/#218]=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/build.gradle.kts | 1 - .../FilteringOneScreen.kt | 4 ++-- .../component/StatusOneRadioGroup.kt | 2 +- .../navigation/FilteringOneNavigation.kt | 5 +++-- .../FilteringState.kt | 2 +- .../FilteringThreeRoute.kt | 4 ++-- .../FilteringThreeSideEffect.kt | 2 +- .../FilteringViewModel.kt | 2 +- .../component/YearMonthPicker.kt | 14 +++++++++++--- .../navigation/FilteringThreeNavigation.kt | 4 ++-- .../FilteringTwoScreen.kt | 4 ++-- .../component/StatusTwoRadioGroup.kt | 2 +- .../navigation/FilteringTwoNavigation.kt | 5 +++-- .../navigation/StartFilteringNavigation.kt | 2 +- .../java/com/terning/feature/main/MainScreen.kt | 6 +++--- .../signup/navigation/SignUpNavigation.kt | 1 - gradle/libs.versions.toml | 2 -- 17 files changed, 34 insertions(+), 28 deletions(-) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringone}/FilteringOneScreen.kt (96%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringone}/component/StatusOneRadioGroup.kt (97%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringone}/navigation/FilteringOneNavigation.kt (82%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringthree}/FilteringState.kt (73%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringthree}/FilteringThreeRoute.kt (97%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringthree}/FilteringThreeSideEffect.kt (81%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringthree}/FilteringViewModel.kt (97%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringthree}/component/YearMonthPicker.kt (95%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringthree}/navigation/FilteringThreeNavigation.kt (89%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringtwo}/FilteringTwoScreen.kt (96%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringtwo}/component/StatusTwoRadioGroup.kt (97%) rename feature/src/main/java/com/terning/feature/filtering/{filtering => filteringtwo}/navigation/FilteringTwoNavigation.kt (83%) diff --git a/feature/build.gradle.kts b/feature/build.gradle.kts index 00c9bc09d..e157e7816 100644 --- a/feature/build.gradle.kts +++ b/feature/build.gradle.kts @@ -95,7 +95,6 @@ dependencies { implementation(libs.accompanist.systemuicontroller) implementation (libs.androidx.core.splashscreen) implementation (libs.androidx.browser) - implementation(libs.compose.date.time.picker) // Compose Preview implementation(libs.compose.ui.tooling) diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringOneScreen.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneScreen.kt similarity index 96% rename from feature/src/main/java/com/terning/feature/filtering/filtering/FilteringOneScreen.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneScreen.kt index a8065f029..8d0d3afcc 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringOneScreen.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneScreen.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering +package com.terning.feature.filtering.filteringone import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column @@ -23,7 +23,7 @@ import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.feature.R -import com.terning.feature.filtering.filtering.component.StatusOneRadioGroup +import com.terning.feature.filtering.filteringone.component.StatusOneRadioGroup @Composable fun FilteringOneScreen( diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusOneRadioGroup.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/component/StatusOneRadioGroup.kt similarity index 97% rename from feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusOneRadioGroup.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringone/component/StatusOneRadioGroup.kt index d37dc6471..80608aa73 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusOneRadioGroup.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/component/StatusOneRadioGroup.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering.component +package com.terning.feature.filtering.filteringone.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.fillMaxWidth diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringOneNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt similarity index 82% rename from feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringOneNavigation.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt index 266137688..e5f25807e 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringOneNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering.navigation +package com.terning.feature.filtering.filteringone.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder @@ -7,7 +7,8 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route -import com.terning.feature.filtering.filtering.FilteringOneScreen +import com.terning.feature.filtering.filteringone.FilteringOneScreen +import com.terning.feature.filtering.filteringtwo.navigation.navigateFilteringTwo import kotlinx.serialization.Serializable fun NavController.navigateFilteringOne( diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringState.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringState.kt similarity index 73% rename from feature/src/main/java/com/terning/feature/filtering/filtering/FilteringState.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringState.kt index b35e6fbd2..7f75fc847 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringState.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringState.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering +package com.terning.feature.filtering.filteringthree data class FilteringState( val grade: Int = -1, diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt similarity index 97% rename from feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt index 387dc519a..faeb3e310 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering +package com.terning.feature.filtering.filteringthree import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column @@ -28,7 +28,7 @@ import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.toast import com.terning.feature.R -import com.terning.feature.filtering.filtering.component.YearMonthPicker +import com.terning.feature.filtering.filteringthree.component.YearMonthPicker import java.util.Calendar @Composable diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeSideEffect.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeSideEffect.kt similarity index 81% rename from feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeSideEffect.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeSideEffect.kt index da8d3dfa8..42cb61d6f 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringThreeSideEffect.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeSideEffect.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering +package com.terning.feature.filtering.filteringthree import androidx.annotation.StringRes diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt similarity index 97% rename from feature/src/main/java/com/terning/feature/filtering/filtering/FilteringViewModel.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt index b4b85b1a5..7b5a64cf2 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringViewModel.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering +package com.terning.feature.filtering.filteringthree import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/component/YearMonthPicker.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt similarity index 95% rename from feature/src/main/java/com/terning/feature/filtering/filtering/component/YearMonthPicker.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt index 12e46a0b6..87e8dd41a 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/component/YearMonthPicker.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering.component +package com.terning.feature.filtering.filteringthree.component import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior import androidx.compose.foundation.layout.Arrangement @@ -29,14 +29,22 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp -import com.kez.picker.PickerState -import com.kez.picker.rememberPickerState import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.Grey500 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningTheme import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map +import androidx.compose.runtime.mutableStateOf + +class PickerState { + var selectedItem by mutableStateOf("") +} + +@Composable +fun rememberPickerState() = remember { + PickerState() +} @Composable fun YearMonthPicker( diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringThreeNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/navigation/FilteringThreeNavigation.kt similarity index 89% rename from feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringThreeNavigation.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringthree/navigation/FilteringThreeNavigation.kt index 759c65c4d..57580223c 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringThreeNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/navigation/FilteringThreeNavigation.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering.navigation +package com.terning.feature.filtering.filteringthree.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder @@ -7,7 +7,7 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route -import com.terning.feature.filtering.filtering.FilteringThreeRoute +import com.terning.feature.filtering.filteringthree.FilteringThreeRoute import com.terning.feature.filtering.starthome.navigation.navigateStartHome import kotlinx.serialization.Serializable diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringTwoScreen.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoScreen.kt similarity index 96% rename from feature/src/main/java/com/terning/feature/filtering/filtering/FilteringTwoScreen.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoScreen.kt index 2f1e8c643..7f2849ce2 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/FilteringTwoScreen.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoScreen.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering +package com.terning.feature.filtering.filteringtwo import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column @@ -23,7 +23,7 @@ import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.feature.R -import com.terning.feature.filtering.filtering.component.StatusTwoRadioGroup +import com.terning.feature.filtering.filteringtwo.component.StatusTwoRadioGroup @Composable fun FilteringTwoScreen( diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusTwoRadioGroup.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/component/StatusTwoRadioGroup.kt similarity index 97% rename from feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusTwoRadioGroup.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringtwo/component/StatusTwoRadioGroup.kt index 6d42ee42a..ed06f467b 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/component/StatusTwoRadioGroup.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/component/StatusTwoRadioGroup.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering.component +package com.terning.feature.filtering.filteringtwo.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.fillMaxWidth diff --git a/feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringTwoNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/navigation/FilteringTwoNavigation.kt similarity index 83% rename from feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringTwoNavigation.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringtwo/navigation/FilteringTwoNavigation.kt index 0bde2ac5e..ab417cdab 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filtering/navigation/FilteringTwoNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/navigation/FilteringTwoNavigation.kt @@ -1,4 +1,4 @@ -package com.terning.feature.filtering.filtering.navigation +package com.terning.feature.filtering.filteringtwo.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder @@ -7,7 +7,8 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route -import com.terning.feature.filtering.filtering.FilteringTwoScreen +import com.terning.feature.filtering.filteringtwo.FilteringTwoScreen +import com.terning.feature.filtering.filteringthree.navigation.navigateFilteringThree import kotlinx.serialization.Serializable fun NavController.navigateFilteringTwo( diff --git a/feature/src/main/java/com/terning/feature/filtering/startfiltering/navigation/StartFilteringNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/startfiltering/navigation/StartFilteringNavigation.kt index f217cf39e..12b8a4cdc 100644 --- a/feature/src/main/java/com/terning/feature/filtering/startfiltering/navigation/StartFilteringNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/startfiltering/navigation/StartFilteringNavigation.kt @@ -7,7 +7,7 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route -import com.terning.feature.filtering.filtering.navigation.navigateFilteringOne +import com.terning.feature.filtering.filteringone.navigation.navigateFilteringOne import com.terning.feature.filtering.startfiltering.StartFilteringRoute import kotlinx.serialization.Serializable diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index e5fbb5d02..f4df34f39 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -25,9 +25,9 @@ import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.White import com.terning.core.util.NoRippleInteractionSource import com.terning.feature.calendar.calendar.navigation.calendarNavGraph -import com.terning.feature.filtering.filtering.navigation.filteringOneNavGraph -import com.terning.feature.filtering.filtering.navigation.filteringThreeNavGraph -import com.terning.feature.filtering.filtering.navigation.filteringTwoNavGraph +import com.terning.feature.filtering.filteringone.navigation.filteringOneNavGraph +import com.terning.feature.filtering.filteringthree.navigation.filteringThreeNavGraph +import com.terning.feature.filtering.filteringtwo.navigation.filteringTwoNavGraph import com.terning.feature.filtering.startfiltering.navigation.startFilteringNavGraph import com.terning.feature.filtering.starthome.navigation.startHomeNavGraph import com.terning.feature.home.changefilter.navigation.changeFilterNavGraph diff --git a/feature/src/main/java/com/terning/feature/onboarding/signup/navigation/SignUpNavigation.kt b/feature/src/main/java/com/terning/feature/onboarding/signup/navigation/SignUpNavigation.kt index 95932966e..ff8c1978e 100644 --- a/feature/src/main/java/com/terning/feature/onboarding/signup/navigation/SignUpNavigation.kt +++ b/feature/src/main/java/com/terning/feature/onboarding/signup/navigation/SignUpNavigation.kt @@ -7,7 +7,6 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route -import com.terning.feature.filtering.filtering.navigation.navigateFilteringOne import com.terning.feature.filtering.startfiltering.navigation.navigateStartFiltering import com.terning.feature.onboarding.signup.SignUpRoute import kotlinx.serialization.Serializable diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 27a38941f..df2ce469f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -26,7 +26,6 @@ androidxComposeBom = "2024.04.01" androidxComposeMaterial3 = "1.2.1" composeNavigation = "2.8.0-beta04" composeSavable = "1.4.3" -composeDateTimePicker = "0.0.2" ## Hilt hilt = "2.48.1" @@ -97,7 +96,6 @@ composeMaterial = "1.3.1" androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" } androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreen" } -compose-date-time-picker = { module = "io.github.kez-lab:compose-date-time-picker", version.ref = "composeDateTimePicker" } junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" } From 8b6571514953f5797f5ddd9fdce7745b394638d9 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 06:15:48 +0900 Subject: [PATCH 07/19] =?UTF-8?q?[DEL/#218]=20=EC=95=88=20=EC=93=B0?= =?UTF-8?q?=EB=8A=94=20=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/build.gradle.kts | 1 - .../filtering/filteringthree/component/YearMonthPicker.kt | 4 +--- gradle/libs.versions.toml | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/feature/build.gradle.kts b/feature/build.gradle.kts index e157e7816..781cf168f 100644 --- a/feature/build.gradle.kts +++ b/feature/build.gradle.kts @@ -70,7 +70,6 @@ dependencies { implementation(libs.hilt.compiler) implementation(libs.androidx.lifecycle.runtime.compose.android) implementation(libs.androidx.compose.saveable) - implementation(libs.androidx.compose.material) // KspDependencies ksp(libs.hilt.android.compiler) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt index 87e8dd41a..fcf0bf129 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt @@ -42,9 +42,7 @@ class PickerState { } @Composable -fun rememberPickerState() = remember { - PickerState() -} +fun rememberPickerState() = remember { PickerState() } @Composable fun YearMonthPicker( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index df2ce469f..2d60e8d41 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -90,7 +90,6 @@ browser = "1.4.0" ## dokka dokka = "1.9.0" -composeMaterial = "1.3.1" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" } @@ -170,7 +169,6 @@ kakao-user = {group = "com.kakao.sdk", name = "v2-user", version.ref = "kakaoVer process-phoenix = {group = "com.jakewharton", name = "process-phoenix", version.ref = "processPhoenix"} accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanistSystemuicontroller" } -androidx-compose-material = { group = "androidx.wear.compose", name = "compose-material", version.ref = "composeMaterial" } [plugins] android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } From 9b9c7d2620ceae7c1b561e3c47ed4bfb1d266506 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 06:48:50 +0900 Subject: [PATCH 08/19] =?UTF-8?q?[FEAT/#218]=20=EB=8D=B0=EC=9D=B4=ED=8A=B8?= =?UTF-8?q?=ED=94=BC=EC=BB=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filteringthree/FilteringThreeRoute.kt | 16 ++--- .../component/YearMonthPicker.kt | 58 ++++++++++++++----- 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt index faeb3e310..e8e505b7f 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt @@ -43,7 +43,7 @@ fun FilteringThreeRoute( val lifecycleOwner = LocalLifecycleOwner.current val currentYear = Calendar.getInstance().get(Calendar.YEAR) - val currentMonth = Calendar.getInstance().get(Calendar.MONTH) + val currentMonth = Calendar.getInstance().get(Calendar.MONTH) + 1 var chosenYear by remember { mutableIntStateOf(currentYear) } var chosenMonth by remember { mutableIntStateOf(currentMonth) } @@ -123,16 +123,12 @@ fun FilteringThreeScreen( ) Spacer(modifier = Modifier.weight(1f)) YearMonthPicker( - years = (2010..2030).map { it.toString() }, - months = (1..12).map { it.toString() }, + chosenYear = chosenYear, + chosenMonth = chosenMonth, + onYearChosen = { onYearChosen(it) }, + onMonthChosen = { onMonthChosen(it) }, ) -// DatePickerUI( -// chosenYear = chosenYear, -// chosenMonth = chosenMonth, -// onYearChosen = { onYearChosen(it) }, -// onMonthChosen = { onMonthChosen(it) }, -// ) - Spacer(modifier = Modifier.weight(6f)) + Spacer(modifier = Modifier.weight(7f)) RectangleButton( style = TerningTheme.typography.button0, paddingVertical = 20.dp, diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt index fcf0bf129..4b790121a 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt @@ -18,6 +18,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow @@ -35,7 +36,18 @@ import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningTheme import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map -import androidx.compose.runtime.mutableStateOf +import okhttp3.internal.toImmutableList + +private const val START_YEAR = 2010 +private const val END_YEAR = 2030 +private const val START_MONTH = 1 +private const val END_MONTH = 12 + +private val years = + (START_YEAR..END_YEAR).map { "${it}년" }.toImmutableList() + +private val months = + (START_MONTH..END_MONTH).map { "${it}월" }.toImmutableList() class PickerState { var selectedItem by mutableStateOf("") @@ -46,32 +58,50 @@ fun rememberPickerState() = remember { PickerState() } @Composable fun YearMonthPicker( - years: List, - months: List, modifier: Modifier = Modifier, - yearPickerState: PickerState = rememberPickerState(), - monthPickerState: PickerState = rememberPickerState(), - startYearIndex: Int = 5, - startMonthIndex: Int = 2, + chosenYear: Int, + chosenMonth: Int, + onYearChosen: (Int) -> Unit, + onMonthChosen: (Int) -> Unit, ) { + val yearPickerState = rememberPickerState() + val monthPickerState = rememberPickerState() + + val startYearIndex = years.indexOf("${chosenYear}년").takeIf { it >= 0 } ?: 0 + val startMonthIndex = months.indexOf("${chosenMonth}월").takeIf { it >= 0 } ?: 0 + + LaunchedEffect(chosenYear) { + yearPickerState.selectedItem = "${chosenYear}년" + } + + LaunchedEffect(chosenMonth) { + monthPickerState.selectedItem = "${chosenMonth}월" + } + Row( modifier = modifier .fillMaxWidth() - .padding(95.dp), - horizontalArrangement = Arrangement.SpaceBetween + .padding(horizontal = 95.dp), + horizontalArrangement = Arrangement.Center ) { DatePicker( modifier = Modifier.weight(1f), pickerState = yearPickerState, items = years, startIndex = startYearIndex, + onItemSelected = { year -> + onYearChosen(year.dropLast(1).toInt()) + } ) - Spacer(modifier = Modifier.width(25.dp)) + Spacer(modifier = Modifier.width(18.dp)) DatePicker( modifier = Modifier.weight(1f), pickerState = monthPickerState, items = months, startIndex = startMonthIndex, + onItemSelected = { month -> + onMonthChosen(month.dropLast(1).toInt()) + } ) } } @@ -83,6 +113,7 @@ fun DatePicker( pickerState: PickerState = rememberPickerState(), startIndex: Int = 0, visibleItemCount: Int = 3, + onItemSelected: (String) -> Unit ) { var itemHeightPixel by remember { mutableIntStateOf(0) } val itemHeightDp = with(LocalDensity.current) { itemHeightPixel.toDp() } @@ -100,8 +131,9 @@ fun DatePicker( .map { index -> items.getOrNull(index) } .distinctUntilChanged() .collect { item -> - if (item != null) { - pickerState.selectedItem = item + item?.let { + pickerState.selectedItem = it + onItemSelected(it) } } } @@ -165,4 +197,4 @@ fun DatePickerContent( color = color, ) } -} \ No newline at end of file +} From 0a643bf64f2f3f5272e2071e337e29185bc8a2c2 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 06:56:25 +0900 Subject: [PATCH 09/19] =?UTF-8?q?[FEAT/#218]=20=EC=BA=98=EB=A6=B0=EB=8D=94?= =?UTF-8?q?=20=ED=99=95=EC=9E=A5=ED=95=A8=EC=88=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/terning/core/extension/CalendarExt.kt | 7 +++++++ .../main/java/com/terning/core/util/CalendarDefaults.kt | 8 ++++++++ .../filteringthree/component/YearMonthPicker.kt | 9 ++++----- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 core/src/main/java/com/terning/core/extension/CalendarExt.kt create mode 100644 core/src/main/java/com/terning/core/util/CalendarDefaults.kt diff --git a/core/src/main/java/com/terning/core/extension/CalendarExt.kt b/core/src/main/java/com/terning/core/extension/CalendarExt.kt new file mode 100644 index 000000000..1bbc06b8a --- /dev/null +++ b/core/src/main/java/com/terning/core/extension/CalendarExt.kt @@ -0,0 +1,7 @@ +package com.terning.core.extension + +import java.util.Calendar + +val Calendar.currentYear: Int get() = get(Calendar.YEAR) + +val Calendar.currentMonth: Int get() = get(Calendar.MONTH) + 1 \ No newline at end of file diff --git a/core/src/main/java/com/terning/core/util/CalendarDefaults.kt b/core/src/main/java/com/terning/core/util/CalendarDefaults.kt new file mode 100644 index 000000000..2d0cb8355 --- /dev/null +++ b/core/src/main/java/com/terning/core/util/CalendarDefaults.kt @@ -0,0 +1,8 @@ +package com.terning.core.util + +object CalendarDefaults { + const val START_YEAR = 2010 + const val END_YEAR = 2030 + const val START_MONTH = 1 + const val END_MONTH = 12 +} diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt index 4b790121a..d61c06c98 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/component/YearMonthPicker.kt @@ -34,15 +34,14 @@ import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.Grey500 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningTheme +import com.terning.core.util.CalendarDefaults.END_MONTH +import com.terning.core.util.CalendarDefaults.END_YEAR +import com.terning.core.util.CalendarDefaults.START_MONTH +import com.terning.core.util.CalendarDefaults.START_YEAR import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map import okhttp3.internal.toImmutableList -private const val START_YEAR = 2010 -private const val END_YEAR = 2030 -private const val START_MONTH = 1 -private const val END_MONTH = 12 - private val years = (START_YEAR..END_YEAR).map { "${it}년" }.toImmutableList() From a3c673a81649580058bfba8e5e8ca195443cc479 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 07:01:34 +0900 Subject: [PATCH 10/19] =?UTF-8?q?[FEAT/#218]=20=EC=BA=98=EB=A6=B0=EB=8D=94?= =?UTF-8?q?=20=ED=99=95=EC=9E=A5=ED=95=A8=EC=88=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/filtering/filteringthree/FilteringThreeRoute.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt index e8e505b7f..969475c00 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt @@ -26,6 +26,8 @@ import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme +import com.terning.core.extension.currentMonth +import com.terning.core.extension.currentYear import com.terning.core.extension.toast import com.terning.feature.R import com.terning.feature.filtering.filteringthree.component.YearMonthPicker @@ -42,8 +44,8 @@ fun FilteringThreeRoute( val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current - val currentYear = Calendar.getInstance().get(Calendar.YEAR) - val currentMonth = Calendar.getInstance().get(Calendar.MONTH) + 1 + val currentYear = Calendar.getInstance().currentYear + val currentMonth = Calendar.getInstance().currentMonth var chosenYear by remember { mutableIntStateOf(currentYear) } var chosenMonth by remember { mutableIntStateOf(currentMonth) } From de564894a21f2ffdedbb78052088c877b7f7cc84 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 07:12:56 +0900 Subject: [PATCH 11/19] =?UTF-8?q?[FEAT/#218]=20=EB=A1=9C=EC=A7=81=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 --- .../filteringthree/FilteringThreeRoute.kt | 39 ++++++++++--------- .../FilteringThreeSideEffect.kt | 1 + .../filteringthree/FilteringViewModel.kt | 10 +++-- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt index 969475c00..54eeafa9b 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt @@ -9,9 +9,6 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource @@ -20,6 +17,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle import com.terning.core.designsystem.component.button.RectangleButton import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar @@ -41,23 +39,25 @@ fun FilteringThreeRoute( navigateToStartHome: () -> Unit, viewModel: FilteringViewModel = hiltViewModel(), ) { + val state by viewModel.state.collectAsStateWithLifecycle() + val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current - val currentYear = Calendar.getInstance().currentYear - val currentMonth = Calendar.getInstance().currentMonth - - var chosenYear by remember { mutableIntStateOf(currentYear) } - var chosenMonth by remember { mutableIntStateOf(currentMonth) } - LaunchedEffect(key1 = true) { - viewModel.fetchGrade(grade = grade) - viewModel.fetchWorkingPeriod(workingPeriod = workingPeriod) + with(viewModel) { + updateGrade(grade = grade) + updateWorkingPeriod(workingPeriod = workingPeriod) + updateStartYear(startYear = Calendar.getInstance().currentYear) + updateStartMonth(startMonth = Calendar.getInstance().currentMonth) + } } - LaunchedEffect(key1 = chosenYear, key2 = chosenMonth) { - viewModel.fetchStartYear(chosenYear) - viewModel.fetchStartMonth(chosenMonth) + LaunchedEffect(key1 = state.startYear, key2 = state.startMonth) { + with(viewModel) { + updateStartYear(state.startYear) + updateStartMonth(state.startMonth) + } } LaunchedEffect(viewModel.sideEffects, lifecycleOwner) { @@ -66,17 +66,18 @@ fun FilteringThreeRoute( when (sideEffect) { is FilteringThreeSideEffect.NavigateToStartHome -> navigateToStartHome() is FilteringThreeSideEffect.ShowToast -> context.toast(sideEffect.message) + is FilteringThreeSideEffect.NavigateUp -> navigateUp() } } } FilteringThreeScreen( - navigateUp = { navigateUp() }, - chosenYear = chosenYear, - chosenMonth = chosenMonth, + navigateUp = { viewModel.navigateUp() }, + chosenYear = state.startYear, + chosenMonth = state.startMonth, onNextClick = { viewModel.postFilteringWithServer() }, - onYearChosen = { chosenYear = it }, - onMonthChosen = { chosenMonth = it } + onYearChosen = { viewModel.updateStartYear(it) }, + onMonthChosen = { viewModel.updateStartMonth(it) } ) } diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeSideEffect.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeSideEffect.kt index 42cb61d6f..3b035dc7c 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeSideEffect.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeSideEffect.kt @@ -5,4 +5,5 @@ import androidx.annotation.StringRes sealed class FilteringThreeSideEffect { data object NavigateToStartHome : FilteringThreeSideEffect() data class ShowToast(@StringRes val message: Int) : FilteringThreeSideEffect() + data object NavigateUp : FilteringThreeSideEffect() } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt index 7b5a64cf2..d5d5f9b58 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt @@ -28,19 +28,19 @@ class FilteringViewModel @Inject constructor( private val _sideEffects = MutableSharedFlow() val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() - fun fetchGrade(grade: Int) { + fun updateGrade(grade: Int) { _state.value = _state.value.copy(grade = grade) } - fun fetchWorkingPeriod(workingPeriod: Int) { + fun updateWorkingPeriod(workingPeriod: Int) { _state.value = _state.value.copy(workingPeriod = workingPeriod) } - fun fetchStartYear(startYear: Int) { + fun updateStartYear(startYear: Int) { _state.value = _state.value.copy(startYear = startYear) } - fun fetchStartMonth(startMonth: Int) { + fun updateStartMonth(startMonth: Int) { _state.value = _state.value.copy(startMonth = startMonth) } @@ -64,4 +64,6 @@ class FilteringViewModel @Inject constructor( } } + fun navigateUp() = viewModelScope.launch { _sideEffects.emit(FilteringThreeSideEffect.NavigateUp) } + } \ No newline at end of file From aa2531f4186d47b2a5fde4e555fb11b4e762577e Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 07:15:34 +0900 Subject: [PATCH 12/19] =?UTF-8?q?[FEAT/#218]=20=EB=A1=9C=EC=A7=81=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 --- .../feature/filtering/filteringthree/FilteringThreeRoute.kt | 6 +++--- .../filteringthree/navigation/FilteringThreeNavigation.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt index 54eeafa9b..2a872fe94 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt @@ -72,10 +72,10 @@ fun FilteringThreeRoute( } FilteringThreeScreen( - navigateUp = { viewModel.navigateUp() }, + navigateUp = viewModel::navigateUp, chosenYear = state.startYear, chosenMonth = state.startMonth, - onNextClick = { viewModel.postFilteringWithServer() }, + onNextClick = viewModel::postFilteringWithServer, onYearChosen = { viewModel.updateStartYear(it) }, onMonthChosen = { viewModel.updateStartMonth(it) } ) @@ -94,7 +94,7 @@ fun FilteringThreeScreen( modifier = Modifier, ) { BackButtonTopAppBar( - onBackButtonClick = { navigateUp() } + onBackButtonClick = navigateUp ) Column( modifier = Modifier.fillMaxSize() diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/navigation/FilteringThreeNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/navigation/FilteringThreeNavigation.kt index 57580223c..2a0257744 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/navigation/FilteringThreeNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/navigation/FilteringThreeNavigation.kt @@ -30,8 +30,8 @@ fun NavGraphBuilder.filteringThreeNavGraph( FilteringThreeRoute( grade = args.grade, workingPeriod = args.workingPeriod, - navigateUp = { navHostController.navigateUp() }, - navigateToStartHome = { navHostController.navigateStartHome() } + navigateUp = navHostController::navigateUp, + navigateToStartHome = navHostController::navigateStartHome ) } } From b7d263ca0d188d6d03c839dafbcf1b86e2f53969 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 07:26:33 +0900 Subject: [PATCH 13/19] =?UTF-8?q?[FEAT/#218]=20=EC=BA=98=EB=A6=B0=EB=8D=94?= =?UTF-8?q?=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filtering/filteringthree/FilteringThreeRoute.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt index 2a872fe94..6e19a291a 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -48,8 +49,6 @@ fun FilteringThreeRoute( with(viewModel) { updateGrade(grade = grade) updateWorkingPeriod(workingPeriod = workingPeriod) - updateStartYear(startYear = Calendar.getInstance().currentYear) - updateStartMonth(startMonth = Calendar.getInstance().currentMonth) } } @@ -73,8 +72,8 @@ fun FilteringThreeRoute( FilteringThreeScreen( navigateUp = viewModel::navigateUp, - chosenYear = state.startYear, - chosenMonth = state.startMonth, + chosenYear = Calendar.getInstance().currentYear, + chosenMonth = Calendar.getInstance().currentMonth, onNextClick = viewModel::postFilteringWithServer, onYearChosen = { viewModel.updateStartYear(it) }, onMonthChosen = { viewModel.updateStartMonth(it) } @@ -124,14 +123,14 @@ fun FilteringThreeScreen( start = 24.dp, ) ) - Spacer(modifier = Modifier.weight(1f)) + Spacer(modifier = Modifier.height(61.dp)) YearMonthPicker( chosenYear = chosenYear, chosenMonth = chosenMonth, onYearChosen = { onYearChosen(it) }, onMonthChosen = { onMonthChosen(it) }, ) - Spacer(modifier = Modifier.weight(7f)) + Spacer(modifier = Modifier.weight(1f)) RectangleButton( style = TerningTheme.typography.button0, paddingVertical = 20.dp, From 990a776328f1c33cfae0bcb4021c63c653687db3 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 07:32:11 +0900 Subject: [PATCH 14/19] =?UTF-8?q?[FEAT/#218]=20=ED=95=84=ED=84=B0=EB=A7=81?= =?UTF-8?q?=20=EB=B2=84=ED=8A=BC=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/designsystem/component/button/FilteringButton.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/button/FilteringButton.kt b/core/src/main/java/com/terning/core/designsystem/component/button/FilteringButton.kt index f0c50d820..bc0ca38db 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/button/FilteringButton.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/button/FilteringButton.kt @@ -58,8 +58,9 @@ fun FilteringButton( val isPressed by interactionSource.collectIsPressedAsState() val backgroundColor = White val textColor = when { - isSelected -> TerningMain - else -> Grey375 + !isSelected -> Grey375 + isPressed -> Grey375 + else -> TerningMain } val borderColor = when { !isSelected && !isPressed -> Grey150 From 93ca5c68cad214af64f9fb41386813bb31cc3f9d Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 07:54:35 +0900 Subject: [PATCH 15/19] =?UTF-8?q?[FEAT/#218]=20=ED=95=84=ED=84=B0=EB=A7=81?= =?UTF-8?q?=20=EC=9B=90=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eringOneScreen.kt => FilteringOneRoute.kt} | 61 ++++++++++++++----- .../filteringone/FilteringOneSideEffect.kt | 5 ++ .../filteringone/FilteringOneState.kt | 6 ++ .../filteringone/FilteringOneViewModel.kt | 31 ++++++++++ .../navigation/FilteringOneNavigation.kt | 4 +- .../filteringthree/FilteringThreeRoute.kt | 2 +- ...lteringState.kt => FilteringThreeState.kt} | 2 +- ...iewModel.kt => FilteringThreeViewModel.kt} | 6 +- 8 files changed, 96 insertions(+), 21 deletions(-) rename feature/src/main/java/com/terning/feature/filtering/filteringone/{FilteringOneScreen.kt => FilteringOneRoute.kt} (69%) create mode 100644 feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneSideEffect.kt create mode 100644 feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneState.kt create mode 100644 feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt rename feature/src/main/java/com/terning/feature/filtering/filteringthree/{FilteringState.kt => FilteringThreeState.kt} (84%) rename feature/src/main/java/com/terning/feature/filtering/filteringthree/{FilteringViewModel.kt => FilteringThreeViewModel.kt} (92%) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneScreen.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt similarity index 69% rename from feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneScreen.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt index 8d0d3afcc..93166b9c8 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneScreen.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt @@ -7,16 +7,17 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue 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.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.flowWithLifecycle import com.terning.core.designsystem.component.button.RectangleButton import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey300 @@ -26,20 +27,52 @@ import com.terning.feature.R import com.terning.feature.filtering.filteringone.component.StatusOneRadioGroup @Composable -fun FilteringOneScreen( +fun FilteringOneRoute( name: String, onNextClick: (Int) -> Unit, navigateUp: () -> Unit, - onButtonClick: (Int) -> Unit = {}, + viewModel: FilteringOneViewModel = hiltViewModel() ) { - val isButtonValid = remember { mutableStateOf(false) } - var grade by remember { mutableIntStateOf(-1) } + val state by viewModel.state.collectAsStateWithLifecycle() + + val lifecycleOwner = LocalLifecycleOwner.current + + LaunchedEffect(viewModel.sideEffects, lifecycleOwner) { + viewModel.sideEffects.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) + .collect { sideEffect -> + when (sideEffect) { + is FilteringOneSideEffect.NavigateUp -> navigateUp() + } + } + } + + FilteringOneScreen( + name = name, + onButtonClick = { index -> + viewModel.updateGrade(index) + viewModel.updateButtonValidation() + }, + onNextClick = onNextClick, + navigateUp = viewModel::navigateUp, + buttonState = state.isButtonValid, + gradeState = state.grade + ) +} +@Composable +fun FilteringOneScreen( + name: String, + onNextClick: (Int) -> Unit, + navigateUp: () -> Unit, + onButtonClick: (Int) -> Unit, + buttonState: Boolean, + gradeState: Int +) { Column( modifier = Modifier ) { BackButtonTopAppBar( - onBackButtonClick = { navigateUp() } + onBackButtonClick = navigateUp ) Column( modifier = Modifier.fillMaxSize() @@ -79,8 +112,6 @@ fun FilteringOneScreen( StatusOneRadioGroup( onButtonClick = { index -> onButtonClick(index) - isButtonValid.value = true - grade = index } ) Text( @@ -96,9 +127,9 @@ fun FilteringOneScreen( style = TerningTheme.typography.button0, paddingVertical = 20.dp, text = R.string.filtering_button, - onButtonClick = { onNextClick(grade) }, + onButtonClick = { onNextClick(gradeState) }, modifier = Modifier.padding(bottom = 12.dp), - isEnabled = isButtonValid.value + isEnabled = buttonState ) } } @@ -112,7 +143,9 @@ fun FilteringOneScreenPreview() { name = "터닝이", onButtonClick = {}, onNextClick = {}, - navigateUp = {} + navigateUp = {}, + buttonState = true, + gradeState = 1 ) } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneSideEffect.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneSideEffect.kt new file mode 100644 index 000000000..5fdbaaaa6 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneSideEffect.kt @@ -0,0 +1,5 @@ +package com.terning.feature.filtering.filteringone + +sealed class FilteringOneSideEffect { + data object NavigateUp : FilteringOneSideEffect() +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneState.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneState.kt new file mode 100644 index 000000000..06c28b481 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneState.kt @@ -0,0 +1,6 @@ +package com.terning.feature.filtering.filteringone + +data class FilteringOneState( + val isButtonValid: Boolean = false, + val grade: Int = -1 +) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt new file mode 100644 index 000000000..214b0447d --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt @@ -0,0 +1,31 @@ +package com.terning.feature.filtering.filteringone + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch + +class FilteringOneViewModel : ViewModel() { + + private val _state: MutableStateFlow = MutableStateFlow(FilteringOneState()) + val state: StateFlow get() = _state.asStateFlow() + + private val _sideEffects = MutableSharedFlow() + val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() + + fun updateButtonValidation() { + _state.value = _state.value.copy(isButtonValid = true) + } + + fun updateGrade(grade: Int) { + _state.value = _state.value.copy(grade = grade) + } + + fun navigateUp() = + viewModelScope.launch { _sideEffects.emit(FilteringOneSideEffect.NavigateUp) } +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt index e5f25807e..c260aaec1 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt @@ -7,7 +7,7 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route -import com.terning.feature.filtering.filteringone.FilteringOneScreen +import com.terning.feature.filtering.filteringone.FilteringOneRoute import com.terning.feature.filtering.filteringtwo.navigation.navigateFilteringTwo import kotlinx.serialization.Serializable @@ -26,7 +26,7 @@ fun NavGraphBuilder.filteringOneNavGraph( ) { composable { val args = it.toRoute() - FilteringOneScreen( + FilteringOneRoute( name = args.name, onNextClick = { grade -> navHostController.navigateFilteringTwo(grade) }, navigateUp = { navHostController.navigateUp() } diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt index 6e19a291a..ff3a10a0e 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt @@ -38,7 +38,7 @@ fun FilteringThreeRoute( workingPeriod: Int, navigateUp: () -> Unit, navigateToStartHome: () -> Unit, - viewModel: FilteringViewModel = hiltViewModel(), + viewModel: FilteringThreeViewModel = hiltViewModel(), ) { val state by viewModel.state.collectAsStateWithLifecycle() diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringState.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeState.kt similarity index 84% rename from feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringState.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeState.kt index 7f75fc847..d907353f9 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringState.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeState.kt @@ -1,6 +1,6 @@ package com.terning.feature.filtering.filteringthree -data class FilteringState( +data class FilteringThreeState( val grade: Int = -1, val workingPeriod: Int = -1, val startYear: Int = -1, diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeViewModel.kt similarity index 92% rename from feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeViewModel.kt index d5d5f9b58..9c31c3c86 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringViewModel.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeViewModel.kt @@ -17,13 +17,13 @@ import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel -class FilteringViewModel @Inject constructor( +class FilteringThreeViewModel @Inject constructor( private val filteringRepository: FilteringRepository, private val tokenRepository: TokenRepository ) : ViewModel() { - private val _state = MutableStateFlow(FilteringState()) - val state: StateFlow get() = _state.asStateFlow() + private val _state = MutableStateFlow(FilteringThreeState()) + val state: StateFlow get() = _state.asStateFlow() private val _sideEffects = MutableSharedFlow() val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() From 016fc7c7eee49728884e66fd3b46a93615618187 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 4 Sep 2024 08:04:47 +0900 Subject: [PATCH 16/19] =?UTF-8?q?[FEAT/#218]=20=ED=95=84=ED=84=B0=EB=A7=81?= =?UTF-8?q?=20=ED=88=AC=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eringTwoScreen.kt => FilteringTwoRoute.kt} | 58 +++++++++++++++---- .../filteringtwo/FilteringTwoSideEffect.kt | 5 ++ .../filteringtwo/FilteringTwoState.kt | 6 ++ .../filteringtwo/FilteringTwoViewModel.kt | 33 +++++++++++ .../navigation/FilteringTwoNavigation.kt | 6 +- 5 files changed, 93 insertions(+), 15 deletions(-) rename feature/src/main/java/com/terning/feature/filtering/filteringtwo/{FilteringTwoScreen.kt => FilteringTwoRoute.kt} (67%) create mode 100644 feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoSideEffect.kt create mode 100644 feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoState.kt create mode 100644 feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoScreen.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt similarity index 67% rename from feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoScreen.kt rename to feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt index 7f2849ce2..8c1a5b7b7 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoScreen.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt @@ -7,16 +7,17 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue 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.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.flowWithLifecycle import com.terning.core.designsystem.component.button.RectangleButton import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey300 @@ -26,15 +27,47 @@ import com.terning.feature.R import com.terning.feature.filtering.filteringtwo.component.StatusTwoRadioGroup @Composable -fun FilteringTwoScreen( +fun FilteringTwoRoute( grade: Int, onNextClick: (Int, Int) -> Unit, navigateUp: () -> Unit, - onButtonClick: (Int) -> Unit = {}, + viewModel: FilteringTwoViewModel = hiltViewModel() ) { - val isButtonValid = remember { mutableStateOf(false) } - var workingPeriod by remember { mutableIntStateOf(-1) } + val state by viewModel.state.collectAsStateWithLifecycle() + + val lifecycleOwner = LocalLifecycleOwner.current + + LaunchedEffect(viewModel.sideEffects, lifecycleOwner) { + viewModel.sideEffects.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) + .collect { sideEffect -> + when (sideEffect) { + is FilteringTwoSideEffect.NavigateUp -> navigateUp() + } + } + } + + FilteringTwoScreen( + grade = grade, + onNextClick = onNextClick, + navigateUp = viewModel::navigateUp, + onButtonClick = { index -> + viewModel.updateWorkingPeriod(index) + viewModel.updateButtonValidation() + }, + buttonState = state.isButtonValid, + workingPeriod = state.workingPeriod + ) +} +@Composable +fun FilteringTwoScreen( + grade: Int, + onNextClick: (Int, Int) -> Unit, + navigateUp: () -> Unit, + onButtonClick: (Int) -> Unit, + buttonState: Boolean, + workingPeriod: Int +) { Column( modifier = Modifier ) { @@ -73,8 +106,6 @@ fun FilteringTwoScreen( StatusTwoRadioGroup( onButtonClick = { index -> onButtonClick(index) - isButtonValid.value = true - workingPeriod = index } ) Spacer(modifier = Modifier.weight(1f)) @@ -84,7 +115,7 @@ fun FilteringTwoScreen( text = R.string.filtering_button, onButtonClick = { onNextClick(grade, workingPeriod) }, modifier = Modifier.padding(bottom = 12.dp), - isEnabled = isButtonValid.value + isEnabled = buttonState ) } } @@ -97,7 +128,10 @@ fun FilteringTwoScreenPreview() { FilteringTwoScreen( grade = 1, onNextClick = { _, _ -> }, - navigateUp = { } + navigateUp = { }, + onButtonClick = { }, + buttonState = true, + workingPeriod = 1 ) } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoSideEffect.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoSideEffect.kt new file mode 100644 index 000000000..a858577c1 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoSideEffect.kt @@ -0,0 +1,5 @@ +package com.terning.feature.filtering.filteringtwo + +sealed class FilteringTwoSideEffect { + data object NavigateUp : FilteringTwoSideEffect() +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoState.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoState.kt new file mode 100644 index 000000000..383049e07 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoState.kt @@ -0,0 +1,6 @@ +package com.terning.feature.filtering.filteringtwo + +data class FilteringTwoState( + val isButtonValid: Boolean = false, + val workingPeriod: Int = -1 +) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt new file mode 100644 index 000000000..3dc4c8afd --- /dev/null +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt @@ -0,0 +1,33 @@ +package com.terning.feature.filtering.filteringtwo + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.terning.feature.filtering.filteringone.FilteringOneSideEffect +import com.terning.feature.filtering.filteringone.FilteringOneState +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch + +class FilteringTwoViewModel : ViewModel(){ + + private val _state: MutableStateFlow = MutableStateFlow(FilteringTwoState()) + val state: StateFlow get() = _state.asStateFlow() + + private val _sideEffects = MutableSharedFlow() + val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() + + fun updateButtonValidation() { + _state.value = _state.value.copy(isButtonValid = true) + } + + fun updateWorkingPeriod(workingPeriod: Int) { + _state.value = _state.value.copy(workingPeriod = workingPeriod) + } + + fun navigateUp() = + viewModelScope.launch { _sideEffects.emit(FilteringTwoSideEffect.NavigateUp) } +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/navigation/FilteringTwoNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/navigation/FilteringTwoNavigation.kt index ab417cdab..a05a89835 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/navigation/FilteringTwoNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/navigation/FilteringTwoNavigation.kt @@ -7,8 +7,8 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.terning.core.navigation.Route -import com.terning.feature.filtering.filteringtwo.FilteringTwoScreen import com.terning.feature.filtering.filteringthree.navigation.navigateFilteringThree +import com.terning.feature.filtering.filteringtwo.FilteringTwoRoute import kotlinx.serialization.Serializable fun NavController.navigateFilteringTwo( @@ -26,7 +26,7 @@ fun NavGraphBuilder.filteringTwoNavGraph( ) { composable { val args = it.toRoute() - FilteringTwoScreen( + FilteringTwoRoute( grade = args.grade, onNextClick = { _, workingPeriod -> navHostController.navigateFilteringThree( @@ -34,7 +34,7 @@ fun NavGraphBuilder.filteringTwoNavGraph( workingPeriod = workingPeriod ) }, - navigateUp = { navHostController.navigateUp() } + navigateUp = navHostController::navigateUp ) } } From e410bb5f69b6d8c7da1e1341ab4e6a4303ca4aa0 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Thu, 5 Sep 2024 04:09:27 +0900 Subject: [PATCH 17/19] =?UTF-8?q?[FEAT/#218]=20=ED=8C=A8=EB=94=A9=EA=B0=92?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/feature/onboarding/signup/SignUpRoute.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpRoute.kt b/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpRoute.kt index 9a963fe57..4be2f12c7 100644 --- a/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpRoute.kt +++ b/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpRoute.kt @@ -123,7 +123,6 @@ fun SignUpScreen( Column( modifier = Modifier.align(Alignment.CenterHorizontally) ) { - Spacer(modifier = Modifier.height(48.dp)) ProfileWithPlusButton( modifier = Modifier.noRippleClickable { onProfileEditClick(true) From 278d274ec671d8d6075fadca3f58f0fa7e609f75 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sat, 7 Sep 2024 10:15:01 +0900 Subject: [PATCH 18/19] =?UTF-8?q?[FEAT/#218]=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=ED=95=A9=EC=B9=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filtering/filteringone/FilteringOneRoute.kt | 3 +-- .../filteringone/FilteringOneViewModel.kt | 11 +++++------ .../filtering/filteringtwo/FilteringTwoRoute.kt | 3 +-- .../filteringtwo/FilteringTwoViewModel.kt | 15 ++++++--------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt index 1d3dd595f..930e81fb7 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt @@ -53,8 +53,7 @@ fun FilteringOneRoute( FilteringOneScreen( name = name, onButtonClick = { index -> - viewModel.updateGrade(index) - viewModel.updateButtonValidation() + viewModel.updateGradeAndButton(index) }, onNextClick = onNextClick, navigateUp = viewModel::navigateUp, diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt index 214b0447d..93829d006 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt @@ -18,12 +18,11 @@ class FilteringOneViewModel : ViewModel() { private val _sideEffects = MutableSharedFlow() val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() - fun updateButtonValidation() { - _state.value = _state.value.copy(isButtonValid = true) - } - - fun updateGrade(grade: Int) { - _state.value = _state.value.copy(grade = grade) + fun updateGradeAndButton(grade: Int) { + _state.value = _state.value.copy( + grade = grade, + isButtonValid = true + ) } fun navigateUp() = diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt index 3b00778d0..21361bdb5 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt @@ -55,8 +55,7 @@ fun FilteringTwoRoute( onNextClick = onNextClick, navigateUp = viewModel::navigateUp, onButtonClick = { index -> - viewModel.updateWorkingPeriod(index) - viewModel.updateButtonValidation() + viewModel.updateWorkingPeriodAndButton(index) }, buttonState = state.isButtonValid, workingPeriod = state.workingPeriod, diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt index 3dc4c8afd..2076a5221 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt @@ -2,8 +2,6 @@ package com.terning.feature.filtering.filteringtwo import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.terning.feature.filtering.filteringone.FilteringOneSideEffect -import com.terning.feature.filtering.filteringone.FilteringOneState import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -12,7 +10,7 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -class FilteringTwoViewModel : ViewModel(){ +class FilteringTwoViewModel : ViewModel() { private val _state: MutableStateFlow = MutableStateFlow(FilteringTwoState()) val state: StateFlow get() = _state.asStateFlow() @@ -20,12 +18,11 @@ class FilteringTwoViewModel : ViewModel(){ private val _sideEffects = MutableSharedFlow() val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() - fun updateButtonValidation() { - _state.value = _state.value.copy(isButtonValid = true) - } - - fun updateWorkingPeriod(workingPeriod: Int) { - _state.value = _state.value.copy(workingPeriod = workingPeriod) + fun updateWorkingPeriodAndButton(workingPeriod: Int) { + _state.value = _state.value.copy( + workingPeriod = workingPeriod, + isButtonValid = true + ) } fun navigateUp() = From fc8c1f3b72230e780c183cc293a4d817cb689d43 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sat, 7 Sep 2024 10:22:14 +0900 Subject: [PATCH 19/19] =?UTF-8?q?[FEAT/#218]=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filteringone/navigation/FilteringOneNavigation.kt | 4 ++-- .../feature/filtering/filteringthree/FilteringThreeRoute.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt index e80b3fbeb..d771d018f 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/navigation/FilteringOneNavigation.kt @@ -30,8 +30,8 @@ fun NavGraphBuilder.filteringOneNavGraph( FilteringOneRoute( paddingValues = paddingValues, name = args.name, - onNextClick = { grade -> navHostController.navigateFilteringTwo(grade) }, - navigateUp = { navHostController.navigateUp() } + onNextClick = navHostController::navigateFilteringTwo, + navigateUp = navHostController::navigateUp ) } } diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt index 8bdc9d4e0..09ef94e01 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringthree/FilteringThreeRoute.kt @@ -80,8 +80,8 @@ fun FilteringThreeRoute( chosenYear = Calendar.getInstance().currentYear, chosenMonth = Calendar.getInstance().currentMonth, onNextClick = viewModel::postFilteringWithServer, - onYearChosen = { viewModel.updateStartYear(it) }, - onMonthChosen = { viewModel.updateStartMonth(it) } + onYearChosen = viewModel::updateStartYear, + onMonthChosen = viewModel::updateStartMonth ) }