Skip to content

Commit 5475fb9

Browse files
add slider display, and panels
1 parent de831c9 commit 5475fb9

File tree

12 files changed

+1070
-173
lines changed

12 files changed

+1070
-173
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
### Jetpack Compose Color Picker
22

3-
Bundle of Stylish customizable Color pickers, selectors, colorful written with Jetpack Compose that
4-
enables users to choose from HSL, HSV or RGB color modes or return gradients instead of solid
5-
colors.
3+
Bundle of Stylish customizable Color pickers, selectors, colorful sliders written with Jetpack Compose
4+
enables users to choose from HSL, HSV or RGB color modes to pick Solid colors or
5+
gradients.
66

7-
You can check out gradient, slider demos for rotating gradients, creating HSV, HSL gradients,
7+
8+
9+
Check out gradient, slider demos for rotating gradients, creating HSV, HSL gradients,
810
and check out Colorful Sliders to get familiar with.
911

1012
<img src="/./screenshots/intro.gif" align="right" width="32%"/>
@@ -31,5 +33,3 @@ and check out Colorful Sliders to get familiar with.
3133
- [ ] Add and display colors selected previously
3234
- [ ] Add gradient color selection with percentage stops, linear, radial and sweep options
3335
- [ ] Add option to select colors from Image, Screen or Camera
34-
35-

app/src/main/java/com/smarttoolfactory/composecolorpicker/demo/ColorPickerDemo.kt

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,29 @@ import androidx.compose.ui.unit.sp
1616
import com.smarttoolfactory.colorpicker.selector.HueSelectorRing
1717
import com.smarttoolfactory.colorpicker.selector.SLSelectorFromHSLDiamond
1818
import com.smarttoolfactory.colorpicker.ui.Blue400
19-
import com.smarttoolfactory.colorpicker.widget.*
19+
import com.smarttoolfactory.colorpicker.widget.SliderDisplayPanelHSL
20+
import com.smarttoolfactory.colorpicker.widget.SliderPanelHSL
21+
import com.smarttoolfactory.colorpicker.widget.drawChecker
2022

2123
@Composable
2224
fun ColorPickerDemo() {
2325
Column(
2426
modifier = Modifier
25-
.background(Color(0xff424242))
2627
// .background(Color.White)
2728
.fillMaxSize()
2829
.padding(8.dp)
2930
.verticalScroll(rememberScrollState())
3031
) {
3132

32-
var hue by remember { mutableStateOf(0f) }
33-
var saturation by remember { mutableStateOf(.5f) }
34-
var lightness by remember { mutableStateOf(.5f) }
35-
var alpha by remember { mutableStateOf(1f) }
36-
33+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
3734

38-
val color =
39-
Color.hsl(hue = hue, saturation = saturation, lightness = lightness, alpha = alpha)
35+
var hue by remember { mutableStateOf(0f) }
36+
var saturation by remember { mutableStateOf(.5f) }
37+
var lightness by remember { mutableStateOf(.5f) }
38+
var alpha by remember { mutableStateOf(1f) }
4039

41-
Column(horizontalAlignment = Alignment.CenterHorizontally) {
40+
val color =
41+
Color.hsl(hue = hue, saturation = saturation, lightness = lightness, alpha = alpha)
4242

4343
Spacer(modifier = Modifier.height(10.dp))
4444
Text(
@@ -81,13 +81,13 @@ fun ColorPickerDemo() {
8181
// ColorWheel for hue selection
8282
// SaturationDiamond for saturation and lightness selections
8383
Box(
84-
modifier = Modifier.padding(8.dp),
84+
modifier = Modifier,
8585
contentAlignment = Alignment.Center
8686
) {
8787

8888
HueSelectorRing(
8989
modifier = Modifier
90-
.fillMaxWidth()
90+
.width(350.dp)
9191
.aspectRatio(1f),
9292
selectionRadius = 8.dp
9393
) { hueChange ->
@@ -108,39 +108,16 @@ fun ColorPickerDemo() {
108108
}
109109
}
110110

111-
SliderHueHSL(
112-
modifier = Modifier.width(300.dp),
111+
SliderDisplayPanelHSL(
112+
modifier = Modifier.width(340.dp),
113113
hue = hue,
114114
saturation = saturation,
115115
lightness = lightness,
116-
onValueChange = {
117-
hue = it
118-
}
119-
)
120-
121-
SliderSaturationHSL(
122-
modifier = Modifier.width(300.dp),
123-
hue = hue, saturation = saturation, lightness = lightness,
124-
onValueChange = { value ->
125-
saturation = value
126-
}
127-
)
128-
129-
SliderLightnessHSL(
130-
modifier = Modifier.width(300.dp),
131-
lightness = lightness,
132-
onValueChange = { result ->
133-
lightness = result
134-
}
135-
)
136-
137-
SliderAlphaHSL(
138-
modifier = Modifier.width(300.dp),
139-
hue = hue,
140116
alpha = alpha,
141-
onValueChange = {
142-
alpha = it
143-
}
117+
onHueChange = { hue = it },
118+
onSaturationChange = { saturation = it },
119+
onLightnessChange = { lightness = it },
120+
onAlphaChange = { alpha = it },
144121
)
145122
}
146123
}

0 commit comments

Comments
 (0)