From 652e80ee7cf21f2e5c089839dd6655400d1515b7 Mon Sep 17 00:00:00 2001 From: Yongshun Shreck Ye Date: Thu, 26 Dec 2024 21:44:30 +0800 Subject: [PATCH] Remove the content in the Material 2 demo to reproduce the bug in commit fb269bdfa876bc63402c68a025325f42b8a8abec and report it Chromium at https://issues.chromium.org/issues/386052671 --- .../compose/material/demo/Material2.kt | 133 ++---------------- 1 file changed, 8 insertions(+), 125 deletions(-) diff --git a/demo/src/commonMain/kotlin/com/huanshankeji/compose/material/demo/Material2.kt b/demo/src/commonMain/kotlin/com/huanshankeji/compose/material/demo/Material2.kt index fd0c409..7858c8b 100644 --- a/demo/src/commonMain/kotlin/com/huanshankeji/compose/material/demo/Material2.kt +++ b/demo/src/commonMain/kotlin/com/huanshankeji/compose/material/demo/Material2.kt @@ -1,31 +1,17 @@ package com.huanshankeji.compose.material.demo -import androidx.compose.runtime.* -import androidx.compose.ui.unit.dp +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import com.huanshankeji.compose.foundation.VerticalScrollBox -import com.huanshankeji.compose.foundation.background -import com.huanshankeji.compose.foundation.layout.* -import com.huanshankeji.compose.foundation.layout.ext.outerPadding -import com.huanshankeji.compose.foundation.text.KeyboardActions -import com.huanshankeji.compose.foundation.text.KeyboardOptions -import com.huanshankeji.compose.foundation.text.input.ImeAction -import com.huanshankeji.compose.foundation.text.input.KeyboardCapitalization -import com.huanshankeji.compose.foundation.text.input.KeyboardType import com.huanshankeji.compose.material.icons.Icons -import com.huanshankeji.compose.material.icons.filled.Add import com.huanshankeji.compose.material.icons.filled.Done import com.huanshankeji.compose.material.icons.filled.Menu import com.huanshankeji.compose.material.icons.filled.Search -import com.huanshankeji.compose.material2.* -import com.huanshankeji.compose.material2.ext.* -import com.huanshankeji.compose.material2.lazy.ext.List -import com.huanshankeji.compose.material2.lazy.ext.ListItemComponents -import com.huanshankeji.compose.material2.lazy.ext.conventionalItem -import com.huanshankeji.compose.material2.lazy.ext.conventionalItems -import com.huanshankeji.compose.ui.Modifier -import com.huanshankeji.compose.ui.graphics.Color -import kotlinx.coroutines.launch -import com.huanshankeji.compose.material2.ext.Button as ExtButton +import com.huanshankeji.compose.material2.SnackbarHost +import com.huanshankeji.compose.material2.SnackbarHostState +import com.huanshankeji.compose.material2.Text +import com.huanshankeji.compose.material2.ext.TopAppBarScaffold +import com.huanshankeji.compose.material3.ext.TaglessText @Composable fun Material2(/*modifier: Modifier = Modifier*/) { @@ -46,110 +32,7 @@ fun Material2(/*modifier: Modifier = Modifier*/) { Text("FAB") // The Material 2 FAB is not added so this is a placeholder. }) { VerticalScrollBox { - Card(contentPaddingModifier) { - Column(contentPaddingModifier.background(Color(0xF8, 0xF8, 0xF8, 0xFF)), Arrangement.spacedBy(16.dp)) { - Text("Material text") - - var count by remember { mutableStateOf(0) } - val coroutineScope = rememberCoroutineScope() - val onClick: () -> Unit = { - count++ - val count = count - coroutineScope.launch { - snackbarHostState.showSnackbar("Count incremented to $count", "action") - } - } - val buttonContent: @Composable () -> Unit = { - TaglessText(count.toString()) - } - val rowScopeButtonContent: @Composable RowScope.() -> Unit = { buttonContent() } - - Row { - Button(onClick, content = rowScopeButtonContent) - OutlinedButton(onClick, content = rowScopeButtonContent) - TextButton(onClick, content = rowScopeButtonContent) - ExtButton(onClick) { - Label(count.toString()) - } - IconButton(onClick, icon = Icons.Default.Add, contentDescription = "increment count") - } - - val listModifier = Modifier.outerPadding(16.dp).height(listSize) - List(listModifier) { - item { - Text("Ungrouped item") - } - items(count) { - Text("Ungrouped item $it/$count") - } - group(headerContent = { - Text("Group title") - }) { - item { - Text("Grouped item") - } - items(count) { - Text("Grouped item $it/$count") - } - } - } - Divider() - val secondaryText = "Secondary text" - List(listModifier) { - conventionalItem(content = ListItemComponents("Ungrouped item", secondaryText)) - conventionalItems(count) { - ListItemComponents("Ungrouped item $it/$count", secondaryText) - } - group(headerContent = { - Text("Group title") - }) { - conventionalItem(content = ListItemComponents("Grouped item", secondaryText)) - conventionalItems(count) { - ListItemComponents("Grouped item $it/$count", secondaryText) - } - } - } - - var text by remember { mutableStateOf("") } - TextFieldWithMaterialIcons( - text, { text = it }, - label = "Demo text field", - leadingIcon = Icons.Default.Add, - trailingIcon = Icons.Default.Menu, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), - singleLine = true - ) - OutlinedTextFieldWithMaterialIcons( - text, { text = it }, - label = "Demo text field", - leadingIcon = Icons.Default.Add, - trailingIcon = Icons.Default.Menu, - keyboardOptions = KeyboardOptions( - KeyboardCapitalization.Words, true, imeAction = ImeAction.Search - ), - keyboardActions = KeyboardActions { - println("keyboard actions with: $text") - }, - singleLine = true - ) - TextArea(text, { text = it }, label = "Demo text field", lines = 3) - - var selected by remember { mutableStateOf(Selection.A) } - RadioGroupRow { - @Composable - fun RadioButtonRow(state: Selection) = - RadioRow(selected == state, state.toString(), { selected = state }) - Selection.entries.forEach { RadioButtonRow(it) } - } - - Row { - var checked by remember { mutableStateOf(false) } - Checkbox(checked, { checked = it }) - Switch(checked, { checked = it }) - SwitchWithLabel(checked, { checked = it }, "Switch") - } - } - } + TaglessText("Content") } } }