Skip to content

Commit 5d3421c

Browse files
authored
Merge pull request #298 from android/wear
Updates for "Developer for different screen sizes pages" on Wear
2 parents 783f5c8 + 788f14d commit 5d3421c

File tree

1 file changed

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

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
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,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
108130
fun ComposeListPreview() {
109131
ComposeList()
110132
}
133+
// [END android_wear_list_preview]
134+
135+
@WearPreviewDevices
136+
@WearPreviewFontScales
137+
@Composable
138+
fun SnapAndFlingComposeListPreview() {
139+
SnapAndFlingComposeList()
140+
}

0 commit comments

Comments
 (0)