Skip to content

Commit

Permalink
[fix] savestatehandler로 값 받기 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ddyeon committed Jul 9, 2024
1 parent c749480 commit 2e35cb8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -66,9 +65,7 @@ fun HomeRoute(
val scope = rememberCoroutineScope()

LaunchedEffect(key1 = Unit) {
if (isVisibleBottomSheet) {
viewModel.setVisibleMovingFolderBottomSheet(true)
}
viewModel.getIsVisibleMoreBottomSheet()
}

viewModel.collectSideEffect { sideEffect ->
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 2e35cb8

Please sign in to comment.