Tin Tran
07/28/2022, 4:34 AMModalBottomSheetStateoianmol
07/28/2022, 5:14 AMTin Tran
07/28/2022, 6:06 AMLaunchedEffect(key1 = state.showBottomSheet) {
        if (state.showBottomSheet) {
            bottomSheetState.animateTo(ModalBottomSheetValue.Expanded)
        } else {
            bottomSheetState.animateTo(ModalBottomSheetValue.Hidden)
        }
    }val bottomSheetState = rememberModalBottomSheetState(
        initialValue = ModalBottomSheetValue.Hidden,
        confirmStateChange = {
            if (!state.bottomSheetCancelable) {
                return@rememberModalBottomSheetState false
            }
            if (it == ModalBottomSheetValue.Hidden) {
                Timber.d("test test test")
                keyboardController?.hide()
                viewModel.reduce(LoginEvent.HideBottomSheet)
            }
            true
        }
    )Albert Chang
07/28/2022, 10:22 AMModalBottomSheetStateoianmol
07/28/2022, 10:39 AMAlbert Chang
07/28/2022, 10:51 AMthe bottomSheetState which is also a composableNo,
ModalBottomSheetStateIf in future you would want to move away from Bottom sheet’s you would end up refactoring viewModelsWhat’s the problem of refactoring view models? Do you design your view model so that any future UI change doesn’t need any modification of view model? Is that possible anyway? Creating this kind of unnecessary restriction for yourself only makes your code more verbose and more complicated. We usually call this over-engineering.
oianmol
07/28/2022, 10:54 AMAlbert Chang
07/28/2022, 10:56 AMModalBottomSheetStaterememberModalBottomSheetState()oianmol
07/28/2022, 11:02 AMModalBottomSheetStateoianmol
07/28/2022, 11:05 AMModalBottomSheetStateAlbert Chang
07/28/2022, 11:06 AMModalBottomSheetStateoianmol
07/28/2022, 11:08 AMrememberModalBottomSheetState()oianmol
07/28/2022, 11:09 AMAlbert Chang
07/28/2022, 11:11 AMModalBottomSheetStateoianmol
07/28/2022, 11:40 AMModalBottomSheetStateexpandhidefengdai
07/28/2022, 1:06 PMfengdai
07/28/2022, 1:15 PMSimple state hoisting can be managed in the composable functions itself. However, if the amount of state to keep track of increases, or the logic to perform in composable functions arises, it’s a good practice to delegate the logic and state responsibilities to other classes: state holders.&
a ViewModel is a special type of state holder
Colton Idle
07/29/2022, 4:14 AMjossiwolf
07/29/2022, 9:01 AMrememberModalBottomSheetStateTin Tran
07/29/2022, 9:37 AMManuel Vivo
08/01/2022, 9:10 AMrememberMBSSSavedStateHandle