Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable predictive back gesture #231

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ dokka = "1.8.10"

# Compose
activity = "1.9.0"
navigation = "2.8.0-beta02"
compose = "1.7.0-beta02"
navigation = "2.8.0-beta05"
compose = "1.7.0-beta05"
compose-compiler = "1.5.2"

# AndroidX
Expand Down
1 change: 1 addition & 0 deletions sample/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<application
android:allowBackup="false"
android:enableOnBackInvokedCallback="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,8 @@ fun CircularRevealScreen(upPress: () -> Unit) {
val (state, onStateChanged) = remember {
mutableStateOf(State(false, Offset.Zero))
}
BackHandler {
if (state.visible) {
onStateChanged(state.copy(visible = false))
} else {
upPress()
}
BackHandler(enabled = state.visible) {
onStateChanged(state.copy(visible = false))
}
DefaultScaffold(upPress = upPress) { innerPadding ->
Surface(modifier = Modifier.padding(innerPadding)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package soup.compose.material.motion.sample.ui.demo

import android.content.res.Configuration
import androidx.activity.compose.BackHandler
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.compose.NavHost
Expand Down Expand Up @@ -46,9 +45,6 @@ fun DemoScreen(upPress: () -> Unit) {
enterTransition = { holdIn() },
exitTransition = { holdOut() },
) {
BackHandler {
upPress()
}
LibraryScreen(
onItemClick = {
navController.navigate(DemoDestination.Album(albumId = it.id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ import soup.compose.material.motion.sample.ui.theme.SampleTheme
@Composable
fun MaterialElevationScaleScreen(upPress: () -> Unit) {
val (forward, onForwardChanged) = remember { mutableStateOf(false) }
BackHandler {
if (forward) {
onForwardChanged(false)
} else {
upPress()
}
BackHandler(enabled = forward) {
onForwardChanged(false)
}
DefaultScaffold(
upPress = upPress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package soup.compose.material.motion.sample.ui.material.fade

import android.content.res.Configuration
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
Expand All @@ -39,9 +38,6 @@ import soup.compose.material.motion.sample.ui.theme.SampleTheme

@Composable
fun MaterialFadeScreen(upPress: () -> Unit) {
BackHandler {
upPress()
}
DefaultScaffold(upPress = upPress) { innerPadding ->
val (visible, onVisibleChanged) = remember { mutableStateOf(true) }
Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package soup.compose.material.motion.sample.ui.material.fadethrough

import android.content.res.Configuration
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
Expand All @@ -33,9 +32,6 @@ import soup.compose.material.motion.sample.ui.theme.SampleTheme
@Composable
fun MaterialFadeThroughScreen(upPress: () -> Unit) {
val (selectedTab, setSelectedTab) = remember { mutableStateOf(BottomTabs.Albums) }
BackHandler {
upPress()
}
DefaultScaffold(
upPress = upPress,
bottomBar = { BottomTabsControls(selectedTab, setSelectedTab) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ import soup.compose.material.motion.sample.ui.theme.SampleTheme
@Composable
fun HoldScreen(upPress: () -> Unit) {
val (forward, onForwardChanged) = remember { mutableStateOf(false) }
BackHandler {
if (forward) {
onForwardChanged(false)
} else {
upPress()
}
BackHandler(enabled = forward) {
onForwardChanged(false)
}
DefaultScaffold(
upPress = upPress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ private enum class Axis {
fun MaterialSharedAxisScreen(upPress: () -> Unit) {
val (selectedAxis, onAxisSelected) = remember { mutableStateOf(Axis.X) }
val (forward, onForwardChanged) = remember { mutableStateOf(false) }
BackHandler {
if (forward) {
onForwardChanged(false)
} else {
upPress()
}
BackHandler(enabled = forward) {
onForwardChanged(false)
}
DefaultScaffold(
upPress = upPress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package soup.compose.material.motion.sample.ui.navigation

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -74,9 +73,6 @@ fun AnimatedNavHostScreen(upPress: () -> Unit) {
},
) {
composable<AnimatedNavDestination.First> {
BackHandler {
upPress()
}
AnimatedNavDestinationScreen(
name = "First",
backgroundColor = Color.Cyan,
Expand Down
Loading