Skip to content

Commit

Permalink
Merge pull request #298 from android/wear
Browse files Browse the repository at this point in the history
Updates for  "Developer for different screen sizes pages" on Wear
  • Loading branch information
kul3r4 authored Jul 25, 2024
2 parents 783f5c8 + 788f14d commit 5d3421c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions wear/src/main/java/com/example/wear/snippets/list/List.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.example.wear.snippets.list
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Build
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalConfiguration
import androidx.wear.compose.material.Text
import androidx.wear.compose.ui.tooling.preview.WearPreviewDevices
import androidx.wear.compose.ui.tooling.preview.WearPreviewFontScales
Expand Down Expand Up @@ -102,9 +103,38 @@ fun SnapAndFlingComposeList() {
// [END android_wear_snap]
}

// [START android_wear_list_breakpoint]
const val LARGE_DISPLAY_BREAKPOINT = 225

@Composable
fun isLargeDisplay() = LocalConfiguration.current.screenWidthDp >= LARGE_DISPLAY_BREAKPOINT
// [START_EXCLUDE]
@Composable
fun breakpointDemo() {
// [END_EXCLUDE]
// ... use in your Composables:
if (isLargeDisplay()) {
// Show additional content.
} else {
// Show content only for smaller displays.
}
// [START_EXCLUDE]
}
// [END_EXCLUDE]
// [END android_wear_list_breakpoint]

// [START android_wear_list_preview]
@WearPreviewDevices
@WearPreviewFontScales
@Composable
fun ComposeListPreview() {
ComposeList()
}
// [END android_wear_list_preview]

@WearPreviewDevices
@WearPreviewFontScales
@Composable
fun SnapAndFlingComposeListPreview() {
SnapAndFlingComposeList()
}

0 comments on commit 5d3421c

Please sign in to comment.