diff --git a/feature/home/src/main/java/com/mashup/dorabangs/feature/home/HomeScreen.kt b/feature/home/src/main/java/com/mashup/dorabangs/feature/home/HomeScreen.kt index 20811a03..23dd0f67 100644 --- a/feature/home/src/main/java/com/mashup/dorabangs/feature/home/HomeScreen.kt +++ b/feature/home/src/main/java/com/mashup/dorabangs/feature/home/HomeScreen.kt @@ -51,7 +51,6 @@ import org.orbitmvi.orbit.compose.collectSideEffect @Composable fun HomeRoute( - isVisibleBottomSheet: Boolean, modifier: Modifier = Modifier, view: View = LocalView.current, clipboardManager: ClipboardManager = LocalClipboardManager.current, @@ -66,9 +65,7 @@ fun HomeRoute( val scope = rememberCoroutineScope() LaunchedEffect(key1 = Unit) { - if (isVisibleBottomSheet) { - viewModel.setVisibleMovingFolderBottomSheet(true) - } + viewModel.getIsVisibleMoreBottomSheet() } viewModel.collectSideEffect { sideEffect -> diff --git a/feature/home/src/main/java/com/mashup/dorabangs/feature/home/HomeViewModel.kt b/feature/home/src/main/java/com/mashup/dorabangs/feature/home/HomeViewModel.kt index c9b1da3a..e80ddb21 100644 --- a/feature/home/src/main/java/com/mashup/dorabangs/feature/home/HomeViewModel.kt +++ b/feature/home/src/main/java/com/mashup/dorabangs/feature/home/HomeViewModel.kt @@ -1,5 +1,6 @@ package com.mashup.dorabangs.feature.home +import android.util.Log import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -17,6 +18,7 @@ import org.orbitmvi.orbit.syntax.simple.postSideEffect import org.orbitmvi.orbit.syntax.simple.reduce import org.orbitmvi.orbit.viewmodel.container import javax.inject.Inject +import kotlin.math.log @HiltViewModel class HomeViewModel @Inject constructor( @@ -26,6 +28,13 @@ class HomeViewModel @Inject constructor( ) : ViewModel(), ContainerHost<HomeState, HomeSideEffect> { override val container = container<HomeState, HomeSideEffect>(HomeState()) + fun getIsVisibleMoreBottomSheet() { + savedStateHandle.get<Boolean>("isVisibleMovingBottomSheet")?.let { isVisible -> + Log.d("HomeViewModel", ": ${isVisible} ") + setVisibleMovingFolderBottomSheet(isVisible) + } + } + fun changeSelectedTapIdx(index: Int) = intent { reduce { state.copy(selectedIndex = index) diff --git a/feature/home/src/main/java/com/mashup/dorabangs/feature/navigation/HomeNavigation.kt b/feature/home/src/main/java/com/mashup/dorabangs/feature/navigation/HomeNavigation.kt index ac56b076..e3c0dc73 100644 --- a/feature/home/src/main/java/com/mashup/dorabangs/feature/navigation/HomeNavigation.kt +++ b/feature/home/src/main/java/com/mashup/dorabangs/feature/navigation/HomeNavigation.kt @@ -14,7 +14,7 @@ fun NavController.navigateToHome(navOptions: NavOptions? = null) = navigate(NavigationRoute.HomeScreen.route, navOptions) fun NavGraphBuilder.homeNavigation( - navigateToClassification: () -> Unit = {}, + navigateToClassification: () -> Unit, navigateToSaveScreenWithLink: (String) -> Unit, navigateToSaveScreenWithoutLink: () -> Unit, navigateToCreateFolder: () -> Unit, @@ -27,14 +27,8 @@ fun NavGraphBuilder.homeNavigation( defaultValue = false }, ), - ) { backStackEntry -> - - val isVisibleBottomSheet = backStackEntry.savedStateHandle.getStateFlow( - "isVisibleMovingBottomSheet", - initialValue = false, - ).collectAsState().value + ) { HomeRoute( - isVisibleBottomSheet = isVisibleBottomSheet, navigateToClassification = navigateToClassification, navigateToSaveScreenWithLink = navigateToSaveScreenWithLink, navigateToSaveScreenWithoutLink = navigateToSaveScreenWithoutLink,