diff --git a/docs/flowlayout.md b/docs/flowlayout.md index a42a657d5..4383d3d70 100644 --- a/docs/flowlayout.md +++ b/docs/flowlayout.md @@ -2,29 +2,13 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-flowlayout)](https://search.maven.org/search?q=g:com.google.accompanist) -Flow Layouts in Accompanist is now deprecated. Please see the migration guide below to begin using -Flow Layouts in Androidx. - -The official `androidx.compose.foundation` FlowLayouts support is very similar to accompanist/flowlayouts, with a few changes. - -It is most similar to `Row` and `Column` and shares similar modifiers and the scopes. -Unlike the standard `Row` and `Column` composables, if it runs out of space on the current row, -the children are placed in the next line, and this repeats until the children are fully placed. - -## Usage - -``` kotlin -FlowRow { - // row contents -} - -FlowColumn { - // column contents -} -``` +!!! warning + **This library is deprecated, with official FlowLayout support in androidx.compose.foundation.** The migration guide and original documentation is below. ## Migration Guide to the official FlowLayouts +The official `androidx.compose.foundation` FlowLayouts support is very similar to accompanist/flowlayouts, with a few changes. + 1. Replace import packages to point to Androidx.Compose ``` kotlin import androidx.compose.foundation.layout.FlowColumn @@ -126,6 +110,24 @@ FlowRow(maxItemsInEachRow = 3) { For examples, refer to the [Flow Row samples](https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/FlowRowSample.kt) and the [Flow Column samples](https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/FlowColumnSample.kt). +## Original Docs + +It is most similar to `Row` and `Column` and shares similar modifiers and the scopes. +Unlike the standard `Row` and `Column` composables, if it runs out of space on the current row, +the children are placed in the next line, and this repeats until the children are fully placed. + +## Usage + +``` kotlin +FlowRow { + // row contents +} + +FlowColumn { + // column contents +} +``` + ## Download [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-flowlayout)](https://search.maven.org/search?q=g:com.google.accompanist) @@ -136,7 +138,7 @@ repositories { } dependencies { - implementation "androidx.compose.foundation:foundation:" + implementation "com.google.accompanist:accompanist-flowlayout:" } ``` diff --git a/docs/placeholder.md b/docs/placeholder.md index 979be7507..9fa8a76bd 100644 --- a/docs/placeholder.md +++ b/docs/placeholder.md @@ -3,7 +3,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-placeholder)](https://search.maven.org/search?q=g:com.google.accompanist) !!! warning -**This library is deprecated, and the API is no longer maintained. We recommend forking the implementation and customising it to your needs.** The original documentation is below. + **This library is deprecated, and the API is no longer maintained. We recommend forking the implementation and customising it to your needs.** The original documentation is below. A library which provides a [modifier][modifier] for display 'placeholder' UI while content is loading. diff --git a/docs/systemuicontroller.md b/docs/systemuicontroller.md index 7f71dadad..beb01632c 100644 --- a/docs/systemuicontroller.md +++ b/docs/systemuicontroller.md @@ -3,7 +3,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-systemuicontroller)](https://search.maven.org/search?q=g:com.google.accompanist) !!! warning -**This library is deprecated, and the API is no longer maintained. We recommend forking the implementation and customising it to your needs.** The original documentation is below. + **This library is deprecated, and the API is no longer maintained. We recommend forking the implementation and customising it to your needs.** The original documentation is below. ## Migration Recommendation: If you were using SystemUIController to go edge-to-edge in your activity and change the system bar colors and system bar icon colors, use the new [Activity.enableEdgeToEdge](https://developer.android.com/reference/androidx/activity/ComponentActivity#(androidx.activity.ComponentActivity).enableEdgeToEdge(androidx.activity.SystemBarStyle,androidx.activity.SystemBarStyle)) method available in androidx.activity 1.8.0-alpha03 and later. This method backports the scrims used on some versions of Android. [This](https://github.com/android/nowinandroid/pull/817) is a sample PR of the migration to the new method and removing the dependency on SystemUIController in Now in Android. diff --git a/docs/themeadapter-appcompat.md b/docs/themeadapter-appcompat.md index 8f23e9f6b..5c146c2c0 100644 --- a/docs/themeadapter-appcompat.md +++ b/docs/themeadapter-appcompat.md @@ -3,7 +3,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-themeadapter-appcompat)](https://search.maven.org/search?q=g:com.google.accompanist) !!! warning -**This library is deprecated, and the API is no longer maintained.** The original documentation is below. + **This library is deprecated, and the API is no longer maintained.** The original documentation is below. ## Migration Recommendation: Use the [Material Theme Builder](https://m3.material.io/theme-builder) tool, or an alternative design tool, to generate a matching XML and Compose theme implementation for your app. See [Migrating XML themes to Compose](https://developer.android.com/jetpack/compose/designsystems/views-to-compose) to learn more. @@ -186,4 +186,4 @@ limitations under the License. [materialtheme]: https://developer.android.com/reference/kotlin/androidx/compose/material/MaterialTheme [colors]: https://developer.android.com/reference/kotlin/androidx/compose/material/Colors [typography]: https://developer.android.com/reference/kotlin/androidx/compose/material/Typography -[shapes]: https://developer.android.com/reference/kotlin/androidx/compose/material/Shapes \ No newline at end of file +[shapes]: https://developer.android.com/reference/kotlin/androidx/compose/material/Shapes diff --git a/docs/themeadapter-core.md b/docs/themeadapter-core.md index 91d06f61a..7c272a18c 100644 --- a/docs/themeadapter-core.md +++ b/docs/themeadapter-core.md @@ -3,7 +3,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-themeadapter-core)](https://search.maven.org/search?q=g:com.google.accompanist) !!! warning -**This library is deprecated, and the API is no longer maintained.** The original documentation is below. + **This library is deprecated, and the API is no longer maintained.** The original documentation is below. ## Migration Recommendation: Use the [Material Theme Builder](https://m3.material.io/theme-builder) tool, or an alternative design tool, to generate a matching XML and Compose theme implementation for your app. See [Migrating XML themes to Compose](https://developer.android.com/jetpack/compose/designsystems/views-to-compose) to learn more. @@ -62,4 +62,4 @@ limitations under the License. ``` [compose]: https://developer.android.com/jetpack/compose -[api]: ../api/themeadapter-core \ No newline at end of file +[api]: ../api/themeadapter-core diff --git a/docs/themeadapter-material.md b/docs/themeadapter-material.md index 998cd086b..e2430ccf7 100644 --- a/docs/themeadapter-material.md +++ b/docs/themeadapter-material.md @@ -3,7 +3,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-themeadapter-material)](https://search.maven.org/search?q=g:com.google.accompanist) !!! warning -**This library is deprecated, and the API is no longer maintained.** The original documentation is below. + **This library is deprecated, and the API is no longer maintained.** The original documentation is below. ## Migration Recommendation: Use the [Material Theme Builder](https://m3.material.io/theme-builder) tool, or an alternative design tool, to generate a matching XML and Compose theme implementation for your app. See [Migrating XML themes to Compose](https://developer.android.com/jetpack/compose/designsystems/views-to-compose) to learn more. @@ -58,9 +58,9 @@ MdcTheme { This is especially handy when you're migrating an existing app, a `Fragment` (or other UI container) at a time. !!! caution -If you are using an AppCompat (i.e. non-MDC) theme in your app, you should use -[AppCompat Theme Adapter](https://github.com/google/accompanist/tree/main/themeadapter-appcompat) -instead, as it attempts to bridge the gap between [AppCompat][appcompat] XML themes, and M2 themes in [Jetpack Compose][compose]. + If you are using an AppCompat (i.e. non-MDC) theme in your app, you should use + [AppCompat Theme Adapter](https://github.com/google/accompanist/tree/main/themeadapter-appcompat) + instead, as it attempts to bridge the gap between [AppCompat][appcompat] XML themes, and M2 themes in [Jetpack Compose][compose]. ### Customizing the M2 theme diff --git a/docs/themeadapter-material3.md b/docs/themeadapter-material3.md index eb04478b2..73403826b 100644 --- a/docs/themeadapter-material3.md +++ b/docs/themeadapter-material3.md @@ -3,7 +3,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-themeadapter-material3)](https://search.maven.org/search?q=g:com.google.accompanist) !!! warning -**This library is deprecated, and the API is no longer maintained. We recommend generating a theme with [Material Theme Builder](https://m3.material.io/theme-builder)** The original documentation is below. + **This library is deprecated, and the API is no longer maintained. We recommend generating a theme with [Material Theme Builder](https://m3.material.io/theme-builder)** The original documentation is below. ## Migration Recommendation: Use the [Material Theme Builder](https://m3.material.io/theme-builder) tool, or an alternative design tool, to generate a matching XML and Compose theme implementation for your app. See [Migrating XML themes to Compose](https://developer.android.com/jetpack/compose/designsystems/views-to-compose) to learn more. @@ -141,4 +141,4 @@ limitations under the License. [materialtheme]: https://developer.android.com/reference/kotlin/androidx/compose/material3/MaterialTheme [colorscheme]: https://developer.android.com/reference/kotlin/androidx/compose/material3/ColorScheme [typography]: https://developer.android.com/reference/kotlin/androidx/compose/material3/Typography -[shapes]: https://developer.android.com/reference/kotlin/androidx/compose/material3/Shapes \ No newline at end of file +[shapes]: https://developer.android.com/reference/kotlin/androidx/compose/material3/Shapes diff --git a/docs/web.md b/docs/web.md index 0df40b7f7..058607029 100644 --- a/docs/web.md +++ b/docs/web.md @@ -5,7 +5,7 @@ A library which provides a Jetpack Compose wrapper around Android's WebView. !!! warning -**This library is deprecated, and the API is no longer maintained. We recommend forking the implementation and customising it to your needs.** The original documentation is below. + **This library is deprecated, and the API is no longer maintained. We recommend forking the implementation and customising it to your needs.** The original documentation is below. ## Usage @@ -71,4 +71,4 @@ repositories { dependencies { implementation "com.google.accompanist:accompanist-webview:" } -``` \ No newline at end of file +``` diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c58dab274..cc8346779 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,18 +1,18 @@ [versions] -compose = "1.6.0-alpha06" -composeCompiler = "1.5.3" +compose = "1.6.0" +composeCompiler = "1.5.8" composeMaterial3 = "1.0.1" composesnapshot = "-" # a single character = no snapshot dokka = "1.8.10" # gradlePlugin and lint need to be updated together -gradlePlugin = "8.1.0" +gradlePlugin = "8.2.2" lintMinCompose = "30.0.0" ktlint = "0.45.2" -kotlin = "1.9.10" +kotlin = "1.9.22" coroutines = "1.6.4" okhttp = "3.12.13" coil = "1.3.2" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2..c1962a79e 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d3f..3499ded5c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d6..aeb74cbb4 100755 --- a/gradlew +++ b/gradlew @@ -85,9 +85,6 @@ done APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -144,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/navigation-material/src/androidTest/java/com/google/accompanist/navigation.material/BottomSheetNavigatorTest.kt b/navigation-material/src/androidTest/java/com/google/accompanist/navigation.material/BottomSheetNavigatorTest.kt index f138f4fe1..c37ae9506 100644 --- a/navigation-material/src/androidTest/java/com/google/accompanist/navigation.material/BottomSheetNavigatorTest.kt +++ b/navigation-material/src/androidTest/java/com/google/accompanist/navigation.material/BottomSheetNavigatorTest.kt @@ -779,6 +779,71 @@ internal class BottomSheetNavigatorTest { .isEqualTo(firstSheetDestination) } + @Test + fun testBackPressWithNestedGraphBehind() { + lateinit var navigator: BottomSheetNavigator + lateinit var navController: NavHostController + lateinit var nestedNavController: NavHostController + lateinit var backDispatcher: OnBackPressedDispatcher + val homeDestination = "home" + val firstSheetDestination = "sheet1" + val firstNestedDestination = "nested1" + val secondNestedDestination = "nested2" + + composeTestRule.setContent { + backDispatcher = LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher!! + navigator = rememberBottomSheetNavigator() + navController = rememberNavController(navigator) + ModalBottomSheetLayout(navigator) { + NavHost(navController, homeDestination) { + composable(homeDestination) { + nestedNavController = rememberNavController() + NavHost(nestedNavController, "nested1") { + composable(firstNestedDestination) { } + composable(secondNestedDestination) { } + } + } + bottomSheet(firstSheetDestination) { + Text("SheetDestination") + } + } + } + } + + assertThat(navController.currentBackStackEntry?.destination?.route) + .isEqualTo(homeDestination) + + composeTestRule.runOnUiThread { + nestedNavController.navigate(secondNestedDestination) + } + composeTestRule.waitForIdle() + + assertThat(navController.currentBackStackEntry?.destination?.route) + .isEqualTo(homeDestination) + assertThat(nestedNavController.currentBackStackEntry?.destination?.route) + .isEqualTo(secondNestedDestination) + + composeTestRule.runOnUiThread { + navController.navigate(firstSheetDestination) + } + composeTestRule.waitForIdle() + + assertThat(navigator.sheetState.currentValue) + .isAnyOf(ModalBottomSheetValue.HalfExpanded, ModalBottomSheetValue.Expanded) + + composeTestRule.runOnUiThread { + backDispatcher.onBackPressed() + } + composeTestRule.waitForIdle() + + assertThat(navController.currentBackStackEntry?.destination?.route) + .isEqualTo(homeDestination) + assertThat(nestedNavController.currentBackStackEntry?.destination?.route) + .isEqualTo(secondNestedDestination) + + assertThat(navigator.sheetState.currentValue).isEqualTo(ModalBottomSheetValue.Hidden) + } + private fun BottomSheetNavigator.createFakeDestination() = BottomSheetNavigator.Destination(this) { Text("Fake Sheet Content") diff --git a/navigation-material/src/main/java/com/google/accompanist/navigation/material/BottomSheetNavigator.kt b/navigation-material/src/main/java/com/google/accompanist/navigation/material/BottomSheetNavigator.kt index b14685efa..85ab18876 100644 --- a/navigation-material/src/main/java/com/google/accompanist/navigation/material/BottomSheetNavigator.kt +++ b/navigation-material/src/main/java/com/google/accompanist/navigation/material/BottomSheetNavigator.kt @@ -17,6 +17,7 @@ package com.google.accompanist.navigation.material import android.annotation.SuppressLint +import androidx.activity.compose.BackHandler import androidx.compose.animation.core.AnimationSpec import androidx.compose.animation.core.SpringSpec import androidx.compose.foundation.layout.ColumnScope @@ -185,6 +186,10 @@ public class BottomSheetNavigator( LaunchedEffect(retainedEntry) { sheetState.show() } + + BackHandler { + state.popWithTransition(popUpTo = retainedEntry!!, saveState = false) + } } SheetContentHost(