HomeiOS Developmentkotlin - BackHandler Compose Multiplatform not engaged on iOS

kotlin – BackHandler Compose Multiplatform not engaged on iOS


I’ve kmm app with 1.8.0 compose-multiplatform and I’ve added

ui-backhandler = { module = "org.jetbrains.compose.ui:ui-backhandler", model.ref = "compose-multiplatform" }

Code pattern:

@Composable
@Preview
enjoyable App(
    navController: NavHostController = rememberNavController(),
) {
    ...
    KoinContext {
        MyTheme {
            Scaffold() { innerPadding ->
                NavHost(
                    navController = navController,
                    startDestination = Display screen.Dashboard.identify
                ) {
                    composable(route = Display screen.MyGroups.identify) {
                        GroupsScreen(
                            navigateUp = {
                                navController.navigateUp()
                            }
                        )
                    }

@OptIn(ExperimentalComposeUiApi::class)
@Composable
enjoyable GroupsScreen(
    navigateUp: () -> Unit
) {
    BackHandler(enabled = true) {
        navigateUp()
    }
    ...
}

iosMain:

enjoyable MainViewController() = ComposeUIViewController { App() }

on iOS facet:

struct ComposeView: UIViewControllerRepresentable {
    func makeUIViewController(context: Context) -> UIViewController {
        MainViewControllerKt.MainViewController()
    }
    func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}

struct ContentView: View {
    var physique: some View {
        ComposeView()
                .ignoresSafeArea(edges: .all)
                .ignoresSafeArea(.keyboard)
    }
}

If I am not mistaken, this must be sufficient for BackHandler to work, nevertheless it would not work on iOS: the “again” gesture from the left edge doesn’t shut the display screen.

Moreover: The place can I discover an instance of utilizing BackHandler on iOS? I am unable to discover a single instance within the official repository, and I am unable to even attempt to add it to the initiatives within the “Examples” folder, as a result of they’re both outdated or have just one display screen

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments