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

BackHandler Composable #324

Closed
swankjesse opened this issue Aug 25, 2022 · 6 comments · Fixed by #1489
Closed

BackHandler Composable #324

swankjesse opened this issue Aug 25, 2022 · 6 comments · Fixed by #1489
Assignees

Comments

@swankjesse
Copy link
Collaborator

Lets hook up something like Compose UI’s BackHandler.

@Composable
fun BackHandler(enabled: Boolean = true, onBack: () -> Unit) {
}
@JakeWharton
Copy link
Collaborator

I'm not sure we can do this at either level of abstraction we provide. Definitely not Redwood but even with Treehouse it seems like a stretch. We know nothing about screens, navigation, or, in the case of Android, the platform back-handling third-party library you need to use.

@swankjesse
Copy link
Collaborator Author

Good call. Probably this goes in the Cash layer on top.

@JakeWharton
Copy link
Collaborator

We may be able to pull it off in Treehouse at some point, but yeah the question is whether we want to impose the necessary bits to wire this up. Maybe a sample to show how it's wired?

@swankjesse
Copy link
Collaborator Author

interface FrameContext : ZiplineService {
  var backHandler: BackHandler?
}

interface BackHandler : ZiplineService {
  fun onBack()
}

@JakeWharton
Copy link
Collaborator

In Compose:

BackHandler(true /* or state derived */) {
  // must handle
}

@JakeWharton
Copy link
Collaborator

JakeWharton commented Aug 16, 2023

I've since come around to this being supported at the Redwood layer because it relies on things like #1116 which previously did not exist as a concept.

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

Successfully merging a pull request may close this issue.

3 participants