Provide NavigationEventDispatcherOwner for non-android targets#2382
Provide NavigationEventDispatcherOwner for non-android targets#2382
Conversation
95ae7db to
44ccf02
Compare
.../uikitMain/kotlin/androidx/compose/ui/navigationevent/UIKitNavigationEventDispatcherOwner.kt
Outdated
Show resolved
Hide resolved
...src/uikitMain/kotlin/androidx/compose/ui/uikit/ComposeUIViewControllerConfiguration.uikit.kt
Show resolved
Hide resolved
44ccf02 to
2d53b0c
Compare
.../ui/ui/src/uikitMain/kotlin/androidx/compose/ui/navigationevent/UIKitNavigationEventInput.kt
Outdated
Show resolved
Hide resolved
|
checked iOS layers with a dialog and a popup. works like a charm nave.mp4 |
…ollerConfiguration`
…lStore and NavigationEventDispatcher owners. And instead of a new NavigationEventDispatcher in the UIKitComposeSceneLayer, a new UIKitNavigationEventInput is used
…to the skiko only source set.
…ationEvent` and `NavigationEventHandler`. Remove unused dependencies and dump API.
8e1a2f4 to
d7523b3
Compare
MatkovIvan
left a comment
There was a problem hiding this comment.
Revert experimental annotations. Removing it means stabilization that we do not want to
...ui-backhandler/src/androidMain/kotlin/androidx/compose/ui/backhandler/BackHandler.android.kt
Show resolved
Hide resolved
MatkovIvan
left a comment
There was a problem hiding this comment.
LGTM in general, but let's add proper metadata in depracation annotations to help with migration
| import androidx.compose.ui.ExperimentalComposeUiApi | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| @Deprecated("Use NavigationEventHandler instead") |
There was a problem hiding this comment.
| @Deprecated("Use NavigationEventHandler instead") | |
| @Deprecated( | |
| message = "Use a {@link androidx.navigationevent.compose.NavigationEventHandler} instead", | |
| replaceWith = ReplaceWith( | |
| expression = "NavigationEventHandler(enabled, onBack)", | |
| imports = arrayOf("androidx.navigationevent.compose.NavigationEventHandler"), | |
| ), | |
| level = DeprecationLevel.WARNING, // TODO: Replace to ERROR in 1.11 | |
| ) |
There was a problem hiding this comment.
KTIJ-35595 ReplaceWith works wrong with expect/actual and default arguments
| import androidx.navigationevent.NavigationEventDispatcherOwner | ||
|
|
||
| internal class IOSLifecycleOwner: LifecycleOwner, ViewModelStoreOwner { | ||
| internal class UIKitArchitectureComponentsOwner : |
There was a problem hiding this comment.
I'm not happy with the idea to put everything in a single class by the criteria that they are Owners interfaces.
Also, ViewModelStore placed here incorrectly. ViewModelStoreOwner and NavigationEventDispatcher should be implemented by the separate instances - either that can be separate classes or anonymous object.
It's up to you - you can do it in the current MR, or I'll fix it by myself later.
There was a problem hiding this comment.
Since I've already refactored this part of the code let's give it to you. ok? I have no strict preferences here but it seems logical though because on other platforms we have these interfaces in a single place
| content = content | ||
| ) | ||
| ) { | ||
| val navigationEventDispatcherOwner = LocalInternalNavigationEventDispatcherOwner.current |
There was a problem hiding this comment.
Two different approaches where used in ComposeHostingViewController and here. Either this code should be used in ComposeSceneMediator once or it's looks like the optimal solution will be to:
- make the
navigationEventInputinternal - Add input at the place where
UIKitComposeSceneLayeris created - use
onClosecallback to remove input
| density = rootView.density, | ||
| getTopLeftOffsetInWindow = { IntOffset.Zero } //full screen | ||
| ) | ||
| ).also { eventInput -> archComponentsOwner.navigationEventDispatcher.addInput(eventInput) } |
There was a problem hiding this comment.
The eventInput added here never removes. It should not be a big issue since navigationEventDispatcher and eventInput have the same lifetime, but it would be better to add event input in the viewControllerDidEnterWindowHierarchy and remove in viewControllerDidLeaveWindowHierarchy
| api(project(":compose:ui:ui-text")) | ||
| api(libs.skikoCommon) | ||
| implementation(libs.atomicFu) | ||
| implementation(project(":compose:ui:ui-backhandler")) |
There was a problem hiding this comment.
creating a stub project for backhandler
the project is still here and contains valid code. What's required is only restoring this dependency
There was a problem hiding this comment.
* What went wrong:
Circular dependency between the following tasks:
:navigationevent:navigationevent-compose:compileDesktopMainJava
+--- :navigationevent:navigationevent-compose:compileKotlinDesktop
| \--- :compose:ui:ui:desktopJar
| +--- :compose:ui:ui:compileDesktopMainJava
| | +--- :compose:ui:ui:compileKotlinDesktop
| | | \--- :compose:ui:ui-backhandler:desktopJar
| | | +--- :compose:ui:ui-backhandler:compileDesktopMainJava
| | | | +--- :navigationevent:navigationevent-compose:desktopJar
There was a problem hiding this comment.
I'll try to use a non-compose library then
Suppot the
NavigationEventDispatcherOwnerfor a correct Navigation3 support on non-android targets.Fixes CMP-7646 Support Navigation 3 for Compose Multiplatform
Testing
Manually checked the demo app
Release Notes
Highlights - Navigation
NavigationEventDispatcherOwnerfor a correct Navigation3 support.