Skip to content

Commit

Permalink
Update test activity and screens to use predictiveBackAnimation
Browse files Browse the repository at this point in the history
  • Loading branch information
xxfast committed Jun 6, 2023
1 parent 72b2eaf commit 74c6c96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:supportsRtl="true">
android:supportsRtl="true"
android:enableOnBackInvokedCallback="true"
>
<activity
android:name="io.github.xxfast.decompose.TestActivity"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.ExperimentalDecomposeApi
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.predictiveBackAnimation
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.slide
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation
import com.arkivanov.decompose.router.stack.pop
import com.arkivanov.decompose.router.stack.push
import io.github.xxfast.decompose.LocalComponentContext
import io.github.xxfast.decompose.router.Router
import io.github.xxfast.decompose.router.content.RoutedContent
import io.github.xxfast.decompose.router.rememberOnRoute
Expand All @@ -56,12 +59,17 @@ const val TITLEBAR_TAG = "titleBar"
const val DETAILS_TAG = "details"
const val LAZY_COLUMN_TAG = "lazyColumn"

@OptIn(ExperimentalDecomposeApi::class)
@Composable
fun HomeScreen() {
val router: Router<Screen> = rememberRouter(Screen::class, listOf(Screen.Game))
RoutedContent(
router = router,
animation = stackAnimation(slide())
animation = predictiveBackAnimation(
animation = stackAnimation(slide()),
onBack = { router.pop() },
backHandler = LocalComponentContext.current.backHandler
)
) { screen ->
when (screen) {
Screen.Game -> ListScreen(
Expand Down

0 comments on commit 74c6c96

Please sign in to comment.