Skip to content

Commit

Permalink
Remove the content in the Material 2 demo to reproduce the bug in com…
Browse files Browse the repository at this point in the history
…mit fb269bd and report it Chromium at https://issues.chromium.org/issues/386052671
  • Loading branch information
ShreckYe committed Dec 26, 2024
1 parent 171dd5b commit 652e80e
Showing 1 changed file with 8 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -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*/) {
Expand All @@ -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")
}
}
}

0 comments on commit 652e80e

Please sign in to comment.