From be854b3e90c345db589cde30daaa839c0a21c129 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sun, 4 Dec 2022 22:27:14 +0700 Subject: [PATCH] Fix appbar back button in Settings screen (#8674) --- .../kanade/tachiyomi/ui/setting/SettingsScreen.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt index 1c6053352b..09915a5664 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt @@ -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) } },