Fix appbar back button in Settings screen (#8674)

This commit is contained in:
Ivan Iskandar 2022-12-04 22:27:14 +07:00 committed by GitHub
parent 47f079891f
commit be854b3e90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,7 @@ class SettingsScreen private constructor(
@Composable
override fun Content() {
val navigator = LocalNavigator.currentOrThrow
val parentNavigator = LocalNavigator.currentOrThrow
if (!isTabletUi()) {
Navigator(
screen = if (toBackup) {
@ -34,7 +34,14 @@ class SettingsScreen private constructor(
SettingsMainScreen
},
content = {
CompositionLocalProvider(LocalBackPress provides navigator::pop) {
val pop: () -> Unit = {
if (it.canPop) {
it.pop()
} else {
parentNavigator.pop()
}
}
CompositionLocalProvider(LocalBackPress provides pop) {
ScreenTransition(
navigator = it,
transition = { Transition.OneWayFade },
@ -54,7 +61,7 @@ class SettingsScreen private constructor(
) {
TwoPanelBox(
startContent = {
CompositionLocalProvider(LocalBackPress provides navigator::pop) {
CompositionLocalProvider(LocalBackPress provides parentNavigator::pop) {
SettingsMainScreen.Content(twoPane = true)
}
},