mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 08:45:27 +02:00
Update style selectors
This commit is contained in:
parent
f88c85bcdc
commit
6ab8477701
@ -34,6 +34,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.lazy.LazyRow
|
import androidx.compose.foundation.lazy.LazyRow
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
@ -42,6 +43,7 @@ import androidx.compose.material3.Icon
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.surfaceColorAtElevation
|
import androidx.compose.material3.surfaceColorAtElevation
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
@ -54,11 +56,19 @@ internal fun ColorSelector(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
selected: Color,
|
selected: Color,
|
||||||
onItemClick: (Color) -> Unit,
|
onItemClick: (Color) -> Unit,
|
||||||
colorSchemes: List<Color>,
|
colors: List<Color>,
|
||||||
defaultColor: Color
|
defaultColor: Color,
|
||||||
) {
|
) {
|
||||||
|
val listState = rememberLazyListState()
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
val index = colors.indexOf(selected)
|
||||||
|
if (index >= 0) listState.scrollToItem(index)
|
||||||
|
}
|
||||||
|
|
||||||
LazyRow(
|
LazyRow(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
state = listState,
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
// Default, Unitto colors
|
// Default, Unitto colors
|
||||||
@ -70,7 +80,7 @@ internal fun ColorSelector(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
colorSchemes.forEach {
|
colors.forEach {
|
||||||
item(it.value.toLong()) {
|
item(it.value.toLong()) {
|
||||||
ColorCheckbox(
|
ColorCheckbox(
|
||||||
color = it,
|
color = it,
|
||||||
@ -103,7 +113,7 @@ private fun ColorCheckbox(
|
|||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.background(color)
|
.background(color)
|
||||||
.border(1.dp, Color.Black.copy(0.5f), CircleShape),
|
.border(1.dp, MaterialTheme.colorScheme.outline, CircleShape),
|
||||||
)
|
)
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = selected,
|
visible = selected,
|
@ -37,6 +37,7 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.lazy.LazyRow
|
import androidx.compose.foundation.lazy.LazyRow
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
@ -47,6 +48,7 @@ import androidx.compose.material3.darkColorScheme
|
|||||||
import androidx.compose.material3.lightColorScheme
|
import androidx.compose.material3.lightColorScheme
|
||||||
import androidx.compose.material3.surfaceColorAtElevation
|
import androidx.compose.material3.surfaceColorAtElevation
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -67,8 +69,16 @@ internal fun MonetModeSelector(
|
|||||||
customColor: Color,
|
customColor: Color,
|
||||||
themingMode: ThemingMode,
|
themingMode: ThemingMode,
|
||||||
) {
|
) {
|
||||||
|
val listState = rememberLazyListState()
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
val index = monetModes.indexOf(selected)
|
||||||
|
if (index >= 0) listState.scrollToItem(index)
|
||||||
|
}
|
||||||
|
|
||||||
LazyRow(
|
LazyRow(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
state = listState,
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
items(monetModes) { monetMode ->
|
items(monetModes) { monetMode ->
|
||||||
@ -114,7 +124,8 @@ private fun MonetModeCheckbox(
|
|||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.background(MaterialTheme.colorScheme.secondary)
|
.background(MaterialTheme.colorScheme.secondary)
|
||||||
.border(1.dp, Color.Black.copy(0.5f), CircleShape),
|
.border(1.dp, MaterialTheme.colorScheme.outline, CircleShape),
|
||||||
|
contentAlignment = Alignment.BottomStart
|
||||||
) {
|
) {
|
||||||
// Is this bad? Yes. Does it work? Also yes.
|
// Is this bad? Yes. Does it work? Also yes.
|
||||||
Box(modifier = Modifier
|
Box(modifier = Modifier
|
@ -229,7 +229,7 @@ private fun DisplayScreen(
|
|||||||
modifier = Modifier.padding(top = 12.dp),
|
modifier = Modifier.padding(top = 12.dp),
|
||||||
selected = selectedColor,
|
selected = selectedColor,
|
||||||
onItemClick = onColorChange,
|
onItemClick = onColorChange,
|
||||||
colorSchemes = colorSchemes,
|
colors = colorSchemes,
|
||||||
defaultColor = Color(0xFF186c31)
|
defaultColor = Color(0xFF186c31)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user