diff --git a/common/common-sample/src/commonMain/kotlin/ru/alexgladkov/common/compose/screens/ModalSheetScreen.kt b/common/common-sample/src/commonMain/kotlin/ru/alexgladkov/common/compose/screens/ModalSheetScreen.kt index 1f8f3d96..57c08b3c 100644 --- a/common/common-sample/src/commonMain/kotlin/ru/alexgladkov/common/compose/screens/ModalSheetScreen.kt +++ b/common/common-sample/src/commonMain/kotlin/ru/alexgladkov/common/compose/screens/ModalSheetScreen.kt @@ -5,8 +5,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.material.Text import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowCircleUp -import androidx.compose.material.icons.filled.ArrowDownward +import androidx.compose.material.icons.filled.* import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp @@ -16,6 +15,10 @@ import ru.alexgladkov.odyssey.compose.extensions.present import ru.alexgladkov.odyssey.compose.local.LocalRootController import ru.alexgladkov.odyssey.compose.navigation.modal_navigation.ModalSheetConfiguration import kotlin.random.Random +import ru.alexgladkov.common.compose.NavigationTree +import ru.alexgladkov.odyssey.core.LaunchFlag +import ru.alexgladkov.odyssey.compose.extensions.present +import ru.alexgladkov.odyssey.compose.extensions.push @Composable @@ -63,5 +66,21 @@ fun ModalSheetScreen(onCloseClick: () -> Unit) { } } } + + ActionCell("Start New Chain", icon = Icons.Filled.OpenInNew) { + rootController.present( + screen = NavigationTree.Present.name, + launchFlag = LaunchFlag.SingleNewTask + ) + } + + ActionCell(text = "Clear Previous Screen", icon = Icons.Filled.Clear) { + rootController.push( + screen = NavigationTree.Push.name, + launchFlag = LaunchFlag.ClearPrevious, + params = 0 + ) + } + } } \ No newline at end of file diff --git a/odyssey/odyssey-compose/src/commonMain/kotlin/ru/alexgladkov/odyssey/compose/RootController.kt b/odyssey/odyssey-compose/src/commonMain/kotlin/ru/alexgladkov/odyssey/compose/RootController.kt index 4a0d5a3a..fbff4492 100644 --- a/odyssey/odyssey-compose/src/commonMain/kotlin/ru/alexgladkov/odyssey/compose/RootController.kt +++ b/odyssey/odyssey-compose/src/commonMain/kotlin/ru/alexgladkov/odyssey/compose/RootController.kt @@ -587,9 +587,18 @@ open class RootController(rootControllerType: RootControllerType): CoreRootContr private fun handleLaunchFlag(screenKey: String, launchFlag: LaunchFlag?) { when (launchFlag) { - LaunchFlag.SingleNewTask -> _backstack.clear() - LaunchFlag.SingleInstance -> _backstack.removeAll { it.realKey == screenKey } - LaunchFlag.ClearPrevious -> _backstack.removeLastOrNull() + LaunchFlag.SingleNewTask -> { + _modalController?.clearBackStack() + _backstack.clear() + } + LaunchFlag.SingleInstance -> { + _modalController?.clearBackStack() + _backstack.removeAll { it.realKey == screenKey } + } + LaunchFlag.ClearPrevious -> { + _modalController?.clearBackStack() + _backstack.removeLastOrNull() + } null -> {} } } diff --git a/odyssey/odyssey-compose/src/commonMain/kotlin/ru/alexgladkov/odyssey/compose/controllers/ModalRootController.kt b/odyssey/odyssey-compose/src/commonMain/kotlin/ru/alexgladkov/odyssey/compose/controllers/ModalRootController.kt index 1fa350fb..753feb1f 100644 --- a/odyssey/odyssey-compose/src/commonMain/kotlin/ru/alexgladkov/odyssey/compose/controllers/ModalRootController.kt +++ b/odyssey/odyssey-compose/src/commonMain/kotlin/ru/alexgladkov/odyssey/compose/controllers/ModalRootController.kt @@ -173,6 +173,7 @@ open class ModalController { fun clearBackStack() { _backStack.clear() + redrawStack() } fun isEmpty() = _backStack.none { it.dialogState !is ModalDialogState.Close }