I try to implement my toast stack from my React-Native app in Jetpack Compose.
MainActivity:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val toastStack = ToastStack()
setContent {
MainContent(toastStack) // Here we have logic that pushes a toast into our stack
ToastStack(toastStack) // Here we show toasts
}
}
}
ToastStack:
@Composable
fun ToastStack(toastStack: ToastStack) {
val stack by toastViewModel.stack.observeAsState(listOf())
LazyColumn(
verticalArrangement = Arrangement.Bottom,
userScrollEnabled = false,
modifier = Modifier
.fillMaxSize(),
) {
items(stack, key = { it.id }) { toast ->
Toast(
toast = toast,
onToastEnd = { toastStack.removeToast(toast.id) }
)
}
}
}
The problem is that LazyColumn have the size of the screen and it blocks all touch events for the MainContent. In React-Native I used pointerEvents="box-none"
to make the view that contains toasts ignore all touch events. Is there any way I can do the same in Jetpack Compose?