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

Fixed Back Navigation Issues + Misc Updates #12

Merged
merged 5 commits into from
Jul 28, 2023
Merged

Conversation

chRyNaN
Copy link
Owner

@chRyNaN chRyNaN commented Jul 28, 2023

What Changed

  • Fixed back navigation issues
  • Changed the Navigation API
  • Added binary compatibility plugin
  • Updated Compose Multiplatform to version 1.5.0-beta01
  • Updated Kotlinx Coroutines to version 1.7.3
  • Added more native targets for the navigation-core module

Back Navigation Issue

Previously, the Navigator would retain a stack of forward NavigationEvents (context and destination changes). It would use that stack for back navigation purposes. There was a Backwards Navigation Strategy which would be used to determine how the back navigation worked. However, this wouldn't work when IN_CONTEXT navigation was set and the previous navigation event was a context change. This should have popped the destination stack to the previous item within the current context in that case, but instead it just did nothing and returned false.

The coordination of context and destination changes is rather difficult and was causing a lot of issues. So, the solution I came up with was to separate the back navigation into two distinct operations (similar to the forward navigation events): back context and back destination change. This simplifies the Navigator implementation with the coordination of the back operations. However, this requires the call-site to explicitly state which back navigation operation they would like to perform. Along with this fix, I decided to change the API so that the navigation functions were easier to work with.

API Changes

Fixing the back navigation issues introduced a new back operation. This change required renaming the goBack function and introducing another "goBack" function but for context changes. As these are essentially stack operations, I decided to rename the functions along the lines with expected stack functions, and change the forward navigation function names as well. The following chart breaks down the changes:

Old Name New Name
goTo push(destination)
changeContext push(context)
goBack popDestination
goBack popContext

There still exists goTo and changeContext functions, but those are deprecated. This is done to ease the transition to the new API.

Also, the Kotlin Binary Compatibility Plugin was added so that it is known when future breaking changes occur and makes it easier to limit any breaking changes. This will be helpful as this API becomes more stable and reaches a 1.0.0 release.

Release

This should be released shortly after this PR is merged so that the changes can be tested in applications, and because I have a project that depends on this library which is where I encountered the back navigation issue.

@chRyNaN chRyNaN merged commit eb0c10a into develop Jul 28, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant