Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UIKit] API for navigation between Compose screens #3046

Open
alexzhirkevich opened this issue Apr 12, 2023 · 13 comments
Open

[UIKit] API for navigation between Compose screens #3046

alexzhirkevich opened this issue Apr 12, 2023 · 13 comments
Assignees
Labels
enhancement New feature or request ios

Comments

@alexzhirkevich
Copy link
Contributor

alexzhirkevich commented Apr 12, 2023

Short description:
Provide API for native like(or really native) navigation between Compose screens on iOS with native gestures.

Previous title:
[UIKit] Unclear behaviour of nested UIViewControllers lifecycle

[Fixed together with memory leak fix]

I try to implement something like native uikit navigation for compose using UINavigationController and UiKitView. And i faced the moment when i need to be notified when controller is popped.
I cannot override viewDidDissapear of UIViewController cause ComposeWindow is internal, so i tried to use DisposableEffect for that. But when ComposeWindow pops from UINavigationController, DisposableEffect inside composable block does never execute onDispose.

@alexzhirkevich alexzhirkevich added bug Something isn't working submitted labels Apr 12, 2023
@dima-avdeev-jb dima-avdeev-jb self-assigned this Apr 12, 2023
@dima-avdeev-jb dima-avdeev-jb added ios enhancement New feature or request and removed submitted bug Something isn't working labels Apr 12, 2023
@dima-avdeev-jb
Copy link
Contributor

dima-avdeev-jb commented Apr 12, 2023

Thanks!
Your current goal is to have native iOS navigation with UINavigationController?
Do you want to navigate betwee UIKit and Compose screens, or just navigate between different Compose screens?

I think it's completed to use this code:

 UIKitView(
        modifier = Modifier.fillMaxSize(),
        factory = {
            navController.view
        }
    )

This UIKitView looks redundant.

Maybe we can provide a better API for navigation between Compose screens and between UIKit screen and Compose.

@alexzhirkevich
Copy link
Contributor Author

alexzhirkevich commented Apr 12, 2023

I want to navigate between different compose screens in a native way with swipe gestures and so on. It works and looks perfect btw, but i also want to be notified, when controller is popped from the screen.

@dima-avdeev-jb
Copy link
Contributor

Ok, thanks!
For now we have different goals for better performance and fixing other bugs in Compose, but this issue is important as well.
We will provide the needful API in the future.

@dima-avdeev-jb dima-avdeev-jb changed the title [UIKit] Unclear behaviour of nested UIViewControllers lifecycle [UIKit] API for navigation between Compose screens Apr 12, 2023
@alexzhirkevich
Copy link
Contributor Author

Just a little example of what can be done for now with UINavigationController. It is awesome, isn't it?

Untitled-2.mp4

@dima-avdeev-jb
Copy link
Contributor

Cool!

@matteocrippa
Copy link

@alexzhirkevich the plan is to release it as PR in Precompose lib?

@alexzhirkevich
Copy link
Contributor Author

alexzhirkevich commented Apr 24, 2023

@matteocrippa

Multiplatform swipe back navigation was already added to precompose (Tlaster/PreCompose#35). Looks almost the same as native. True native have some limitations and bugs now.

@lukwol
Copy link

lukwol commented Apr 28, 2023

I'm currently experimenting with a way to abstract navigation for all Compose targets in my project.
Right now navigation on iOS or Desktop looks the same as on Android - screens are changed with crossfade animation.
For now there is no back gesture on iOS (like on Android) but I might consider adding one.

@alexzhirkevich
Copy link
Contributor Author

Original issue is related to #3201

@arkivanov
Copy link
Contributor

Just FYI, Decompose supports the predictive back gesture on all platforms. There is one known bug which I will fix soon, though.
https://arkivanov.github.io/Decompose/extensions/compose/#predictive-back-gesture

Plus, there are feature requests to make it better customizable, so it could look closer to the native variant.

@AhmedMourad0
Copy link

Any updates on this? As awesome as the community libraries addressing this are, I think Compose Multiplatform needs first party navigation and resource management solutions as those are parts of the app that can't be migrated easily if a library gets abandoned or isn't quick enough to fix critical bugs or update to newer kotlin/compose releases.

@dima-avdeev-jb
Copy link
Contributor

@AhmedMourad0 Thanks! Yeah - you are right!
We have resources library and want to enhance it. Code samples https://github.com/JetBrains/compose-multiplatform/blob/master/components/resources/demo/shared/src/commonMain/kotlin/org/jetbrains/compose/resources/demo/shared/UseResources.kt

Also we are looking at navigation as well! For now we are investigating different approaches and trying to find the best direction!

@lukwol
Copy link

lukwol commented Oct 6, 2023

Great news. I'm looking forward to first party solutions for navigation and resource management.
In the meantime I've updated my navigation library to benefit from custom transitions and finally published it on Maven Central.
As for the string resources on mobile, Android XMLs and iOS Strings Catalog, hidden behind common API works fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ios
Projects
None yet
Development

No branches or pull requests

6 participants