Skip to content

Commit f2ee97d

Browse files
update gradient color pickers
1 parent 756f8df commit f2ee97d

File tree

3 files changed

+21
-38
lines changed

3 files changed

+21
-38
lines changed

colorpicker/src/main/java/com/smarttoolfactory/colorpicker/picker/gradient/ColorPickerGradientRingDimondHSL.kt

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ fun ColorPickerGradientRingDiamondHSL(
6767
var lightness by remember { mutableStateOf(hslArray[2]) }
6868
var alpha by remember { mutableStateOf(gradientColorState.color.alpha) }
6969

70-
gradientColorState.color =
71-
Color.hsl(
72-
hue = hue,
73-
saturation = saturation,
74-
lightness = lightness,
75-
alpha = alpha
76-
)
77-
7870
Column(
7971
modifier = modifier,
8072
horizontalAlignment = Alignment.CenterHorizontally,
@@ -111,13 +103,7 @@ fun ColorPickerGradientRingDiamondHSL(
111103
) { hueChange ->
112104
hue = hueChange
113105

114-
gradientColorState.color =
115-
Color.hsl(
116-
hue = hue,
117-
saturation = saturation,
118-
lightness = lightness,
119-
alpha = alpha
120-
)
106+
setGradientColor(gradientColorState, hue, saturation, lightness, alpha)
121107
onBrushColorChange(BrushColor(color = gradientColorState.color))
122108
}
123109

@@ -132,13 +118,7 @@ fun ColorPickerGradientRingDiamondHSL(
132118
saturation = s
133119
lightness = l
134120

135-
gradientColorState.color =
136-
Color.hsl(
137-
hue = hue,
138-
saturation = saturation,
139-
lightness = lightness,
140-
alpha = alpha
141-
)
121+
setGradientColor(gradientColorState, hue, saturation, lightness, alpha)
142122
onBrushColorChange(BrushColor(color = gradientColorState.color))
143123
}
144124
}
@@ -199,13 +179,7 @@ fun ColorPickerGradientRingDiamondHSL(
199179
lightness = color.lightness
200180
alpha = color.alpha
201181

202-
gradientColorState.color =
203-
Color.hsl(
204-
hue = hue,
205-
saturation = saturation,
206-
lightness = lightness,
207-
alpha = alpha
208-
)
182+
setGradientColor(gradientColorState, hue, saturation, lightness, alpha)
209183
onBrushColorChange(BrushColor(color = gradientColorState.color))
210184
}
211185
},
@@ -215,6 +189,22 @@ fun ColorPickerGradientRingDiamondHSL(
215189
)
216190
}
217191
}
218-
219192
}
220193
}
194+
195+
private fun setGradientColor(
196+
gradientColorState: GradientColorState,
197+
hue: Float,
198+
saturation: Float,
199+
lightness: Float,
200+
alpha: Float
201+
) {
202+
gradientColorState.color =
203+
Color.hsl(
204+
hue = hue,
205+
saturation = saturation,
206+
lightness = lightness,
207+
alpha = alpha
208+
)
209+
}
210+

colorpicker/src/main/java/com/smarttoolfactory/colorpicker/picker/gradient/ColorPickerGradientRingRectHSL.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ fun ColorPickerGradientRingRectHSL(
6868
var lightness by remember { mutableStateOf(hslArray[2]) }
6969
var alpha by remember { mutableStateOf(gradientColorState.color.alpha) }
7070

71-
// setGradientColor(gradientColorState, hue, saturation, lightness, alpha)
72-
7371
Column(
7472
modifier = modifier,
7573
horizontalAlignment = Alignment.CenterHorizontally,
@@ -184,7 +182,7 @@ fun ColorPickerGradientRingRectHSL(
184182
lightness = color.lightness
185183
alpha = color.alpha
186184

187-
setGradientColor(gradientColorState, hue, saturation, lightness, alpha)
185+
setGradientColor(gradientColorState, hue, saturation, lightness, alpha)
188186
onBrushColorChange(BrushColor(color = gradientColorState.color))
189187
}
190188
},

colorpicker/src/main/java/com/smarttoolfactory/colorpicker/widget/HexTextField.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,13 @@ fun HexTextField(
7474
onValueChange = {
7575

7676
if (it.length <= if (useAlpha) 8 else 6) {
77-
78-
println("😍 CurrentString: $it")
7977
var validHex = true
8078

8179
for (index in it.indices) {
8280
validHex = hexRegexSingleChar.matches(it[index].toString())
83-
println("🎃 CHART: ${it[index]}, validHex: $validHex")
8481
if (!validHex) break
8582
}
8683

87-
println("💬 TEXT: $it, validHex: $validHex")
88-
8984
if (validHex) {
9085
onTextChange(it)
9186

0 commit comments

Comments
 (0)