This message was deleted.
# multiplatform
s
This message was deleted.
s
Okay sure.
r
1. Please add this on
libs.versions.toml
Copy code
navigationevent = "1.1.0-alpha01"
androidx-navigationevent = { module = "androidx.navigationevent:navigationevent", version.ref = "navigationevent" }
2. implement on
build.gradle.kts
Copy code
androidMain.dependencies { 
 implementation(libs.androidx.navigationevent)
}
3. in
commonMain
Copy code
@Composable
expect fun BackPressHandler(
    onBackPressed: () -> Unit,
    enabled: Boolean = true
)
4. in Android
Copy code
@Composable
actual fun BackPressHandler(
    onBackPressed: () -> Unit,
    enabled: Boolean
) {
    val navEventState = rememberNavigationEventState(
        currentInfo = NavigationEventInfo.None
    )
    NavigationBackHandler(
        state = navEventState,
        isBackEnabled = enabled,
        onBackCompleted = onBackPressed
    )
}
5. ios
Copy code
@OptIn(ExperimentalComposeUiApi::class)
@Suppress("DEPRECATION")
@Composable
actual fun BackPressHandler(
    onBackPressed: () -> Unit,
    enabled: Boolean
) {

    BackHandler(
        enabled = enabled,
        onBack = onBackPressed
    )
}
🚫 2
e
navigation-event library is CMP ready, you should not need expect actual to be able to use it.
r
Which version?
r
But i'm facing the problem in this version
e
iosX64
is a tier 3 KMP target so thats probably why its not supported by nav events lib. If that target is required for your use case however, then yes, you need to do it the way you described.
r
oh, ok thanks 😉