@@ -21,13 +21,13 @@ import androidx.compose.runtime.setValue
2121import androidx.compose.ui.Alignment
2222import androidx.compose.ui.Modifier
2323import androidx.compose.ui.draw.clip
24- import androidx.compose.ui.geometry.Offset
2524import androidx.compose.ui.graphics.Brush
2625import androidx.compose.ui.graphics.Color
2726import androidx.compose.ui.graphics.drawscope.DrawScope
2827import androidx.compose.ui.input.pointer.pointerInput
2928import androidx.compose.ui.layout.onGloballyPositioned
3029import androidx.compose.ui.platform.LocalDensity
30+ import androidx.compose.ui.unit.Dp
3131import androidx.compose.ui.unit.dp
3232import top.yukonga.miuix.kmp.theme.MiuixTheme
3333import top.yukonga.miuix.kmp.utils.ColorUtils
@@ -148,18 +148,11 @@ fun HueSlider(
148148 value = currentHue / 360f ,
149149 onValueChanged = onHueChanged,
150150 drawBrush = {
151- val width = size.width
152- for (i in 0 until width.toInt()) {
153- val hue = i / width * 360f
154- drawLine(
155- color = Color .hsv(hue, 1f , 1f ),
156- start = Offset (i.toFloat(), 0f ),
157- end = Offset (i.toFloat(), size.height),
158- strokeWidth = 1f
159- )
151+ val hueColors = List (36 ) { i ->
152+ Color .hsv(i * 10f , 1f , 1f )
160153 }
154+ drawRect(brush = Brush .horizontalGradient(hueColors))
161155 },
162- indicatorColor = { Color .hsv(currentHue, 1f , 1f ) },
163156 modifier = Modifier .fillMaxWidth()
164157 )
165158}
@@ -189,7 +182,6 @@ fun SaturationSlider(
189182 )
190183 drawRect(brush = brush)
191184 },
192- indicatorColor = { Color .hsv(currentHue, currentSaturation, 1f ) },
193185 modifier = Modifier .fillMaxWidth()
194186 )
195187}
@@ -222,7 +214,6 @@ fun ValueSlider(
222214 )
223215 drawRect(brush = brush)
224216 },
225- indicatorColor = { Color .hsv(currentHue, currentSaturation, currentValue) },
226217 modifier = Modifier .fillMaxWidth()
227218 )
228219}
@@ -256,7 +247,6 @@ fun AlphaSlider(
256247 )
257248 drawRect(brush = brush)
258249 },
259- indicatorColor = { Color .hsv(currentHue, currentSaturation, currentValue, currentAlpha) },
260250 modifier = Modifier .fillMaxWidth()
261251 )
262252}
@@ -269,7 +259,6 @@ private fun ColorSlider(
269259 value : Float ,
270260 onValueChanged : (Float ) -> Unit ,
271261 drawBrush : DrawScope .() -> Unit ,
272- indicatorColor : () -> Color ,
273262 modifier : Modifier = Modifier
274263) {
275264 val density = LocalDensity .current
@@ -305,8 +294,7 @@ private fun ColorSlider(
305294 value = value,
306295 sliderWidth = sliderWidth,
307296 sliderSizePx = sliderSizePx,
308- indicatorSize = indicatorSizeDp,
309- indicatorColor = indicatorColor()
297+ indicatorSize = indicatorSizeDp
310298 )
311299 }
312300}
@@ -315,10 +303,9 @@ private fun ColorSlider(
315303private fun SliderIndicator (
316304 modifier : Modifier ,
317305 value : Float ,
318- sliderWidth : androidx.compose.ui.unit. Dp ,
306+ sliderWidth : Dp ,
319307 sliderSizePx : Float ,
320- indicatorSize : androidx.compose.ui.unit.Dp ,
321- indicatorColor : Color
308+ indicatorSize : Dp
322309) {
323310 val density = LocalDensity .current
324311 Box (
@@ -332,7 +319,7 @@ private fun SliderIndicator(
332319 .size(indicatorSize)
333320 .clip(RoundedCornerShape (50 .dp))
334321 .border(6 .dp, Color .White , RoundedCornerShape (50 .dp))
335- .background(indicatorColor , RoundedCornerShape (50 .dp))
322+ .background(Color . Transparent , RoundedCornerShape (50 .dp))
336323 )
337324}
338325
0 commit comments