james
02/12/2022, 12:16 AMTextField
once my ModalBottomSheet
is shown, is using the `ModalBottomSheetState`'s confirmStateChange
the correct place to do that, or is there a better place? I understand it can work but it doesn't necessarily feel right.. is there a listener I can use which signals "the modal bottom sheet has finished appearing"?Colton Idle
02/12/2022, 6:10 AMColton Idle
02/12/2022, 4:43 PMjossiwolf
02/14/2022, 8:53 AMsnapshotFlow
, you can create a Flow that emits whenever the state's value changes and then request focus.
You wouldn't want to use confirmStateChange
because this is called when ModalBottomSheetState
decides which state (if any) to move to, so you'd be requesting focus too early.
We use snapshotFlow
in Accompanist to get updates for when the sheet is visible: https://github.com/google/accompanist/blob/main/navigation-material/src/main/java/com/google/accompanist/navigation/material/SheetContentHost.kt#L83jossiwolf
02/14/2022, 8:54 AMColton Idle
02/14/2022, 12:10 PMjossiwolf
02/14/2022, 5:00 PMModalBottomSheetLayout
, the Accompanist one is on my mind🙂 (I imagine the underlying cause might be similar though)Colton Idle
02/14/2022, 5:42 PM