Skip to content

Commit

Permalink
Sample screen for Cards (#2044)
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke authored Feb 19, 2024
1 parent 2416bf8 commit 3cd19c8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material.MaterialTheme
import androidx.wear.compose.material.Text
import androidx.wear.compose.ui.tooling.preview.WearPreviewDevices
import com.google.android.horologist.compose.layout.ScalingLazyColumn
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.google.android.horologist.compose.layout.rememberColumnState
import com.google.android.horologist.compose.material.Card

@Preview
@WearPreviewDevices
@Composable
fun SampleCardScreenPreview() {
val state = rememberColumnState()
Expand All @@ -47,14 +47,24 @@ internal fun SampleCardScreen(
modifier = modifier,
columnState = columnState,
) {
item {
Card(
onClick = { println("Click") },
onLongClick = { println("LongClick") },
onDoubleClick = { println("DoubleClick") },
enabled = false,
) {
Text("Hello\nCard")
}
}
item {
Card(
onClick = { println("Click") },
onLongClick = { println("LongClick") },
onDoubleClick = { println("DoubleClick") },
modifier = Modifier.background(Color.Cyan),
) {
Text("Hello, Card")
Text("Hello\nCard")
}
}
item {
Expand All @@ -65,7 +75,7 @@ internal fun SampleCardScreen(
modifier = Modifier.background(Color.Cyan),
shape = MaterialTheme.shapes.medium,
) {
Text("Hello, Card")
Text("Hello\nCard")
}
}
item {
Expand All @@ -75,7 +85,7 @@ internal fun SampleCardScreen(
onDoubleClick = { println("DoubleClick") },
backgroundPainter = painterResource(id = android.R.drawable.ic_dialog_alert),
) {
Text("Hello, Card")
Text("Hello\nCard")
}
}
item {
Expand All @@ -85,7 +95,7 @@ internal fun SampleCardScreen(
onDoubleClick = { println("DoubleClick") },
contentPadding = PaddingValues(24.dp),
) {
Text("Hello, Card")
Text("Hello\nCard")
}
}
item {
Expand All @@ -95,7 +105,7 @@ internal fun SampleCardScreen(
onDoubleClick = { println("DoubleClick") },
contentColor = MaterialTheme.colors.primaryVariant,
) {
Text("Hello, Card")
Text("Hello\nCard")
}
}
item {
Expand All @@ -105,7 +115,7 @@ internal fun SampleCardScreen(
onDoubleClick = { println("DoubleClick") },
enabled = false,
) {
Text("Hello, Card")
Text("Hello\nCard")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ fun MenuScreen(
onClick = { navigateToRoute(Screen.MaterialButtonsScreen.route) },
)
}
item {
Chip(
label = stringResource(id = R.string.sample_material_cards),
modifier = modifier.fillMaxWidth(),
onClick = { navigateToRoute(Screen.MaterialCardsScreen.route) },
)
}
item {
Chip(
label = stringResource(id = R.string.sample_material_chips),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.google.android.horologist.compose.layout.ScreenScaffold
import com.google.android.horologist.compose.layout.rememberColumnState
import com.google.android.horologist.materialcomponents.SampleAlertDialog
import com.google.android.horologist.materialcomponents.SampleButtonScreen
import com.google.android.horologist.materialcomponents.SampleCardScreen
import com.google.android.horologist.materialcomponents.SampleChipIconWithProgressScreen
import com.google.android.horologist.materialcomponents.SampleChipScreen
import com.google.android.horologist.materialcomponents.SampleCompactChipScreen
Expand Down Expand Up @@ -218,6 +219,15 @@ fun SampleWearApp() {
SampleButtonScreen(columnState = columnState)
}
}
composable(
route = Screen.MaterialCardsScreen.route,
) {
val columnState = rememberColumnState()

ScreenScaffold(scrollState = columnState) {
SampleCardScreen(columnState = columnState)
}
}
composable(
route = Screen.MaterialChipsScreen.route,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ sealed class Screen(

object MaterialAlertDialog : Screen("materialAlertDialog")
object MaterialButtonsScreen : Screen("materialButtonsScreen")
object MaterialCardsScreen : Screen("materialCardsScreen")
object MaterialChipsScreen : Screen("materialChipsScreen")
object MaterialChipIconWithProgressScreen : Screen("materialChipIconWithProgressScreen")
object MaterialCompactChipsScreen : Screen("materialCompactChips")
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@
<string name="pager_screen_chip_label">Pager Screen</string>
<string name="pager_screen_chip_content_description">Pager Screen</string>
<string name="vertical_pager_screen_chip_content_description">Vertical Pager Screen</string>
<string name="sample_material_cards">Material Cards Screen</string>
</resources>

0 comments on commit 3cd19c8

Please sign in to comment.