mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-14 03:19:19 +00:00
Update Compose Version and Create Chip Row in Compose
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package com.looker.droidify.ui.compose.utils
|
||||
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@ -19,7 +18,6 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.looker.droidify.ui.compose.theme.LocalShapes
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@ -34,8 +32,9 @@ fun ExpandableCard(
|
||||
mainContent: @Composable () -> Unit
|
||||
) {
|
||||
var expanded by rememberSaveable { mutableStateOf(preExpanded) }
|
||||
val cardElevation by animateDpAsState(targetValue = if (expanded) 12.dp else 0.dp)
|
||||
val background by animateColorAsState(targetValue = backgroundColor)
|
||||
val background by animateColorAsState(
|
||||
targetValue = if (expanded) MaterialTheme.colorScheme.surfaceVariant else backgroundColor
|
||||
)
|
||||
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
@ -45,7 +44,6 @@ fun ExpandableCard(
|
||||
onClick = onClick,
|
||||
onLongClick = { expanded = !expanded }
|
||||
),
|
||||
tonalElevation = cardElevation,
|
||||
color = background
|
||||
) {
|
||||
Box(modifier = modifier, contentAlignment = Alignment.CenterStart) {
|
||||
|
48
src/main/kotlin/com/looker/droidify/ui/compose/utils/Chip.kt
Normal file
48
src/main/kotlin/com/looker/droidify/ui/compose/utils/Chip.kt
Normal file
@ -0,0 +1,48 @@
|
||||
package com.looker.droidify.ui.compose.utils
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Chip
|
||||
import androidx.compose.material.ChipColors
|
||||
import androidx.compose.material.ChipDefaults
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun ChipRow(
|
||||
modifier: Modifier = Modifier,
|
||||
list: List<String>,
|
||||
chipColors: ChipColors = ChipDefaults.chipColors(
|
||||
backgroundColor = MaterialTheme.colorScheme.surface,
|
||||
contentColor = MaterialTheme.colorScheme.primary.copy(alpha = ChipDefaults.ContentOpacity),
|
||||
),
|
||||
shapes: Shape = RoundedCornerShape(50),
|
||||
onClick: (String) -> Unit
|
||||
) {
|
||||
LazyRow(
|
||||
modifier = modifier,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
items(list) {
|
||||
Chip(
|
||||
shape = shapes,
|
||||
colors = chipColors,
|
||||
onClick = { onClick(it) }
|
||||
) {
|
||||
Text(
|
||||
text = it,
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.primary.copy(alpha = ChipDefaults.ContentOpacity)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user