File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
wear/src/main/java/com/example/wear/snippets/list Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package com.example.wear.snippets.list
1818import androidx.compose.material.icons.Icons
1919import androidx.compose.material.icons.filled.Build
2020import androidx.compose.runtime.Composable
21+ import androidx.compose.ui.platform.LocalConfiguration
2122import androidx.wear.compose.material.Text
2223import androidx.wear.compose.ui.tooling.preview.WearPreviewDevices
2324import androidx.wear.compose.ui.tooling.preview.WearPreviewFontScales
@@ -102,9 +103,38 @@ fun SnapAndFlingComposeList() {
102103 // [END android_wear_snap]
103104}
104105
106+ // [START android_wear_list_breakpoint]
107+ const val LARGE_DISPLAY_BREAKPOINT = 225
108+
109+ @Composable
110+ fun isLargeDisplay () = LocalConfiguration .current.screenWidthDp >= LARGE_DISPLAY_BREAKPOINT
111+ // [START_EXCLUDE]
112+ @Composable
113+ fun breakpointDemo () {
114+ // [END_EXCLUDE]
115+ // ... use in your Composables:
116+ if (isLargeDisplay()) {
117+ // Show additional content.
118+ } else {
119+ // Show content only for smaller displays.
120+ }
121+ // [START_EXCLUDE]
122+ }
123+ // [END_EXCLUDE]
124+ // [END android_wear_list_breakpoint]
125+
126+ // [START android_wear_list_preview]
105127@WearPreviewDevices
106128@WearPreviewFontScales
107129@Composable
108130fun ComposeListPreview () {
109131 ComposeList ()
110132}
133+ // [END android_wear_list_preview]
134+
135+ @WearPreviewDevices
136+ @WearPreviewFontScales
137+ @Composable
138+ fun SnapAndFlingComposeListPreview () {
139+ SnapAndFlingComposeList ()
140+ }
You can’t perform that action at this time.
0 commit comments