From 8d796b75d7c3bc8524b22f613e393a9b3484ed4c Mon Sep 17 00:00:00 2001 From: aro Date: Sun, 20 Nov 2022 22:14:06 +0100 Subject: [PATCH] why is kotlin desktop compose so hard? --- .../wrench/components/WrenchBottomRow.kt | 33 ++++++++++++------- .../kotlin/xyz/atnrch/wrench/ui/UIColors.kt | 8 ++++- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/xyz/atnrch/wrench/components/WrenchBottomRow.kt b/src/main/kotlin/xyz/atnrch/wrench/components/WrenchBottomRow.kt index 7caeac5..f5a90f3 100644 --- a/src/main/kotlin/xyz/atnrch/wrench/components/WrenchBottomRow.kt +++ b/src/main/kotlin/xyz/atnrch/wrench/components/WrenchBottomRow.kt @@ -11,6 +11,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.PlayArrow import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color @@ -24,6 +25,8 @@ fun BottomRow( state: Boolean, onStateChange: (state: Boolean) -> Unit ) { + val buttonColors = remember { arrayOf(UIColors.WATCHER_START_BG) } + //............. // START BUTTON //............. @@ -38,21 +41,27 @@ fun BottomRow( onStateChange(true) } }, - colors = ButtonDefaults.buttonColors(UIColors.LIGHT, Color.White), + colors = ButtonDefaults.buttonColors(buttonColors[0], Color.White), contentPadding = ButtonDefaults.ContentPadding, shape = RoundedCornerShape(100), modifier = Modifier.shadow(15.dp, RoundedCornerShape(100), false) ) { - if (state) Icon( - Icons.Filled.Close, - tint = UIColors.STRESS, - contentDescription = "Stop", - modifier = Modifier.size(28.dp) - ) else Icon( - Icons.Filled.PlayArrow, - tint = UIColors.GREEN, - contentDescription = "Start", - modifier = Modifier.size(28.dp) - ) + if (state) { + buttonColors[0] = UIColors.WATCHER_STOP_BG + Icon( + Icons.Filled.Close, + tint = UIColors.WATCHER_STOP_FG, + contentDescription = "Stop", + modifier = Modifier.size(28.dp) + ) + } else { + buttonColors[0] = UIColors.WATCHER_START_BG + Icon( + Icons.Filled.PlayArrow, + tint = UIColors.WATCHER_START_FG, + contentDescription = "Start", + modifier = Modifier.size(28.dp) + ) + } } } \ No newline at end of file diff --git a/src/main/kotlin/xyz/atnrch/wrench/ui/UIColors.kt b/src/main/kotlin/xyz/atnrch/wrench/ui/UIColors.kt index ae18c61..2a36edd 100644 --- a/src/main/kotlin/xyz/atnrch/wrench/ui/UIColors.kt +++ b/src/main/kotlin/xyz/atnrch/wrench/ui/UIColors.kt @@ -7,6 +7,12 @@ class UIColors { val PRIMARY = Color(0xFF424242) val LIGHT = Color(0xFF6D6D6D) val STRESS = Color(0xFFF44336) - val GREEN = Color(0xFF388E3C) + val GREEN = Color(0xFF64BA59) + val ORANGE = Color(0xFFFFB300) + + val WATCHER_START_BG = Color(0xFF31893D) + val WATCHER_START_FG = Color(0xFF64BA69) + val WATCHER_STOP_BG = Color(0xFFBA000D) + val WATCHER_STOP_FG = STRESS } } \ No newline at end of file