Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
31b4de2
Added two snippets for showcasing how to do Masking and Clipping in C…
riggaroo Oct 2, 2024
d1e297b
🤖 Update Dependencies (#366)
compose-devrel-github-bot Oct 3, 2024
0c9024b
Add Material Carousel (#363)
riggaroo Oct 3, 2024
68fef6e
Basic menu examples (#371)
jakeroseman Oct 11, 2024
fbfd07d
Filter chip dropdown menu (#375)
JolandaVerhoef Oct 11, 2024
f67b849
Add example of date picker textfield opening picker dialog on click (…
JolandaVerhoef Oct 11, 2024
a0b94c0
Add auto advance pager snippets (#377)
jakeroseman Oct 11, 2024
591dfa5
Tooltip component examples (#373)
jakeroseman Oct 11, 2024
4baf477
Add pull to refresh snippets (#378)
JolandaVerhoef Oct 11, 2024
5545f37
Remove LaunchedEffect workaround (#379)
jakeroseman Oct 14, 2024
90b8500
Navigation drawer examples (#380)
jakeroseman Oct 14, 2024
e9116f5
Snippets for keyboard input (#368)
chikoski Oct 16, 2024
2af26d9
Snippet for animated sorted list with add/remove buttons. (#381)
jakeroseman Oct 16, 2024
514653c
Add basic segmented button examples (#383)
jakeroseman Oct 24, 2024
5ccd4a8
Adding views snippets module with Generated Preview samples (#384)
secondsun Oct 28, 2024
195bd61
Adding top bar multi selection examples (#387)
jakeroseman Oct 29, 2024
d081491
Include AppScaffold in navigation Snippet (#385)
kul3r4 Oct 31, 2024
81c1a2a
Animate image size on scroll (#390)
jakeroseman Nov 5, 2024
1da22a0
Add basic HTML text styling example (#389)
jakeroseman Nov 5, 2024
f595a0d
🤖 Update Dependencies (#391)
compose-devrel-github-bot Nov 6, 2024
f4e4987
add in predictive back snippets for NavHost and predictive back handl…
trambui09 Nov 21, 2024
515b08e
Add region tags to auto advance pager examples (#398)
jakeroseman Nov 27, 2024
fb654a9
Init Wear Tiles snippets (#400)
ithinkihaveacat Nov 27, 2024
c699e70
Create misc module, add broadcast receiver snippets (#397)
JolandaVerhoef Nov 28, 2024
6f61cb5
Add live search with FilterTextView example (#402)
jakeroseman Dec 4, 2024
0d07b08
Add single option radio button example (#401)
jakeroseman Dec 4, 2024
c79a414
update to use type safe routes (#399)
trambui09 Dec 6, 2024
273d399
Migrated relevant MotionCompose snippets into snippets (#411)
riggaroo Dec 9, 2024
82573fd
Moving location permissions snippets to repo (#413)
jakeroseman Dec 9, 2024
6dc5a0a
Use VerticalDivider in IntrinsicSnippets (#369)
DavidMendozaMartinez Dec 10, 2024
41b6a64
Add an example of Shared elements that are seekable using SeekableTra…
riggaroo Dec 10, 2024
22976bd
🤖 Update Dependencies (#427)
compose-devrel-github-bot Dec 19, 2024
e6997d9
Adding SearchBar examples (#408)
jakeroseman Dec 20, 2024
5bf449b
Add Swipe to reveal examples (#412)
jakeroseman Dec 20, 2024
14b6384
Add example usage of keyframesWithSplines (#430)
riggaroo Jan 6, 2025
716dfe1
Update Advanced Focus Snippets to remove Deprecations (#432)
tiwiz Jan 7, 2025
b9c07aa
Replaced deprecated WindowHeightSizeClass with isHeightAtLeastBreakpo…
JonEckenrode Jan 7, 2025
83ae63d
🤖 Update Dependencies (#440)
compose-devrel-github-bot Jan 23, 2025
36d1904
Update M3SupportScaffoldSnippet (#441)
ashnohe Jan 24, 2025
a7117c0
🤖 Update Dependencies (#446)
compose-devrel-github-bot Jan 30, 2025
1eec3c8
Downgrade Tiles snippets to use stable versions (#448)
ithinkihaveacat Feb 10, 2025
724b5e6
update adaptive layouts samples to navigable scaffolds (#449)
trambui09 Feb 11, 2025
d2ccac0
Revert "update adaptive layouts samples to navigable scaffolds (#449)…
trambui09 Feb 12, 2025
70b9ce1
update adaptive snippets to have navigable scaffolds implementation
trambui09 Feb 14, 2025
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
11 changes: 7 additions & 4 deletions .github/workflows/apply_spotless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ jobs:
- name: Run spotlessApply
run: ./gradlew :compose:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

- name: Run spotlessApply for Wear
run: ./gradlew :wear:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

- name: Run spotlessApply for Misc
run: ./gradlew :misc:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

- name: Auto-commit if spotlessApply has changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply Spotless

- name: Run spotlessApply for Wear
run: ./gradlew :wear:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace
commit_message: Apply Spotless
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ jobs:
run: ./gradlew :kotlin:build
- name: Build Wear snippets
run: ./gradlew :wear:build
- name: Build misc snippets
run: ./gradlew :misc:build
1 change: 1 addition & 0 deletions compose/snippets/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:enableOnBackInvokedCallback="true"
android:theme="@style/Theme.Snippets">
<!-- [START android_compose_pip_manifest_entry]-->
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.example.compose.snippets

import NavigationDrawerExamples
import android.os.Bundle
import android.os.StrictMode
import androidx.activity.ComponentActivity
Expand All @@ -33,24 +34,31 @@ import com.example.compose.snippets.components.AppBarExamples
import com.example.compose.snippets.components.BadgeExamples
import com.example.compose.snippets.components.ButtonExamples
import com.example.compose.snippets.components.CardExamples
import com.example.compose.snippets.components.CarouselExamples
import com.example.compose.snippets.components.CheckboxExamples
import com.example.compose.snippets.components.ChipExamples
import com.example.compose.snippets.components.ComponentsScreen
import com.example.compose.snippets.components.DatePickerExamples
import com.example.compose.snippets.components.DialogExamples
import com.example.compose.snippets.components.DividerExamples
import com.example.compose.snippets.components.FloatingActionButtonExamples
import com.example.compose.snippets.components.MenusExamples
import com.example.compose.snippets.components.PartialBottomSheet
import com.example.compose.snippets.components.ProgressIndicatorExamples
import com.example.compose.snippets.components.ScaffoldExample
import com.example.compose.snippets.components.SearchBarExamples
import com.example.compose.snippets.components.SegmentedButtonExamples
import com.example.compose.snippets.components.SliderExamples
import com.example.compose.snippets.components.SwipeToDismissBoxExamples
import com.example.compose.snippets.components.SwitchExamples
import com.example.compose.snippets.components.TimePickerExamples
import com.example.compose.snippets.components.TooltipExamples
import com.example.compose.snippets.graphics.ApplyPolygonAsClipImage
import com.example.compose.snippets.graphics.BitmapFromComposableFullSnippet
import com.example.compose.snippets.graphics.BrushExamplesScreen
import com.example.compose.snippets.images.ImageExamplesScreen
import com.example.compose.snippets.landing.LandingScreen
import com.example.compose.snippets.layouts.PagerExamples
import com.example.compose.snippets.navigation.Destination
import com.example.compose.snippets.navigation.TopComponentsDestination
import com.example.compose.snippets.ui.theme.SnippetsTheme
Expand Down Expand Up @@ -85,6 +93,7 @@ class SnippetsActivity : ComponentActivity() {
}
Destination.ShapesExamples -> ApplyPolygonAsClipImage()
Destination.SharedElementExamples -> PlaceholderSizeAnimated_Demo()
Destination.PagerExamples -> PagerExamples()
}
}
}
Expand All @@ -109,6 +118,13 @@ class SnippetsActivity : ComponentActivity() {
TopComponentsDestination.PartialBottomSheet -> PartialBottomSheet()
TopComponentsDestination.TimePickerExamples -> TimePickerExamples()
TopComponentsDestination.DatePickerExamples -> DatePickerExamples()
TopComponentsDestination.CarouselExamples -> CarouselExamples()
TopComponentsDestination.MenusExample -> MenusExamples()
TopComponentsDestination.TooltipExamples -> TooltipExamples()
TopComponentsDestination.NavigationDrawerExamples -> NavigationDrawerExamples()
TopComponentsDestination.SegmentedButtonExamples -> SegmentedButtonExamples()
TopComponentsDestination.SwipeToDismissBoxExamples -> SwipeToDismissBoxExamples()
TopComponentsDestination.SearchBarExamples -> SearchBarExamples()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.example.compose.snippets.adaptivelayouts

import android.os.Parcelable
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
Expand All @@ -30,33 +29,38 @@ import androidx.compose.material3.Card
import androidx.compose.material3.ListItem
import androidx.compose.material3.Text
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
import androidx.compose.material3.adaptive.WindowAdaptiveInfo
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.PaneScaffoldDirective
import androidx.compose.material3.adaptive.navigation.BackNavigationBehavior
import androidx.compose.material3.adaptive.navigation.NavigableListDetailPaneScaffold
import androidx.compose.material3.adaptive.navigation.ThreePaneScaffoldPredictiveBackHandler
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 androidx.window.core.layout.WindowWidthSizeClass
import kotlinx.coroutines.launch
import kotlinx.parcelize.Parcelize

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Composable
fun SampleListDetailPaneScaffoldParts() {
fun SampleNavigableListDetailPaneScaffoldParts() {
// [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part02]
val navigator = rememberListDetailPaneScaffoldNavigator<MyItem>()

BackHandler(navigator.canNavigateBack()) {
navigator.navigateBack()
}
val scaffoldNavigator = rememberListDetailPaneScaffoldNavigator<MyItem>()
val scope = rememberCoroutineScope()
// [END android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part02]

// [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part03]
ListDetailPaneScaffold(
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
NavigableListDetailPaneScaffold(
navigator = scaffoldNavigator,
// [START_EXCLUDE]
listPane = {},
detailPane = {},
Expand All @@ -65,16 +69,21 @@ fun SampleListDetailPaneScaffoldParts() {
// [END android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part03]

// [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part04]
ListDetailPaneScaffold(
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
NavigableListDetailPaneScaffold(
navigator = scaffoldNavigator,
listPane = {
AnimatedPane {
MyList(
onItemClick = { item ->
// Navigate to the detail pane with the passed item
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item)
}
scope.launch {
scaffoldNavigator
.navigateTo(
ListDetailPaneScaffoldRole.Detail,
item
)
}
},
)
}
},
Expand All @@ -85,16 +94,14 @@ fun SampleListDetailPaneScaffoldParts() {
// [END android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part04]

// [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_part05]
ListDetailPaneScaffold(
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
listPane =
NavigableListDetailPaneScaffold(
navigator = scaffoldNavigator,
// [START_EXCLUDE]
{},
listPane = {},
// [END_EXCLUDE]
detailPane = {
AnimatedPane {
navigator.currentDestination?.content?.let {
scaffoldNavigator.currentDestination?.contentKey?.let {
MyDetails(it)
}
}
Expand All @@ -106,39 +113,100 @@ fun SampleListDetailPaneScaffoldParts() {
@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Preview
@Composable
fun SampleListDetailPaneScaffoldFull() {
// [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_full]
val navigator = rememberListDetailPaneScaffoldNavigator<MyItem>()
fun SampleNavigableListDetailPaneScaffoldFull() {
// [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_full]
val scaffoldNavigator = rememberListDetailPaneScaffoldNavigator<MyItem>()
val scope = rememberCoroutineScope()

BackHandler(navigator.canNavigateBack()) {
navigator.navigateBack()
}
NavigableListDetailPaneScaffold(
navigator = scaffoldNavigator,
listPane = {
AnimatedPane {
MyList(
onItemClick = { item ->
// Navigate to the detail pane with the passed item
scope.launch {
scaffoldNavigator.navigateTo(
ListDetailPaneScaffoldRole.Detail,
item
)
}
},
)
}
},
detailPane = {
AnimatedPane {
// Show the detail pane content if selected item is available
scaffoldNavigator.currentDestination?.contentKey?.let {
MyDetails(it)
}
}
},
)
// [END android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_full]
}

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Composable
fun SampleListDetailPaneScaffoldWithPredictiveBackFull() {
// [START android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_with_pb_full]
val scaffoldNavigator = rememberListDetailPaneScaffoldNavigator<MyItem>()
val customScaffoldDirective = customPaneScaffoldDirective(currentWindowAdaptiveInfo())
val scope = rememberCoroutineScope()

ThreePaneScaffoldPredictiveBackHandler(
navigator = scaffoldNavigator,
backBehavior = BackNavigationBehavior.PopUntilContentChange
)

ListDetailPaneScaffold(
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
directive = customScaffoldDirective,
scaffoldState = scaffoldNavigator.scaffoldState,
listPane = {
AnimatedPane {
MyList(
onItemClick = { item ->
// Navigate to the detail pane with the passed item
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item)
scope.launch {
scaffoldNavigator.navigateTo(
ListDetailPaneScaffoldRole.Detail,
item
)
}
},
)
}
},
detailPane = {
AnimatedPane {
// Show the detail pane content if selected item is available
navigator.currentDestination?.content?.let {
scaffoldNavigator.currentDestination?.contentKey?.let {
MyDetails(it)
}
}
},
)
// [END android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_full]
}

fun customPaneScaffoldDirective(currentWindowAdaptiveInfo: WindowAdaptiveInfo): PaneScaffoldDirective {
val horizontalPartitions =
when (currentWindowAdaptiveInfo.windowSizeClass.windowWidthSizeClass) {
WindowWidthSizeClass.COMPACT -> 1
WindowWidthSizeClass.MEDIUM -> 2
else -> 3
}

return PaneScaffoldDirective(
maxHorizontalPartitions = horizontalPartitions,
horizontalPartitionSpacerSize = 16.dp,
maxVerticalPartitions = 1,
verticalPartitionSpacerSize = 8.dp,
defaultPanePreferredWidth = 320.dp,
excludedBounds = emptyList()
)
}
// [END android_compose_adaptivelayouts_sample_list_detail_pane_scaffold_with_pb_full]
@Composable
fun MyList(
onItemClick: (MyItem) -> Unit,
Expand Down
Loading