mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-24 03:42:15 +00:00
Add Util Function to ease life
This commit is contained in:
parent
a7e9949d44
commit
1e9dd3f03a
@ -21,6 +21,7 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.looker.droidify.ui.compose.utils.compositeOverBackground
|
||||||
|
|
||||||
private enum class SelectionState { Unselected, Selected }
|
private enum class SelectionState { Unselected, Selected }
|
||||||
|
|
||||||
@ -49,7 +50,10 @@ private fun categoryChipTransition(selected: Boolean): CategoryChipTransition {
|
|||||||
val contentColor = transition.animateColor(label = "chip_content_alpha") { state ->
|
val contentColor = transition.animateColor(label = "chip_content_alpha") { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
SelectionState.Unselected -> MaterialTheme.colorScheme.surface
|
SelectionState.Unselected -> MaterialTheme.colorScheme.surface
|
||||||
SelectionState.Selected -> MaterialTheme.colorScheme.inversePrimary.copy(alpha = 0.8f)
|
SelectionState.Selected -> MaterialTheme.colorScheme.primaryContainer.compositeOverBackground(
|
||||||
|
alpha = 0.8f,
|
||||||
|
background = MaterialTheme.colorScheme.onBackground
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val checkScale = transition.animateFloat(
|
val checkScale = transition.animateFloat(
|
||||||
|
@ -10,7 +10,6 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.compositeOver
|
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@ -30,11 +29,13 @@ fun CustomChip(
|
|||||||
shape = Shapes.Full,
|
shape = Shapes.Full,
|
||||||
border = BorderStroke(
|
border = BorderStroke(
|
||||||
width = borderWidth,
|
width = borderWidth,
|
||||||
color = borderColor.copy(0.5f).compositeOver(MaterialTheme.colorScheme.surface)
|
color = borderColor.compositeOverBackground(
|
||||||
|
alpha = 0.5f,
|
||||||
|
MaterialTheme.colorScheme.surface
|
||||||
|
)
|
||||||
),
|
),
|
||||||
colors = chipColors(
|
colors = chipColors(
|
||||||
backgroundColor = containerColor.copy(0.1f)
|
backgroundColor = containerColor.compositeOverBackground(alpha = 0.1f)
|
||||||
.compositeOver(MaterialTheme.colorScheme.background)
|
|
||||||
),
|
),
|
||||||
onClick = { onClick(text) }
|
onClick = { onClick(text) }
|
||||||
) {
|
) {
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.looker.droidify.ui.compose.utils
|
||||||
|
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.Stable
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.compositeOver
|
||||||
|
|
||||||
|
@Stable
|
||||||
|
@Composable
|
||||||
|
fun Color.compositeOverBackground(
|
||||||
|
alpha: Float,
|
||||||
|
background: Color = MaterialTheme.colorScheme.background
|
||||||
|
) = this.copy(alpha).compositeOver(background)
|
Loading…
x
Reference in New Issue
Block a user