From f523af8d541f84c3449bb9939525018d68af6fff Mon Sep 17 00:00:00 2001 From: Aleksey Zamulla Date: Mon, 15 Dec 2025 18:43:07 +0100 Subject: [PATCH 1/7] update: PredictiveBackHandler section; renamed the parent section into "Breaking changes and deprecations" to not confuse the two --- topics/whats-new/whats-new-compose-110.md | 34 ++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/topics/whats-new/whats-new-compose-110.md b/topics/whats-new/whats-new-compose-110.md index a7e4f5cc..fb66f228 100644 --- a/topics/whats-new/whats-new-compose-110.md +++ b/topics/whats-new/whats-new-compose-110.md @@ -29,7 +29,7 @@ You can find the full list of changes for this release on [GitHub](https://githu * Savedstate library `org.jetbrains.androidx.savedstate:savedstate*:1.4.0`. Based on [Jetpack Savedstate 1.4.0](https://developer.android.com/jetpack/androidx/releases/savedstate#1.4.0) * WindowManager Core library `org.jetbrains.androidx.window:window-core:1.5.1`. Based on [Jetpack WindowManager 1.5.1](https://developer.android.com/jetpack/androidx/releases/window#1.5.1) -## Breaking changes +## Breaking changes and deprecations ### Deprecated dependency aliases @@ -41,6 +41,38 @@ Specific references are suggested in the corresponding deprecation notices. This change should make dependency management for Compose Multiplatform libraries a bit more transparent. In the future, we hope to provide a BOM for Compose Multiplatform to simplify setting up compatible versions. +### Deprecated `PredictiveBackHandler()` + +The `PredictiveBackHandler()` function was introduced in Compose Multiplatform to bring native Android back navigation +gesture to other platforms. +With the release of Navigation 3 the old implementation was made obsolete with the new `NavigationEvent` class and APIs +built around it. +Specifically, instead of the `PredictiveBackHandler()` function there is a new `NavigationBackHandler()` that wraps +the general `NavigationEventHandler()` function for cases when forward navigation is not relevant. + +The simplest migration can look like this: + + + + PredictiveBackHandler() { /* handle everything about the back gesture */ } + + + NavigationBackHandler( + state = NavigationEventInfo.None, + onBackCancelled = { /* handle a cancelled back gesture */ }, + ) { /* handle a completed back gesture */ } + + + +Here: + +* The `state` parameter is mandatory: `NavigationEventInfo` is designed to hold contextual information about the UI state. + But if you don't have any information to store for now, you can use `NavigationEventInfo.None` as a stub. +* The `onBack` parameter is broken up into `onBackCancelled` and `onBackCompleted` so you don't need to track canceled + gestures separately. + +For details on the general function, see the [NavigationEventHandler KDoc](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigationevent/navigationevent-compose/src/commonMain/kotlin/androidx/navigationevent/compose/NavigationEventHandler.kt;l=28;drc=fba1459ebd11b27fbfb12ed1925e8f87b32e1594). + ### Minimum Kotlin version increased for web If your project includes a web target, the latest features require upgrading to Kotlin 2.2.20. From e1cd9ce79ddaa460f46409db8900ea861b70da57 Mon Sep 17 00:00:00 2001 From: Aleksey Zamulla Date: Mon, 15 Dec 2025 19:27:20 +0100 Subject: [PATCH 2/7] update: better code for migration --- topics/whats-new/whats-new-compose-110.md | 35 +++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/topics/whats-new/whats-new-compose-110.md b/topics/whats-new/whats-new-compose-110.md index fb66f228..0033aa3f 100644 --- a/topics/whats-new/whats-new-compose-110.md +++ b/topics/whats-new/whats-new-compose-110.md @@ -48,19 +48,42 @@ gesture to other platforms. With the release of Navigation 3 the old implementation was made obsolete with the new `NavigationEvent` class and APIs built around it. Specifically, instead of the `PredictiveBackHandler()` function there is a new `NavigationBackHandler()` that wraps -the general `NavigationEventHandler()` function for cases when forward navigation is not relevant. +the general `NavigationEventHandler()` function. The simplest migration can look like this: - PredictiveBackHandler() { /* handle everything about the back gesture */ } + PredictiveBackHandler(enabled = true) { progress -> + try { + progress.collect { event -> + // Animate the back gesture progress + } + // Process the completed back gesture + } catch(e: Exception) { + // Process the canceled back gesture + } + } - NavigationBackHandler( - state = NavigationEventInfo.None, - onBackCancelled = { /* handle a cancelled back gesture */ }, - ) { /* handle a completed back gesture */ } + val navState = rememberNavigationEventState(NavigationEventInfo.None) + NavigationBackHandler( + state = navState, + isBackEnabled = true, + onBackCancelled = { + // Process the canceled back gesture + }, + onBackCompleted = { + // Process the completed back gesture + } + ) + LaunchedEffect(navState.transitionState) { + val transitionState = navState.transitionState + if (transitionState is NavigationEventTransitionState.InProgress) { + val progress = transitionState.latestEvent.progress + // Animate the back gesture progress + } + } From 8dd33c0c44577d419d5513081bf541b36ad342b4 Mon Sep 17 00:00:00 2001 From: Aleksey Zamulla Date: Mon, 15 Dec 2025 19:32:50 +0100 Subject: [PATCH 3/7] update: better code for migration --- topics/whats-new/whats-new-compose-110.md | 1 + 1 file changed, 1 insertion(+) diff --git a/topics/whats-new/whats-new-compose-110.md b/topics/whats-new/whats-new-compose-110.md index 0033aa3f..bfafec3c 100644 --- a/topics/whats-new/whats-new-compose-110.md +++ b/topics/whats-new/whats-new-compose-110.md @@ -93,6 +93,7 @@ Here: But if you don't have any information to store for now, you can use `NavigationEventInfo.None` as a stub. * The `onBack` parameter is broken up into `onBackCancelled` and `onBackCompleted` so you don't need to track canceled gestures separately. +* The `NavigationEventState.transitionState` property helps to track the progress of the physical gesture. For details on the general function, see the [NavigationEventHandler KDoc](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigationevent/navigationevent-compose/src/commonMain/kotlin/androidx/navigationevent/compose/NavigationEventHandler.kt;l=28;drc=fba1459ebd11b27fbfb12ed1925e8f87b32e1594). From 887fe113298a3b66ba1f2dcfe2479f46ee04d46f Mon Sep 17 00:00:00 2001 From: Aleksey Zamulla Date: Tue, 16 Dec 2025 14:11:52 +0100 Subject: [PATCH 4/7] fix: compare block --- topics/whats-new/whats-new-compose-110.md | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/topics/whats-new/whats-new-compose-110.md b/topics/whats-new/whats-new-compose-110.md index bfafec3c..e16a4002 100644 --- a/topics/whats-new/whats-new-compose-110.md +++ b/topics/whats-new/whats-new-compose-110.md @@ -54,36 +54,36 @@ The simplest migration can look like this: - PredictiveBackHandler(enabled = true) { progress -> - try { - progress.collect { event -> - // Animate the back gesture progress + PredictiveBackHandler(enabled = true) { progress -> + try { + progress.collect { event -> + // Animate the back gesture progress + } + // Process the completed back gesture + } catch(e: Exception) { + // Process the canceled back gesture } - // Process the completed back gesture - } catch(e: Exception) { - // Process the canceled back gesture } - } - val navState = rememberNavigationEventState(NavigationEventInfo.None) - NavigationBackHandler( - state = navState, - isBackEnabled = true, - onBackCancelled = { - // Process the canceled back gesture - }, - onBackCompleted = { - // Process the completed back gesture - } - ) - LaunchedEffect(navState.transitionState) { - val transitionState = navState.transitionState - if (transitionState is NavigationEventTransitionState.InProgress) { - val progress = transitionState.latestEvent.progress - // Animate the back gesture progress + val navState = rememberNavigationEventState(NavigationEventInfo.None) + NavigationBackHandler( + state = navState, + isBackEnabled = true, + onBackCancelled = { + // Process the canceled back gesture + }, + onBackCompleted = { + // Process the completed back gesture + } + ) + LaunchedEffect(navState.transitionState) { + val transitionState = navState.transitionState + if (transitionState is NavigationEventTransitionState.InProgress) { + val progress = transitionState.latestEvent.progress + // Animate the back gesture progress + } } - } From 594027b121eb3a58f08b526a4fed690558243846 Mon Sep 17 00:00:00 2001 From: Aleksey Zamulla Date: Tue, 16 Dec 2025 14:29:29 +0100 Subject: [PATCH 5/7] update: comment the None --- topics/whats-new/whats-new-compose-110.md | 1 + 1 file changed, 1 insertion(+) diff --git a/topics/whats-new/whats-new-compose-110.md b/topics/whats-new/whats-new-compose-110.md index e16a4002..c3d27dc1 100644 --- a/topics/whats-new/whats-new-compose-110.md +++ b/topics/whats-new/whats-new-compose-110.md @@ -66,6 +66,7 @@ The simplest migration can look like this: } + // Use an empty state as a stub to satisfy the required argument val navState = rememberNavigationEventState(NavigationEventInfo.None) NavigationBackHandler( state = navState, From 623c0d7c4b1cf0311952ff8117225cdff0535d0d Mon Sep 17 00:00:00 2001 From: Aleksey Zamulla Date: Tue, 16 Dec 2025 15:23:45 +0100 Subject: [PATCH 6/7] fix: better reference for Navigation Event --- topics/whats-new/whats-new-compose-110.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/topics/whats-new/whats-new-compose-110.md b/topics/whats-new/whats-new-compose-110.md index c3d27dc1..11467338 100644 --- a/topics/whats-new/whats-new-compose-110.md +++ b/topics/whats-new/whats-new-compose-110.md @@ -45,10 +45,10 @@ In the future, we hope to provide a BOM for Compose Multiplatform to simplify se The `PredictiveBackHandler()` function was introduced in Compose Multiplatform to bring native Android back navigation gesture to other platforms. -With the release of Navigation 3 the old implementation was made obsolete with the new `NavigationEvent` class and APIs -built around it. -Specifically, instead of the `PredictiveBackHandler()` function there is a new `NavigationBackHandler()` that wraps -the general `NavigationEventHandler()` function. +With the release of Navigation 3 the old implementation was made obsolete with the new [Navigation Event](https://developer.android.com/jetpack/androidx/releases/navigationevent) +library and its APIs. +Specifically, instead of the `PredictiveBackHandler()` function there is a new `NavigationBackHandler()` function that wraps +the more general `NavigationEventHandler()` implementation. The simplest migration can look like this: From fbd3bcee69223240f88e823d862ad920a95f177f Mon Sep 17 00:00:00 2001 From: Aleksey Zamulla Date: Tue, 16 Dec 2025 15:26:37 +0100 Subject: [PATCH 7/7] fix: better reference for Navigation Event docs --- topics/whats-new/whats-new-compose-110.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topics/whats-new/whats-new-compose-110.md b/topics/whats-new/whats-new-compose-110.md index 11467338..c44785bc 100644 --- a/topics/whats-new/whats-new-compose-110.md +++ b/topics/whats-new/whats-new-compose-110.md @@ -96,7 +96,7 @@ Here: gestures separately. * The `NavigationEventState.transitionState` property helps to track the progress of the physical gesture. -For details on the general function, see the [NavigationEventHandler KDoc](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigationevent/navigationevent-compose/src/commonMain/kotlin/androidx/navigationevent/compose/NavigationEventHandler.kt;l=28;drc=fba1459ebd11b27fbfb12ed1925e8f87b32e1594). +For details on the implementation, see the [NavigationEventHandler page in the Navigation Event API reference](https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventHandler). ### Minimum Kotlin version increased for web