Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.getcode.navigation.results.NavResultStateRegistry
import com.getcode.navigation.results.navigateForResult
import com.getcode.navigation.results.resultBackNavigator
import com.getcode.navigation.scenes.LocalSheetNavigator
import com.getcode.ui.utils.rememberKeyboardController
import kotlinx.coroutines.flow.filterIsInstance

@Composable
Expand Down Expand Up @@ -67,6 +68,7 @@ private fun FlowConversationScreen(identifier: ChatIdentifier, openKeyboard: Boo
// inspects/mutates this navigator's own back stack), so it can't ride the type dispatcher and
// must target the sheet navigator explicitly.
val sheetNavigator = LocalSheetNavigator.current
val keyboard = rememberKeyboardController()

LaunchedEffect(viewModel, identifier) {
viewModel.dispatchEvent(ChatViewModel.Event.OnChatOpened(identifier))
Expand Down Expand Up @@ -100,16 +102,18 @@ private fun FlowConversationScreen(identifier: ChatIdentifier, openKeyboard: Boo
viewModel.eventFlow
.filterIsInstance<ChatViewModel.Event.OpenScreen>()
.collect { (route, asSheet) ->
if (asSheet) {
// Dismiss this chat sheet and open [route] as a fresh sheet. openAsSheet on the
// sheet-owning navigator animates the current sheet closed (via pendingSheetDismiss)
// before opening the new one.
sheetNavigator?.openAsSheet(route)
} else {
// A full AppRoute (never a ChatStep) -> the dispatcher bubbles it up the parent
// chain to the outer app nav host, the same destination as the old
// outerNavigator.navigate(route).
navigator.navigate(route)
keyboard.hideIfVisible {
if (asSheet) {
// Dismiss this chat sheet and open [route] as a fresh sheet. openAsSheet on the
// sheet-owning navigator animates the current sheet closed (via pendingSheetDismiss)
// before opening the new one.
sheetNavigator?.openAsSheet(route)
} else {
// A full AppRoute (never a ChatStep) -> the dispatcher bubbles it up the parent
// chain to the outer app nav host, the same destination as the old
// outerNavigator.navigate(route).
navigator.navigate(route)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ internal fun UserControlBottomBar(
state = state,
hazeState = hazeState,
hazeMaterial = material,
onClick = { dispatch(ChatViewModel.Event.OnSendCash) }
onClick = {
keyboard.hideIfVisible {
dispatch(ChatViewModel.Event.OnSendCash)
}
}
)

if (canType) {
Expand Down
Loading