|
16 | 16 |
|
17 | 17 | package com.example.wear.snippets.m3.list |
18 | 18 |
|
| 19 | +import androidx.compose.foundation.layout.fillMaxWidth |
19 | 20 | import androidx.compose.material.icons.Icons |
20 | 21 | import androidx.compose.material.icons.filled.Build |
21 | 22 | import androidx.compose.runtime.Composable |
| 23 | +import androidx.compose.ui.Modifier |
22 | 24 | import androidx.compose.ui.platform.LocalConfiguration |
23 | | -import androidx.wear.compose.material.Text |
| 25 | +import androidx.compose.ui.text.style.TextOverflow |
| 26 | +import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState |
24 | 27 | import androidx.wear.compose.ui.tooling.preview.WearPreviewDevices |
25 | 28 | import androidx.wear.compose.ui.tooling.preview.WearPreviewFontScales |
26 | 29 | import com.google.android.horologist.annotations.ExperimentalHorologistApi |
| 30 | +import com.google.android.horologist.compose.layout.ColumnItemType |
| 31 | +import com.google.android.horologist.compose.layout.rememberResponsiveColumnPadding |
| 32 | +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState |
| 33 | +import androidx.wear.compose.material3.ListHeader |
| 34 | +import androidx.wear.compose.material3.ScreenScaffold |
| 35 | +import androidx.wear.compose.foundation.lazy.TransformingLazyColumn |
| 36 | +import androidx.wear.compose.material3.Icon |
27 | 37 | import com.google.android.horologist.compose.layout.ScalingLazyColumn |
28 | 38 | import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults |
29 | 39 | import com.google.android.horologist.compose.layout.ScalingLazyColumnState |
30 | 40 | import com.google.android.horologist.compose.layout.ScreenScaffold |
31 | | -import com.google.android.horologist.compose.layout.rememberResponsiveColumnState |
32 | 41 | import com.google.android.horologist.compose.material.Button |
33 | 42 | import com.google.android.horologist.compose.material.ListHeaderDefaults.firstItemPadding |
34 | 43 | import com.google.android.horologist.compose.material.ResponsiveListHeader |
| 44 | +import androidx.wear.compose.material3.Button |
| 45 | +import androidx.wear.compose.material3.SurfaceTransformation |
| 46 | +import androidx.wear.compose.material3.lazy.rememberTransformationSpec |
| 47 | +import androidx.wear.compose.material3.lazy.transformedHeight |
| 48 | +import androidx.wear.compose.material3.Text |
35 | 49 |
|
36 | | -@OptIn(ExperimentalHorologistApi::class) |
37 | 50 | @Composable |
38 | 51 | fun ComposeList() { |
39 | 52 | // [START android_wear_list] |
40 | | - val columnState = rememberResponsiveColumnState( |
41 | | - contentPadding = ScalingLazyColumnDefaults.padding( |
42 | | - first = ScalingLazyColumnDefaults.ItemType.Text, |
43 | | - last = ScalingLazyColumnDefaults.ItemType.SingleButton |
44 | | - ) |
| 53 | + val columnState = rememberTransformingLazyColumnState() |
| 54 | + val contentPadding = rememberResponsiveColumnPadding( |
| 55 | + first = ColumnItemType.ListHeader, |
| 56 | + last = ColumnItemType.Button, |
45 | 57 | ) |
46 | | - ScreenScaffold(scrollState = columnState) { |
47 | | - ScalingLazyColumn( |
48 | | - columnState = columnState |
| 58 | + val transformationSpec = rememberTransformationSpec() |
| 59 | + ScreenScaffold(scrollState = columnState, |
| 60 | + contentPadding = contentPadding) { contentPadding -> |
| 61 | + TransformingLazyColumn( |
| 62 | + state = columnState, |
| 63 | + contentPadding = contentPadding |
49 | 64 | ) { |
50 | 65 | item { |
51 | | - ResponsiveListHeader(contentPadding = firstItemPadding()) { |
| 66 | + ListHeader(modifier = Modifier.fillMaxWidth().transformedHeight(this, transformationSpec), |
| 67 | + transformation = SurfaceTransformation(transformationSpec)){ |
52 | 68 | Text(text = "Header") |
53 | 69 | } |
54 | 70 | } |
55 | 71 | // ... other items |
56 | 72 | item { |
57 | | - Button( |
58 | | - imageVector = Icons.Default.Build, |
59 | | - contentDescription = "Example Button", |
60 | | - onClick = { } |
61 | | - ) |
| 73 | + Button(modifier = Modifier.fillMaxWidth().transformedHeight(this, transformationSpec), |
| 74 | + transformation = SurfaceTransformation(transformationSpec), |
| 75 | + onClick = { /* ... */ }, |
| 76 | + icon = { |
| 77 | + Icon( |
| 78 | + imageVector = Icons.Default.Build, |
| 79 | + contentDescription = "build", |
| 80 | + ) |
| 81 | + }, |
| 82 | + ){ |
| 83 | + Text( |
| 84 | + text = "Build", |
| 85 | + maxLines = 1, |
| 86 | + overflow = TextOverflow.Ellipsis, |
| 87 | + ) |
| 88 | + } |
| 89 | + |
62 | 90 | } |
63 | 91 | } |
64 | 92 | } |
@@ -87,7 +115,7 @@ fun SnapAndFlingComposeList() { |
87 | 115 | // [START_EXCLUDE] |
88 | 116 | item { |
89 | 117 | ResponsiveListHeader(contentPadding = firstItemPadding()) { |
90 | | - Text(text = "Header") |
| 118 | + androidx.wear.compose.material.Text(text = "Header") |
91 | 119 | } |
92 | 120 | } |
93 | 121 | // ... other items |
|
0 commit comments