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

Update Canonical Layouts to M3 alpha 1.4.0-alpha04 #480

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 13 additions & 13 deletions CanonicalLayouts/list-detail-compose/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id("org.jetbrains.kotlin.plugin.compose") version "2.0.0"
id("org.jetbrains.kotlin.plugin.compose") version "2.0.20"
}

android {
Expand Down Expand Up @@ -66,22 +66,22 @@ composeCompiler {
}

dependencies {
def composeBom = platform('androidx.compose:compose-bom:2024.09.00')
def composeBom = platform('androidx.compose:compose-bom:2024.11.00')
implementation(composeBom)

implementation "com.google.accompanist:accompanist-adaptive:0.32.0"
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.5'
implementation 'androidx.activity:activity-compose:1.9.2'
implementation "androidx.compose.foundation:foundation:1.7.0"
implementation "androidx.compose.ui:ui:1.7.0"
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'
implementation 'androidx.activity:activity-compose:1.9.3'
implementation "androidx.compose.foundation:foundation:1.7.5"
implementation "androidx.compose.ui:ui:1.7.5"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation "androidx.window:window:1.3.0"
implementation 'androidx.compose.material3:material3:1.3.0'
implementation 'androidx.compose.material3.adaptive:adaptive:1.1.0-alpha02'
implementation 'androidx.compose.material3.adaptive:adaptive-layout:1.1.0-alpha02'
implementation 'androidx.compose.material3.adaptive:adaptive-navigation:1.1.0-alpha02'
implementation "androidx.compose.material3:material3-window-size-class:1.3.0"
implementation "androidx.compose.animation:animation:1.7.0"
implementation 'androidx.compose.material3:material3:1.4.0-alpha04'
implementation 'androidx.compose.material3.adaptive:adaptive:1.1.0-alpha07'
implementation 'androidx.compose.material3.adaptive:adaptive-layout:1.1.0-alpha07'
implementation 'androidx.compose.material3.adaptive:adaptive-navigation:1.1.0-alpha07'
implementation "androidx.compose.material3:material3-window-size-class:1.3.1"
implementation "androidx.compose.animation:animation:1.7.5"
testImplementation 'junit:junit:4.13.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.animation.SharedTransitionScope
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -43,29 +44,30 @@ import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.LocalMinimumInteractiveComponentSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.VerticalDragHandle
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
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.PaneExpansionDragHandle
import androidx.compose.material3.adaptive.layout.rememberPaneExpansionState
import androidx.compose.material3.adaptive.navigation.rememberListDetailPaneScaffoldNavigator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.window.core.layout.WindowWidthSizeClass
import com.example.listdetailcompose.R
import kotlinx.coroutines.launch

// Create some simple sample data
private val loremIpsum = """
Expand Down Expand Up @@ -96,11 +98,14 @@ private data class DefinedWord(
fun ListDetailSample() {
var selectedWordIndex: Int? by rememberSaveable { mutableStateOf(null) }
val navigator = rememberListDetailPaneScaffoldNavigator<Nothing>()
val scope = rememberCoroutineScope()
val isListAndDetailVisible =
navigator.scaffoldValue[ListDetailPaneScaffoldRole.Detail] == PaneAdaptedValue.Expanded && navigator.scaffoldValue[ListDetailPaneScaffoldRole.List] == PaneAdaptedValue.Expanded

BackHandler(enabled = navigator.canNavigateBack()) {
navigator.navigateBack()
scope.launch {
navigator.navigateBack()
}
}

SharedTransitionLayout {
Expand All @@ -122,7 +127,9 @@ fun ListDetailSample() {
},
onIndexClick = { index ->
selectedWordIndex = index
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail)
scope.launch {
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail)
}
},
isListAndDetailVisible = isListAndDetailVisible,
isListVisible = !isDetailVisible,
Expand All @@ -147,7 +154,16 @@ fun ListDetailSample() {
},
paneExpansionState = rememberPaneExpansionState(navigator.scaffoldValue),
paneExpansionDragHandle = { state ->
PaneExpansionDragHandle(state, Color.Red)
val interactionSource =
remember { MutableInteractionSource() }
VerticalDragHandle(
modifier =
Modifier.paneExpansionDraggable(
state,
LocalMinimumInteractiveComponentSize.current,
interactionSource
), interactionSource = interactionSource
)
}
)
}
Expand Down Expand Up @@ -312,7 +328,7 @@ private fun DetailContent(
state,
animatedVisibilityScope = animatedVisibilityScope
)
}
}
} else {
Modifier
}
Expand Down
6 changes: 3 additions & 3 deletions CanonicalLayouts/list-detail-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
plugins {
id 'com.android.application' version '8.6.0' apply false
id 'com.android.library' version '8.6.0' apply false
id 'org.jetbrains.kotlin.android' version '2.0.0' apply false
id 'com.android.application' version '8.7.3' apply false
id 'com.android.library' version '8.7.3' apply false
id 'org.jetbrains.kotlin.android' version '2.0.20' apply false
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed May 25 14:11:15 UTC 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
20 changes: 10 additions & 10 deletions CanonicalLayouts/supporting-pane-compose/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id("org.jetbrains.kotlin.plugin.compose") version "2.0.0"
id("org.jetbrains.kotlin.plugin.compose") version "2.0.20"

}

Expand Down Expand Up @@ -68,19 +68,19 @@ composeCompiler {
}

dependencies {
def composeBom = platform('androidx.compose:compose-bom:2024.09.00')
def composeBom = platform('androidx.compose:compose-bom:2024.11.00')
implementation(composeBom)

implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.5'
implementation 'androidx.activity:activity-compose:1.9.2'
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'
implementation 'androidx.activity:activity-compose:1.9.3'
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation "androidx.window:window:1.3.0"
implementation 'androidx.compose.material3:material3:1.3.0'
implementation 'androidx.compose.material3.adaptive:adaptive:1.1.0-alpha02'
implementation 'androidx.compose.material3.adaptive:adaptive-layout:1.1.0-alpha02'
implementation 'androidx.compose.material3.adaptive:adaptive-navigation:1.1.0-alpha02'
implementation "androidx.compose.material3:material3-window-size-class:1.3.0"
implementation 'androidx.compose.material3:material3:1.4.0-alpha04'
implementation 'androidx.compose.material3.adaptive:adaptive:1.1.0-alpha07'
implementation 'androidx.compose.material3.adaptive:adaptive-layout:1.1.0-alpha07'
implementation 'androidx.compose.material3.adaptive:adaptive-navigation:1.1.0-alpha07'
implementation "androidx.compose.material3:material3-window-size-class:1.3.1"
testImplementation 'junit:junit:4.13.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,37 @@ package com.example.supportingpanecompose.ui

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.LocalMinimumInteractiveComponentSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.VerticalDragHandle
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
import androidx.compose.material3.adaptive.layout.AnimatedPane
import androidx.compose.material3.adaptive.layout.PaneExpansionDragHandle
import androidx.compose.material3.adaptive.layout.SupportingPaneScaffold
import androidx.compose.material3.adaptive.layout.SupportingPaneScaffoldRole
import androidx.compose.material3.adaptive.layout.rememberPaneExpansionState
import androidx.compose.material3.adaptive.navigation.rememberSupportingPaneScaffoldNavigator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.example.supportingpanecompose.R
import kotlinx.coroutines.launch

// Create some simple sample data
private val data = mapOf(
Expand All @@ -61,9 +65,12 @@ private val data = mapOf(
fun SupportingPaneSample() {
var selectedTopic: String by rememberSaveable { mutableStateOf(data.keys.first()) }
val navigator = rememberSupportingPaneScaffoldNavigator()
val scope = rememberCoroutineScope()

BackHandler(enabled = navigator.canNavigateBack()) {
navigator.navigateBack()
scope.launch {
navigator.navigateBack()
}
}

SupportingPaneScaffold(
Expand Down Expand Up @@ -92,7 +99,9 @@ fun SupportingPaneSample() {
.clickable {
selectedTopic = relatedTopic
if (navigator.canNavigateBack()) {
navigator.navigateBack()
scope.launch {
navigator.navigateBack()
}
}
}
) {
Expand Down Expand Up @@ -120,7 +129,9 @@ fun SupportingPaneSample() {
.fillMaxWidth()
.padding(all = 8.dp)
.clickable {
navigator.navigateTo(SupportingPaneScaffoldRole.Supporting)
scope.launch {
navigator.navigateTo(SupportingPaneScaffoldRole.Supporting)
}
},
contentAlignment = Alignment.Center
) {
Expand All @@ -134,6 +145,15 @@ fun SupportingPaneSample() {
},
paneExpansionState = rememberPaneExpansionState(navigator.scaffoldValue),
paneExpansionDragHandle = { state ->
PaneExpansionDragHandle(state, Color.Red)
val interactionSource =
remember { MutableInteractionSource() }
VerticalDragHandle(
modifier =
Modifier.paneExpansionDraggable(
state,
LocalMinimumInteractiveComponentSize.current,
interactionSource
), interactionSource = interactionSource
)
})
}
6 changes: 3 additions & 3 deletions CanonicalLayouts/supporting-pane-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
plugins {
id 'com.android.application' version '8.6.0' apply false
id 'com.android.library' version '8.6.0' apply false
id 'org.jetbrains.kotlin.android' version '2.0.0' apply false
id 'com.android.application' version '8.7.3' apply false
id 'com.android.library' version '8.7.3' apply false
id 'org.jetbrains.kotlin.android' version '2.0.20' apply false
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed May 25 14:11:15 UTC 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Loading