Skip to content

Commit

Permalink
Update Supporting Pane to latest Material 3 alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Orgiu committed Dec 5, 2024
1 parent ae7c8cf commit eeb3e9a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
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

0 comments on commit eeb3e9a

Please sign in to comment.