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

Create key-navigation module with back handling support #883

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ashdavies
Copy link
Contributor

@ashdavies ashdavies commented Sep 18, 2023

In order to provide back handling support for desktop, a key listener must be applied to the composition via Modifier.onPreviewKeyEvent. Previous attempts were to hook into the composition hierarchy, utilising expect/actual.

However, it is possible to use the same functionality from the recently introduced gesture navigation module. The NavDecorator implementation delegates to NavigatorDefaults.DefaultDecoration, whilst decorating content with the required modifier.

This then makes the sample implementation redundant, thus it is removed.

Copy link
Collaborator

@ZacSweers ZacSweers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delays on this. I think this makes sense, but what do you think about putting this just in the foundation artifact as a helper? CC @stagg @kierse for second opinions. A separate artifact entirely seems unnecessary for this case I think

@stagg
Copy link
Collaborator

stagg commented Nov 26, 2023

Sorry for the delays on this. I think this makes sense, but what do you think about putting this just in the foundation artifact as a helper? CC @stagg @kierse for second opinions. A separate artifact entirely seems unnecessary for this case I think

Ya, think having this in foundation makes the most sense for all desktop uses. Would be nice if we did't have to rely on it being in a NavDecoration, seeing how we can't nest them. Might even be useful for all platforms 🤔

@ZacSweers
Copy link
Collaborator

Yeah we can revise later, this seems a good start. @ashdavies can merge once you move to foundation!

@ashdavies
Copy link
Contributor Author

Thanks folks, yeah I think the NavDecoration would be useful if it were nestable, it'd be nice just to decorate the default decoration. I want to verify some compatibility with an issue I found in my playground, I'll move it to foundation after that 🎉

@ashdavies
Copy link
Contributor Author

Managed to verify the bug in my playground was unrelated, I'll update this PR now.

@ashdavies
Copy link
Contributor Author

Task :circuit-foundation:compileKotlinIosSimulatorArm64 FAILED

e: Compilation failed: No container found for type parameter 'T' of 'FUN IR_EXTERNAL_DECLARATION_STUB name:DecoratedContent visibility:public modality:ABSTRACT ($this:com.slack.circuit.backstack.NavDecoration, args:kotlinx.collections.immutable.ImmutableList, backStackDepth:kotlin.Int, modifier:androidx.compose.ui.Modifier, content:kotlin.Function3<T of com.slack.circuit.backstack.NavDecoration.DecoratedContent, androidx.compose.runtime.Composer, kotlin.Int, kotlin.Unit>, $composer:androidx.compose.runtime.Composer?, $changed:kotlin.Int) returnType:kotlin.Unit'

I don't recognise this error, any clues from folks more familiar with iOS?

@ZacSweers
Copy link
Collaborator

No idea, that looks like a bug for the compose issue tracker :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants