@@ -16,29 +16,29 @@ import androidx.compose.ui.unit.sp
1616import com.smarttoolfactory.colorpicker.selector.HueSelectorRing
1717import com.smarttoolfactory.colorpicker.selector.SLSelectorFromHSLDiamond
1818import 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
2224fun 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