Clip color swatch click indicator correctly
This commit is contained in:
parent
ff7a72f7c4
commit
7d48db455c
@ -2,6 +2,7 @@ package de.mm20.launcher2.ui.settings.colorscheme
|
|||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
@ -22,7 +23,8 @@ import hct.Hct
|
|||||||
fun ColorSwatch(
|
fun ColorSwatch(
|
||||||
color: Color,
|
color: Color,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
selected: Boolean = false
|
selected: Boolean = false,
|
||||||
|
onClick: (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
val darkTheme = LocalDarkTheme.current
|
val darkTheme = LocalDarkTheme.current
|
||||||
val iconColor = Color(Hct.fromInt(color.toArgb()).let {
|
val iconColor = Color(Hct.fromInt(color.toArgb()).let {
|
||||||
@ -46,6 +48,7 @@ fun ColorSwatch(
|
|||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
|
.clickable(enabled = onClick != null, onClick = onClick ?: {})
|
||||||
.border(
|
.border(
|
||||||
if (selected) 4.dp else 1.dp,
|
if (selected) 4.dp else 1.dp,
|
||||||
borderColor,
|
borderColor,
|
||||||
|
|||||||
@ -48,8 +48,8 @@ fun CorePaletteColorPreference(
|
|||||||
color = Color(value ?: defaultValue),
|
color = Color(value ?: defaultValue),
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(48.dp)
|
.size(48.dp)
|
||||||
.tooltipTrigger()
|
.tooltipTrigger(),
|
||||||
.clickable { showDialog = true },
|
onClick = { showDialog = true },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -75,8 +75,8 @@ fun ThemeColorPreference(
|
|||||||
color = Color((value ?: defaultValue).get(corePalette)),
|
color = Color((value ?: defaultValue).get(corePalette)),
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(48.dp)
|
.size(48.dp)
|
||||||
.tooltipTrigger()
|
.tooltipTrigger(),
|
||||||
.clickable { showDialog = true },
|
onClick = { showDialog = true },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,14 +176,14 @@ fun ThemeColorPreference(
|
|||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.size(64.dp)
|
.size(64.dp),
|
||||||
.clickable {
|
|
||||||
currentValue = ColorRef(
|
|
||||||
CorePaletteColor.Primary,
|
|
||||||
tone.roundToInt()
|
|
||||||
)
|
|
||||||
},
|
|
||||||
selected = themeColor.color == CorePaletteColor.Primary,
|
selected = themeColor.color == CorePaletteColor.Primary,
|
||||||
|
onClick = {
|
||||||
|
currentValue = ColorRef(
|
||||||
|
CorePaletteColor.Primary,
|
||||||
|
tone.roundToInt()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
ColorSwatch(
|
ColorSwatch(
|
||||||
@ -194,14 +194,14 @@ fun ThemeColorPreference(
|
|||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.size(64.dp)
|
.size(64.dp),
|
||||||
.clickable {
|
|
||||||
currentValue = ColorRef(
|
|
||||||
CorePaletteColor.Secondary,
|
|
||||||
tone.roundToInt()
|
|
||||||
)
|
|
||||||
},
|
|
||||||
selected = themeColor.color == CorePaletteColor.Secondary,
|
selected = themeColor.color == CorePaletteColor.Secondary,
|
||||||
|
onClick = {
|
||||||
|
currentValue = ColorRef(
|
||||||
|
CorePaletteColor.Secondary,
|
||||||
|
tone.roundToInt()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
ColorSwatch(
|
ColorSwatch(
|
||||||
@ -212,14 +212,14 @@ fun ThemeColorPreference(
|
|||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.size(64.dp)
|
.size(64.dp),
|
||||||
.clickable {
|
|
||||||
currentValue = ColorRef(
|
|
||||||
CorePaletteColor.Tertiary,
|
|
||||||
tone.roundToInt()
|
|
||||||
)
|
|
||||||
},
|
|
||||||
selected = themeColor.color == CorePaletteColor.Tertiary,
|
selected = themeColor.color == CorePaletteColor.Tertiary,
|
||||||
|
onClick = {
|
||||||
|
currentValue = ColorRef(
|
||||||
|
CorePaletteColor.Tertiary,
|
||||||
|
tone.roundToInt()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Row(
|
Row(
|
||||||
@ -233,14 +233,14 @@ fun ThemeColorPreference(
|
|||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.size(64.dp)
|
.size(64.dp),
|
||||||
.clickable {
|
|
||||||
currentValue = ColorRef(
|
|
||||||
CorePaletteColor.Neutral,
|
|
||||||
tone.roundToInt()
|
|
||||||
)
|
|
||||||
},
|
|
||||||
selected = themeColor.color == CorePaletteColor.Neutral,
|
selected = themeColor.color == CorePaletteColor.Neutral,
|
||||||
|
onClick = {
|
||||||
|
currentValue = ColorRef(
|
||||||
|
CorePaletteColor.Neutral,
|
||||||
|
tone.roundToInt()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
ColorSwatch(
|
ColorSwatch(
|
||||||
@ -251,14 +251,14 @@ fun ThemeColorPreference(
|
|||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.size(64.dp)
|
.size(64.dp),
|
||||||
.clickable {
|
|
||||||
currentValue = ColorRef(
|
|
||||||
CorePaletteColor.NeutralVariant,
|
|
||||||
tone.roundToInt()
|
|
||||||
)
|
|
||||||
},
|
|
||||||
selected = themeColor.color == CorePaletteColor.NeutralVariant,
|
selected = themeColor.color == CorePaletteColor.NeutralVariant,
|
||||||
|
onClick = {
|
||||||
|
currentValue = ColorRef(
|
||||||
|
CorePaletteColor.NeutralVariant,
|
||||||
|
tone.roundToInt()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
ColorSwatch(
|
ColorSwatch(
|
||||||
@ -269,14 +269,14 @@ fun ThemeColorPreference(
|
|||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.size(64.dp)
|
.size(64.dp),
|
||||||
.clickable {
|
|
||||||
currentValue = ColorRef(
|
|
||||||
CorePaletteColor.Error,
|
|
||||||
tone.roundToInt()
|
|
||||||
)
|
|
||||||
},
|
|
||||||
selected = themeColor.color == CorePaletteColor.Error,
|
selected = themeColor.color == CorePaletteColor.Error,
|
||||||
|
onClick = {
|
||||||
|
currentValue = ColorRef(
|
||||||
|
CorePaletteColor.Error,
|
||||||
|
tone.roundToInt()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user