diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleListDetailPaneScaffold.kt b/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleListDetailPaneScaffold.kt index b79f7ee7..5fd3ee36 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleListDetailPaneScaffold.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleListDetailPaneScaffold.kt @@ -35,11 +35,13 @@ import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffold import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffoldRole import androidx.compose.material3.adaptive.navigation.rememberListDetailPaneScaffoldNavigator import androidx.compose.runtime.Composable +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import kotlinx.coroutines.launch import kotlinx.parcelize.Parcelize @OptIn(ExperimentalMaterial3AdaptiveApi::class) @@ -47,9 +49,10 @@ import kotlinx.parcelize.Parcelize fun SampleListDetailPaneScaffoldParts() { // [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part02] val navigator = rememberListDetailPaneScaffoldNavigator() + val scope = rememberCoroutineScope() BackHandler(navigator.canNavigateBack()) { - navigator.navigateBack() + scope.launch { navigator.navigateBack() } } // [END android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part02] @@ -73,7 +76,9 @@ fun SampleListDetailPaneScaffoldParts() { MyList( onItemClick = { item -> // Navigate to the detail pane with the passed item - navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) + scope.launch { + navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) + } } ) } @@ -94,7 +99,7 @@ fun SampleListDetailPaneScaffoldParts() { // [END_EXCLUDE] detailPane = { AnimatedPane { - navigator.currentDestination?.content?.let { + navigator.currentDestination?.contentKey?.let { MyDetails(it) } } @@ -109,9 +114,10 @@ fun SampleListDetailPaneScaffoldParts() { fun SampleListDetailPaneScaffoldFull() { // [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_full] val navigator = rememberListDetailPaneScaffoldNavigator() + val scope = rememberCoroutineScope() BackHandler(navigator.canNavigateBack()) { - navigator.navigateBack() + scope.launch { navigator.navigateBack() } } ListDetailPaneScaffold( @@ -122,7 +128,9 @@ fun SampleListDetailPaneScaffoldFull() { MyList( onItemClick = { item -> // Navigate to the detail pane with the passed item - navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) + scope.launch { + navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) + } }, ) } @@ -130,7 +138,7 @@ fun SampleListDetailPaneScaffoldFull() { detailPane = { AnimatedPane { // Show the detail pane content if selected item is available - navigator.currentDestination?.content?.let { + navigator.currentDestination?.contentKey?.let { MyDetails(it) } } diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleSupportingPaneScaffold.kt b/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleSupportingPaneScaffold.kt index ad2e0d30..c36d08d0 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleSupportingPaneScaffold.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleSupportingPaneScaffold.kt @@ -32,15 +32,20 @@ import androidx.compose.material3.adaptive.layout.ThreePaneScaffoldRole import androidx.compose.material3.adaptive.layout.ThreePaneScaffoldScope import androidx.compose.material3.adaptive.navigation.rememberSupportingPaneScaffoldNavigator import androidx.compose.runtime.Composable +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import kotlinx.coroutines.launch +@Preview @Composable fun SampleSupportingPaneScaffoldParts() { // [START android_compose_adaptivelayouts_sample_supporting_pane_scaffold_nav_and_back] val navigator = rememberSupportingPaneScaffoldNavigator() + val scope = rememberCoroutineScope() BackHandler(navigator.canNavigateBack()) { - navigator.navigateBack() + scope.launch { navigator.navigateBack() } } // [END android_compose_adaptivelayouts_sample_supporting_pane_scaffold_nav_and_back] @@ -54,13 +59,15 @@ fun SampleSupportingPaneScaffoldParts() { // [END android_compose_adaptivelayouts_sample_supporting_pane_scaffold_params] } +@Preview @Composable fun SampleSupportingPaneScaffoldFull() { // [START android_compose_adaptivelayouts_sample_supporting_pane_scaffold_full] val navigator = rememberSupportingPaneScaffoldNavigator() + val scope = rememberCoroutineScope() BackHandler(navigator.canNavigateBack()) { - navigator.navigateBack() + scope.launch { navigator.navigateBack() } } SupportingPaneScaffold( @@ -73,7 +80,9 @@ fun SampleSupportingPaneScaffoldFull() { Button( modifier = Modifier.wrapContentSize(), onClick = { - navigator.navigateTo(SupportingPaneScaffoldRole.Supporting) + scope.launch { + navigator.navigateTo(SupportingPaneScaffoldRole.Supporting) + } } ) { Text("Show supporting pane") @@ -100,36 +109,30 @@ fun ThreePaneScaffoldScope.MainPane( onNavigateToSupportingPane: () -> Unit, modifier: Modifier = Modifier, ) { - AnimatedPane(modifier = modifier.safeContentPadding()) { - // Main pane content - if (shouldShowSupportingPaneButton) { - Button(onClick = onNavigateToSupportingPane) { - Text("Show supporting pane") - } - } else { - Text("Supporting pane is shown") - } - } + MainPane( + modifier = modifier.safeContentPadding(), + shouldShowSupportingPaneButton = shouldShowSupportingPaneButton, + onNavigateToSupportingPane = onNavigateToSupportingPane + ) } @Composable fun ThreePaneScaffoldScope.SupportingPane( modifier: Modifier = Modifier, ) { - AnimatedPane(modifier = modifier.safeContentPadding()) { - // Supporting pane content - Text("This is the supporting pane") - } + SupportingPane(modifier = modifier.safeContentPadding()) } // [END android_compose_adaptivelayouts_sample_supporting_pane_scaffold_extracted_panes] +@Preview @Composable fun SampleSupportingPaneScaffoldSimplified() { // [START android_compose_adaptivelayouts_sample_supporting_pane_scaffold_simplified] val navigator = rememberSupportingPaneScaffoldNavigator() + val scope = rememberCoroutineScope() BackHandler(navigator.canNavigateBack()) { - navigator.navigateBack() + scope.launch { navigator.navigateBack() } } SupportingPaneScaffold( @@ -138,7 +141,9 @@ fun SampleSupportingPaneScaffoldSimplified() { mainPane = { MainPane( shouldShowSupportingPaneButton = navigator.scaffoldValue.secondary == PaneAdaptedValue.Hidden, - onNavigateToSupportingPane = { navigator.navigateTo(ThreePaneScaffoldRole.Secondary) } + onNavigateToSupportingPane = { + scope.launch { navigator.navigateTo(ThreePaneScaffoldRole.Secondary) } + } ) }, supportingPane = { SupportingPane() }, diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementBlurSnippet.kt b/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementBlurSnippet.kt index 92bee909..e07cbec6 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementBlurSnippet.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementBlurSnippet.kt @@ -157,7 +157,7 @@ fun SharedTransitionScope.SnackItem( SnackContents( snack = snack, modifier = Modifier.sharedElement( - state = rememberSharedContentState(key = snack.name), + sharedContentState = rememberSharedContentState(key = snack.name), animatedVisibilityScope = this@AnimatedVisibility, boundsTransform = boundsTransition, ), diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementSnippets.kt index 955dbe46..5a51b8d5 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementSnippets.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementSnippets.kt @@ -111,7 +111,7 @@ private fun AnimatedVisibilitySharedElementShortenedExample() { SnackContents( snack = snack, modifier = Modifier.sharedElement( - state = rememberSharedContentState(key = snack.name), + sharedContentState = rememberSharedContentState(key = snack.name), animatedVisibilityScope = this@AnimatedVisibility ), onClick = { @@ -175,7 +175,7 @@ fun SharedTransitionScope.SnackEditDetails( SnackContents( snack = targetSnack, modifier = Modifier.sharedElement( - state = rememberSharedContentState(key = targetSnack.name), + sharedContentState = rememberSharedContentState(key = targetSnack.name), animatedVisibilityScope = this@AnimatedContent, ), onClick = { diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/draganddrop/DragAndDropSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/draganddrop/DragAndDropSnippets.kt index 46e245a3..da7b84a1 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/draganddrop/DragAndDropSnippets.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/draganddrop/DragAndDropSnippets.kt @@ -24,7 +24,6 @@ import androidx.annotation.RequiresApi import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.draganddrop.dragAndDropSource import androidx.compose.foundation.draganddrop.dragAndDropTarget -import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -41,39 +40,39 @@ private fun DragAndDropSnippet() { val url = "" // [START android_compose_drag_and_drop_1] - Modifier.dragAndDropSource { - detectTapGestures(onLongPress = { - // Transfer data here. - }) + Modifier.dragAndDropSource { _ -> + // Transfer data here. + DragAndDropTransferData(ClipData.newPlainText("image Url", url)) } // [END android_compose_drag_and_drop_1] // [START android_compose_drag_and_drop_2] - Modifier.dragAndDropSource { - detectTapGestures(onLongPress = { - startTransfer( - DragAndDropTransferData( - ClipData.newPlainText( - "image Url", url - ) - ) + Modifier.dragAndDropSource { _ -> + +// detectTapGestures(onLongPress = { +// startTransfer( + DragAndDropTransferData( + ClipData.newPlainText( + "image Url", url ) - }) + ) +// ) +// }) } // [END android_compose_drag_and_drop_2] // [START android_compose_drag_and_drop_3] - Modifier.dragAndDropSource { - detectTapGestures(onLongPress = { - startTransfer( - DragAndDropTransferData( - ClipData.newPlainText( - "image Url", url - ), - flags = View.DRAG_FLAG_GLOBAL - ) - ) - }) + Modifier.dragAndDropSource { _ -> +// detectTapGestures(onLongPress = { +// startTransfer( + DragAndDropTransferData( + ClipData.newPlainText( + "image Url", url + ), + flags = View.DRAG_FLAG_GLOBAL + ) +// ) +// }) } // [END android_compose_drag_and_drop_3] diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/touchinput/userinteractions/UserInteractions.kt b/compose/snippets/src/main/java/com/example/compose/snippets/touchinput/userinteractions/UserInteractions.kt index 07248a6f..12de9f92 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/touchinput/userinteractions/UserInteractions.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/touchinput/userinteractions/UserInteractions.kt @@ -30,13 +30,14 @@ import androidx.compose.foundation.interaction.PressInteraction import androidx.compose.foundation.layout.Box import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.LocalRippleConfiguration -import androidx.compose.material.LocalUseFallbackRippleImplementation import androidx.compose.material.RippleConfiguration import androidx.compose.material.ripple import androidx.compose.material.ripple.LocalRippleTheme import androidx.compose.material.ripple.RippleAlpha import androidx.compose.material.ripple.RippleTheme import androidx.compose.material.ripple.rememberRipple +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.LocalUseFallbackRippleImplementation import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider @@ -239,7 +240,7 @@ private class ScaleIndicationNode( fun App() { } -@OptIn(ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable private fun LocalUseFallbackRippleImplementationExample() { // [START android_compose_userinteractions_localusefallbackrippleimplementation] @@ -252,7 +253,7 @@ private fun LocalUseFallbackRippleImplementationExample() { } // [START android_compose_userinteractions_localusefallbackrippleimplementation_app_theme] -@OptIn(ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun MyAppTheme(content: @Composable () -> Unit) { CompositionLocalProvider(LocalUseFallbackRippleImplementation provides true) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fdc4663d..6f59dcbe 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,13 +18,12 @@ androidx-navigation = "2.8.6" androidx-paging = "3.3.5" androidx-test = "1.6.1" androidx-test-espresso = "3.6.1" -androidx-window = "1.4.0-beta01" +androidx-window = "1.4.0-beta02" androidxHiltNavigationCompose = "1.2.0" coil = "2.7.0" # @keep compileSdk = "35" -compose-latest = "1.7.7" -composeUiTooling = "1.4.0" +composeUiTooling = "1.4.1" coreSplashscreen = "1.0.1" coroutines = "1.10.1" glide = "1.0.0-beta01" @@ -64,13 +63,13 @@ accompanist-theme-adapter-material = { module = "com.google.accompanist:accompan accompanist-theme-adapter-material3 = { module = "com.google.accompanist:accompanist-themeadapter-material3", version.ref = "accompanist" } androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" } androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } -androidx-compose-animation-graphics = { module = "androidx.compose.animation:animation-graphics", version.ref = "compose-latest" } -androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose-latest" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose-latest" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose-latest" } +androidx-compose-animation-graphics = { module = "androidx.compose.animation:animation-graphics" } +androidx-compose-bom = { module = "androidx.compose:compose-bom-beta", version.ref = "androidx-compose-bom" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } -androidx-compose-material-ripple = { module = "androidx.compose.material:material-ripple", version.ref = "compose-latest" } +androidx-compose-material-ripple = { module = "androidx.compose.material:material-ripple" } androidx-compose-material3 = { module = "androidx.compose.material3:material3" } androidx-compose-material3-adaptive = { module = "androidx.compose.material3.adaptive:adaptive", version.ref = "material3-adaptive" } androidx-compose-material3-adaptive-layout = { module = "androidx.compose.material3.adaptive:adaptive-layout", version.ref = "material3-adaptive" } @@ -78,7 +77,7 @@ androidx-compose-material3-adaptive-navigation = { module = "androidx.compose.ma androidx-compose-material3-adaptive-navigation-suite = { module = "androidx.compose.material3:material3-adaptive-navigation-suite", version.ref = "material3-adaptive-navigation-suite" } androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose-latest" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } androidx-compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" } androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" }