diff --git a/color/src/commonMain/composeResources/drawable/scd_color_dialog_transparent_pattern.svg b/color/src/commonMain/composeResources/drawable/scd_color_dialog_transparent_pattern.svg deleted file mode 100644 index 9b2d2ed8..00000000 --- a/color/src/commonMain/composeResources/drawable/scd_color_dialog_transparent_pattern.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/color/src/commonMain/composeResources/drawable/scd_color_dialog_transparent_pattern.xml b/color/src/commonMain/composeResources/drawable/scd_color_dialog_transparent_pattern.xml new file mode 100644 index 00000000..79d864e8 --- /dev/null +++ b/color/src/commonMain/composeResources/drawable/scd_color_dialog_transparent_pattern.xml @@ -0,0 +1,11 @@ + + + diff --git a/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/utils/Utils.kt b/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/utils/Utils.kt index 9d3cf41e..3fef91c7 100644 --- a/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/utils/Utils.kt +++ b/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/utils/Utils.kt @@ -15,8 +15,26 @@ */ package com.maxkeppeler.sheets.color.utils +import androidx.compose.ui.graphics.Color + /** Receive the clipboard data. */ @OptIn(ExperimentalStdlibApi::class) internal fun getFormattedColor(color: Int): String { - return "#" + (0xFFFFFFFF and color.toLong()).toHexString() + val c = Color(color) + return toArgbHexManual(c.alpha * 255F, c.red * 255F, c.green * 255F, c.blue * 255F) +} + +private fun toArgbHexManual(a: Float, r: Float, g: Float, b: Float): String { + require(a in 0F..255F && r in 0F..255F && g in 0F..255F && b in 0F..255F) { + "ARGB values must be between 0 and 255." + } + return "#${a.toInt().toHex()}${r.toInt().toHex()}${g.toInt().toHex()}${b.toInt().toHex()}" } + +private fun Int.toHex(): String = toHexString(HexFormat { + upperCase = true + number { + removeLeadingZeros = true + minLength = 2 + } +}) diff --git a/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorCustomControlComponent.kt b/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorCustomControlComponent.kt index 42c8e661..dd9fbdd0 100644 --- a/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorCustomControlComponent.kt +++ b/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorCustomControlComponent.kt @@ -93,7 +93,7 @@ internal fun ColorCustomControlComponent( ) { entry -> val index = colorItems.indexOf(entry) val onValueChange: (Int) -> Unit = { - entry.second.value = it.toFloat() + entry.second.value = it / 256F } val sliderTestTag = testSequenceTagOf( TestTags.COLOR_CUSTOM_VALUE_SLIDER, @@ -103,7 +103,7 @@ internal fun ColorCustomControlComponent( LibOrientation.PORTRAIT -> ColorCustomControlListItemComponent( label = entry.first, - value = entry.second.value.toInt(), + value = (entry.second.value * 256F).toInt(), onValueChange = onValueChange, colorItemLabelWidth = colorItemLabelWidth, colorValueLabelWidth = colorValueLabelWidth, @@ -112,7 +112,7 @@ internal fun ColorCustomControlComponent( LibOrientation.LANDSCAPE -> ColorCustomControlGridItemComponent( label = entry.first, - value = entry.second.value.toInt(), + value = (entry.second.value * 256F).toInt(), onValueChange = onValueChange, sliderTestTag = sliderTestTag, ) diff --git a/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorSelectionModeComponent.kt b/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorSelectionModeComponent.kt index 32fa4e70..3ec39d90 100644 --- a/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorSelectionModeComponent.kt +++ b/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorSelectionModeComponent.kt @@ -79,7 +79,7 @@ internal fun ColorSelectionModeComponent( } ) Icon( - modifier = Modifier.size(48.dp), + modifier = Modifier.size(24.dp), imageVector = if (mode != ColorSelectionMode.TEMPLATE) config.icons.Apps else config.icons.Tune, contentDescription = text, tint = MaterialTheme.colorScheme.primary @@ -102,7 +102,7 @@ internal fun ColorSelectionModeComponent( shape = RoundedCornerShape(50) ) { Icon( - modifier = Modifier.size(48.dp), + modifier = Modifier.size(24.dp), imageVector = config.icons.NotInterested, contentDescription = stringResource(Res.string.scd_color_dialog_no_color), tint = MaterialTheme.colorScheme.primary diff --git a/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorTemplateItemComponent.kt b/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorTemplateItemComponent.kt index c2e4b8b3..e2cb5f60 100644 --- a/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorTemplateItemComponent.kt +++ b/color/src/commonMain/kotlin/com/maxkeppeler/sheets/color/views/ColorTemplateItemComponent.kt @@ -85,7 +85,7 @@ internal fun ColorTemplateItemComponent( colors = IconButtonDefaults.filledIconButtonColors(containerColor = MaterialTheme.colorScheme.background), modifier = Modifier .align(Alignment.Center) - .size(48.dp), + .size(24.dp), onClick = {} ) { Icon(