From 788f14dcac9f72a1a1871be528829926ff1d47ac Mon Sep 17 00:00:00 2001 From: Chiara Chiappini Date: Wed, 24 Jul 2024 14:42:49 +0100 Subject: [PATCH] Adds preview and breakpoint --- .../com/example/wear/snippets/list/List.kt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/wear/src/main/java/com/example/wear/snippets/list/List.kt b/wear/src/main/java/com/example/wear/snippets/list/List.kt index 0c73de7d..98cf8d18 100644 --- a/wear/src/main/java/com/example/wear/snippets/list/List.kt +++ b/wear/src/main/java/com/example/wear/snippets/list/List.kt @@ -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 @@ -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() +}