File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
colorpicker/src/main/java/com/smarttoolfactory/colorpicker/widget Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ package com.smarttoolfactory.colorpicker.widget
2+
3+ import androidx.compose.foundation.background
4+ import androidx.compose.foundation.layout.Box
5+ import androidx.compose.foundation.layout.Row
6+ import androidx.compose.foundation.layout.height
7+ import androidx.compose.foundation.shape.RoundedCornerShape
8+ import androidx.compose.runtime.Composable
9+ import androidx.compose.ui.Modifier
10+ import androidx.compose.ui.graphics.Color
11+ import androidx.compose.ui.unit.dp
12+
13+ /* *
14+ * Color display that displays both colors horizontally aligned with half [RoundedCornerShape]
15+ * with [Modifier.drawChecker] to display checker pattern when any color's alpha is less than 1.0f
16+ * @param initialColor color that should be static
17+ * @param currentColor color that is changed based on user actions
18+ */
19+ @Composable
20+ fun ColorDisplayRoundedRect (
21+ modifier : Modifier = Modifier ,
22+ initialColor : Color ,
23+ currentColor : Color
24+ ) {
25+ Row (modifier = modifier) {
26+ Box (
27+ modifier = Modifier
28+ .weight(1f )
29+ .height(40 .dp)
30+ .background(
31+ initialColor,
32+ shape = RoundedCornerShape (topStart = 8 .dp, bottomStart = 8 .dp)
33+ )
34+ )
35+ Box (
36+ modifier = Modifier
37+ .weight(1f )
38+ .height(40 .dp)
39+ .drawChecker(RoundedCornerShape (topEnd = 8 .dp, bottomEnd = 8 .dp))
40+ .background(
41+ currentColor,
42+ shape = RoundedCornerShape (topEnd = 8 .dp, bottomEnd = 8 .dp)
43+ )
44+ )
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments