From 58b138755eed04398d9934e0f8304ad1a114d0b3 Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Fri, 27 Sep 2024 11:19:05 -0700 Subject: [PATCH] Update to material3-adaptive 1.1 Change-Id: I4b3b68face17149ab87135df28baa41cd5bacb0f --- .../InterestsListDetailScreen.kt | 19 +++++++++++++++++++ .../apps/nowinandroid/KotlinAndroid.kt | 2 +- gradle/libs.versions.toml | 7 ++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/interests2pane/InterestsListDetailScreen.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/interests2pane/InterestsListDetailScreen.kt index 669c6300a8..b381607268 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/interests2pane/InterestsListDetailScreen.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/interests2pane/InterestsListDetailScreen.kt @@ -18,6 +18,7 @@ package com.google.samples.apps.nowinandroid.ui.interests2pane import androidx.activity.compose.BackHandler import androidx.annotation.Keep +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi import androidx.compose.material3.adaptive.WindowAdaptiveInfo import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo @@ -25,8 +26,11 @@ import androidx.compose.material3.adaptive.layout.AnimatedPane import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffold import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffoldRole import androidx.compose.material3.adaptive.layout.PaneAdaptedValue +import androidx.compose.material3.adaptive.layout.PaneExpansionAnchor +import androidx.compose.material3.adaptive.layout.PaneExpansionDragHandle import androidx.compose.material3.adaptive.layout.ThreePaneScaffoldDestinationItem import androidx.compose.material3.adaptive.layout.calculatePaneScaffoldDirective +import androidx.compose.material3.adaptive.layout.rememberPaneExpansionState import androidx.compose.material3.adaptive.navigation.ThreePaneScaffoldNavigator import androidx.compose.material3.adaptive.navigation.rememberListDetailPaneScaffoldNavigator import androidx.compose.runtime.Composable @@ -126,6 +130,14 @@ internal fun InterestsListDetailScreen( listDetailNavigator.navigateTo(ListDetailPaneScaffoldRole.Detail) } + val paneExpansionState = rememberPaneExpansionState( + anchors = listOf( + PaneExpansionAnchor.Proportion(0f), + PaneExpansionAnchor.Proportion(0.5f), + PaneExpansionAnchor.Proportion(1f), + ) + ) + ListDetailPaneScaffold( value = listDetailNavigator.scaffoldValue, directive = listDetailNavigator.scaffoldDirective, @@ -157,6 +169,13 @@ internal fun InterestsListDetailScreen( } } }, + paneExpansionState = paneExpansionState, + paneExpansionDragHandle = { + PaneExpansionDragHandle( + state = it, + color = MaterialTheme.colorScheme.onSurface, + ) + } ) } diff --git a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt index bfb7995958..99d87e2b09 100644 --- a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt +++ b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt @@ -36,7 +36,7 @@ internal fun Project.configureKotlinAndroid( commonExtension: CommonExtension<*, *, *, *, *, *>, ) { commonExtension.apply { - compileSdk = 34 + compileSdk = 35 defaultConfig { minSdk = 21 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 00c1801940..57876881cf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,6 +8,7 @@ androidxActivity = "1.8.2" androidxAppCompat = "1.7.0" androidxBrowser = "1.8.0" androidxComposeBom = "2024.09.00" +androidxComposeMaterial3Adaptive = "1.1.0-alpha03" androidxComposeRuntimeTracing = "1.0.0-beta01" androidxCore = "1.12.0" androidxCoreSplashscreen = "1.0.1" @@ -73,9 +74,9 @@ androidx-compose-foundation-layout = { group = "androidx.compose.foundation", na androidx-compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended" } androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" } androidx-compose-material3-navigationSuite = { group = "androidx.compose.material3", name = "material3-adaptive-navigation-suite" } -androidx-compose-material3-adaptive = { group = "androidx.compose.material3.adaptive", name = "adaptive" } -androidx-compose-material3-adaptive-layout = { group = "androidx.compose.material3.adaptive", name = "adaptive-layout" } -androidx-compose-material3-adaptive-navigation = { group = "androidx.compose.material3.adaptive", name = "adaptive-navigation" } +androidx-compose-material3-adaptive = { group = "androidx.compose.material3.adaptive", name = "adaptive", version.ref = "androidxComposeMaterial3Adaptive" } +androidx-compose-material3-adaptive-layout = { group = "androidx.compose.material3.adaptive", name = "adaptive-layout", version.ref = "androidxComposeMaterial3Adaptive" } +androidx-compose-material3-adaptive-navigation = { group = "androidx.compose.material3.adaptive", name = "adaptive-navigation", version.ref = "androidxComposeMaterial3Adaptive" } androidx-compose-material3-windowSizeClass = { group = "androidx.compose.material3", name = "material3-window-size-class" } androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime" } androidx-compose-runtime-tracing = { group = "androidx.compose.runtime", name = "runtime-tracing", version.ref = "androidxComposeRuntimeTracing" }