-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bebe7d
commit 73ca641
Showing
2 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
JetCatalogCompose/app/src/main/java/com/google/jetcatalog/ChipsScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package com.google.jetcatalog | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Check | ||
import androidx.compose.material.icons.filled.Clear | ||
import androidx.compose.material.icons.filled.Close | ||
import androidx.compose.material.icons.filled.Edit | ||
import androidx.compose.material.icons.filled.Favorite | ||
import androidx.compose.material.icons.filled.Settings | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import androidx.tv.material3.AssistChip | ||
import androidx.tv.material3.Button | ||
import androidx.tv.material3.ButtonDefaults | ||
import androidx.tv.material3.ExperimentalTvMaterial3Api | ||
import androidx.tv.material3.FilterChip | ||
import androidx.tv.material3.Icon | ||
import androidx.tv.material3.IconButton | ||
import androidx.tv.material3.IconButtonDefaults | ||
import androidx.tv.material3.InputChip | ||
import androidx.tv.material3.OutlinedButton | ||
import androidx.tv.material3.OutlinedButtonDefaults | ||
import androidx.tv.material3.OutlinedIconButton | ||
import androidx.tv.material3.OutlinedIconButtonDefaults | ||
import androidx.tv.material3.SuggestionChip | ||
import androidx.tv.material3.Text | ||
import androidx.tv.material3.WideButton | ||
|
||
@OptIn(ExperimentalTvMaterial3Api::class) | ||
@Composable | ||
fun ChipsScreen() { | ||
val actions = listOf( | ||
ExampleAction( | ||
title = "Assist Chip", | ||
content = { | ||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(20.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
AssistChip(onClick = { }) { | ||
Text(text = "Label") | ||
} | ||
|
||
AssistChip( | ||
onClick = { }, | ||
leadingIcon = editIcon | ||
) { | ||
Text(text = "Label") | ||
} | ||
} | ||
} | ||
), | ||
ExampleAction( | ||
title = "Filter Chip", | ||
content = { | ||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(20.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
var isSelected1 by remember { mutableStateOf(false) } | ||
FilterChip( | ||
selected = isSelected1, | ||
onClick = { isSelected1 = !isSelected1 } | ||
) { | ||
Text(text = "Label") | ||
} | ||
|
||
var isSelected2 by remember { mutableStateOf(false) } | ||
FilterChip( | ||
selected = isSelected2, | ||
onClick = { isSelected2 = !isSelected2 }, | ||
leadingIcon = checkIcon | ||
) { | ||
Text(text = "Label") | ||
} | ||
} | ||
} | ||
), | ||
ExampleAction( | ||
title = "Input Chip", | ||
content = { | ||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(20.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
var isSelected1 by remember { mutableStateOf(false) } | ||
InputChip( | ||
selected = isSelected1, | ||
onClick = { isSelected1 = !isSelected1 } | ||
) { | ||
Text(text = "Label") | ||
} | ||
|
||
var isSelected2 by remember { mutableStateOf(false) } | ||
InputChip( | ||
selected = isSelected2, | ||
onClick = { isSelected2 = !isSelected2 }, | ||
leadingIcon = editIcon, | ||
trailingIcon = clearIcon | ||
) { | ||
Text(text = "Label") | ||
} | ||
} | ||
} | ||
), | ||
ExampleAction( | ||
title = "Suggestion Chip", | ||
content = { | ||
SuggestionChip(onClick = { }) { | ||
Text(text = "Label") | ||
} | ||
} | ||
), | ||
) | ||
|
||
ExamplesScreenWithDottedBackground(actions) | ||
} | ||
|
||
@OptIn(ExperimentalTvMaterial3Api::class) | ||
private val editIcon = @Composable { | ||
Icon( | ||
imageVector = Icons.Default.Edit, | ||
contentDescription = "Edit icon", | ||
) | ||
} | ||
|
||
@OptIn(ExperimentalTvMaterial3Api::class) | ||
private val checkIcon = @Composable { | ||
Icon( | ||
imageVector = Icons.Default.Check, | ||
contentDescription = "Check icon", | ||
) | ||
} | ||
|
||
@OptIn(ExperimentalTvMaterial3Api::class) | ||
private val clearIcon = @Composable { | ||
Icon( | ||
imageVector = Icons.Default.Clear, | ||
contentDescription = "Clear icon", | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters