Comments (2)
It seems that this sort of pattern already exists, but is unfortunately marked as internal. See here
Also to anyone else trying to use the above code, make sure to have the kotlin-parcelize plugin enabled in your common module.
from voyager.
Add below compose to your project and use it like
BackPressHandler { //back pressed
//Do Something
}
@Composable
fun BackPressHandler(
backPressedDispatcher: OnBackPressedDispatcher? =
LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher,
onBackPressed: () -> Unit
) {
val currentOnBackPressed by rememberUpdatedState(newValue = onBackPressed)
val backCallback = remember {
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
currentOnBackPressed()
}
}
}
DisposableEffect(key1 = backPressedDispatcher) {
backPressedDispatcher?.addCallback(backCallback)
onDispose {
backCallback.remove()
}
}
}
from voyager.
Related Issues (20)
- navigator scoped for viewmodel (moko-mvvm) HOT 1
- [Question] How to navigate from ScreenModel/ViewModel? HOT 1
- Window inset imePadding stopped working in 1.1.0-alpha03 HOT 2
- Voyager Screen with a `ViewModel` does not have its `SavedStateHandle` saved on process death HOT 1
- Integration with KMMViewModel
- Nesting Navigators prevents WindowInsets from being updated upon device rotation on iOS
- Parcelable encountered IOException writing serializable object HOT 6
- Configuration changes not handled - Tab Options
- Recommended way to implement application that requires login? HOT 4
- Screen State not getting retained HOT 2
- Update compose version to 1.6.1 HOT 2
- Cant pass a lambda to a Screen HOT 2
- Saveable state exception on transition HOT 1
- ViewModel not found in hilt graph. Please, check if you have a Multibinding HOT 1
- Deeplink in IOS HOT 1
- State Preservation Issue with Nested Navigators in Voyager HOT 5
- how can I change BottomSheetNavigator background in Screen? HOT 1
- Navigation from ScreeModel HOT 2
- [Bug][Deeplink] Navigator stack doesn't change after screens list changes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voyager.