Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.compose.snippets.adaptivelayouts

import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material3.Text
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffold
import androidx.compose.material3.adaptive.layout.SupportingPaneScaffold
import androidx.compose.material3.adaptive.navigation.rememberListDetailPaneScaffoldNavigator
import androidx.compose.material3.adaptive.navigation.rememberSupportingPaneScaffoldNavigator
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp


// [START android_compose_canonical_layouts_sample_my_feed]
@Composable
fun MyFeed(names: List<String>) {
LazyVerticalGrid(
// GridCells.Adaptive automatically adapts column count based on available width
columns = GridCells.Adaptive(minSize = 180.dp),
) {
items(names) { name ->
Text(name)
}
}
}
// [END android_compose_canonical_layouts_sample_my_feed]


@OptIn(ExperimentalMaterial3AdaptiveApi::class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: move the start of the region tag up one line. The @OptIn annotation is required to use the adaptive APIs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below.

// [START android_compose_canonical_layouts_list_detail_pane_scaffold]
@Composable
fun MyListDetailPaneScaffold() {
val navigator = rememberListDetailPaneScaffoldNavigator()
ListDetailPaneScaffold(
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
listPane = {
// Listing Pane
},
detailPane = {
// Details Pane
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: this sample doesn't include a navigate to handler nor a close/dismiss button w/ event handler.

}
)
}
// [END android_compose_canonical_layouts_list_detail_pane_scaffold]

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
// [START android_compose_canonical_layouts_supporting_pane_scaffold]
@Composable
fun MySupportingPaneScaffold() {
// Creates and remembers a navigator to control pane visibility and navigation
val navigator = rememberSupportingPaneScaffoldNavigator()
SupportingPaneScaffold(
// Directive and value help control pane visibility based on screen size and state
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
mainPane = {
// Main Pane for the primary content
},
supportingPane = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to previous: show how to navigate to this pane and how to dismiss it.

Question: why use SupportingPaneScaffold rather than NavigableSupportingPaneScaffold?

//Supporting Pane for supplementary content
}
)
}
// [END android_compose_canonical_layouts_supporting_pane_scaffold]
Loading