Skip to content

Commit 70558b1

Browse files
committed
Adds preview and breakpoint
1 parent 010a9f1 commit 70558b1

File tree

1 file changed

+29
-0
lines changed
  • wear/src/main/java/com/example/wear/snippets/list

1 file changed

+29
-0
lines changed

wear/src/main/java/com/example/wear/snippets/list/List.kt

+29
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.example.wear.snippets.list
1818
import androidx.compose.material.icons.Icons
1919
import androidx.compose.material.icons.filled.Build
2020
import androidx.compose.runtime.Composable
21+
import androidx.compose.ui.platform.LocalConfiguration
2122
import androidx.wear.compose.material.Text
2223
import androidx.wear.compose.ui.tooling.preview.WearPreviewDevices
2324
import androidx.wear.compose.ui.tooling.preview.WearPreviewFontScales
@@ -102,9 +103,37 @@ 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+
fun breakpointDemo() {
113+
// [END_EXCLUDE]
114+
// ... use in your Composables:
115+
if (isLargeDisplay()) {
116+
// Show additional content.
117+
} else {
118+
// Show content only for smaller displays.
119+
}
120+
// [START_EXCLUDE]
121+
}
122+
// [END_EXCLUDE]
123+
// [END android_wear_list_breakpoint]
124+
125+
// [START android_wear_list_preview]
105126
@WearPreviewDevices
106127
@WearPreviewFontScales
107128
@Composable
108129
fun ComposeListPreview() {
109130
ComposeList()
110131
}
132+
// [END android_wear_list_preview]
133+
134+
@WearPreviewDevices
135+
@WearPreviewFontScales
136+
@Composable
137+
fun SnapAndFlingComposeListPreview() {
138+
SnapAndFlingComposeList()
139+
}

0 commit comments

Comments
 (0)