Skip to content

Commit db4116b

Browse files
refactor
1 parent 5a82782 commit db4116b

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Colorful sliders that can have Solid or Gradient colors for thumb or track which
44
track with varying sizes, borders with solid or gradient colors. And Sliders with emojis, or custom
55
Composables like **Icon**.
66

7-
|Dimensions | Properties | Slider with Icon | Slider with Label | Gradient |
7+
|Properties | Dimensions | Slider with Icon | Slider with Label | Gradient |
88
| ----------|-----------| -----------| -----------| -----------|
9-
| <img src="./screenshots/slider_dimensions.png"/> | <img src="./screenshots/slider_properties.png"/> | <img src="./screenshots/slider_icons.png"/> | <img src="./screenshots/slider_labels.png"/> | <img src="./screenshots/slider_gradient.png"/> |
9+
| <img src="./screenshots/slider_properties.png"/> | <img src="./screenshots/slider_dimensions.png"/> | <img src="./screenshots/slider_icons.png"/> | <img src="./screenshots/slider_labels.png"/> | <img src="./screenshots/slider_gradient.png"/> |
1010

1111
### ColorfulSlider
1212

@@ -198,6 +198,7 @@ fun ColorfulIconSlider(
198198

199199
Usage
200200

201+
Emojis are transparent by default in Compose, you might want to set non-transparent color for `Text`
201202
```
202203
ColorfulIconSlider(
203204
value = progress,

slider/src/main/java/com/smarttoolfactory/slider/ColorfulIconSlider.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ fun ColorfulIconSlider(
144144
minWidth = ThumbRadius * 2,
145145
minHeight = ThumbRadius * 2,
146146
),
147-
thumb = { thumb() }) { thumbSize: IntSize, constraints: Constraints ->
147+
thumb = { thumb() }
148+
) { thumbSize: IntSize, constraints: Constraints ->
148149

149150
require(steps >= 0) { "steps should be >= 0" }
150151
val onValueChangeState = rememberUpdatedState(onValueChange)
@@ -465,12 +466,11 @@ private fun SliderComposeLayout(
465466
it.measure(constraints)
466467
}.first()
467468

468-
469469
val sliderWidth = sliderPlaceable.width
470470
val sliderHeight = sliderPlaceable.height
471471

472472
layout(sliderWidth, sliderHeight) {
473473
sliderPlaceable.placeRelative(0, 0)
474474
}
475475
}
476-
}
476+
}

slider/src/main/java/com/smarttoolfactory/slider/ColorfulSlider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ private fun Track(
446446
pointMode = PointMode.Points,
447447
brush = if (outsideFraction) inactiveTickColor
448448
else activeTickColor,
449-
strokeRadius.coerceAtMost(thumbRadius / 2),
449+
strokeWidth = strokeRadius.coerceAtMost(thumbRadius / 2),
450450
cap = StrokeCap.Round
451451
)
452452
}

slider/src/main/java/com/smarttoolfactory/slider/DimensionUtil.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ package com.smarttoolfactory.slider
77
* @param end of interval
88
* @param amount e closed unit interval [0, 1]
99
*/
10-
fun lerp(start: Float, end: Float, amount: Float): Float {
10+
internal fun lerp(start: Float, end: Float, amount: Float): Float {
1111
return (1 - amount) * start + amount * (end - start)
1212
}
1313

1414
/**
1515
* Scale x1 from start1..end1 range to start2..end2 range
1616
1717
*/
18-
fun scale(start1: Float, end1: Float, pos: Float, start2: Float, end2: Float) =
18+
internal fun scale(start1: Float, end1: Float, pos: Float, start2: Float, end2: Float) =
1919
lerp(start2, end2, calculateFraction(start1, end1, pos))
2020

2121
/**
2222
* Scale x.start, x.endInclusive from a1..b1 range to a2..b2 range
2323
*/
24-
fun scale(
24+
internal fun scale(
2525
start1: Float,
2626
end1: Float,
2727
range: ClosedFloatingPointRange<Float>,

slider/src/main/java/com/smarttoolfactory/slider/MinimumTouch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlin.math.roundToInt
1616

1717
@OptIn(ExperimentalMaterialApi::class)
1818
@Suppress("ModifierInspectorInfo")
19-
fun Modifier.minimumTouchTargetSize(): Modifier = composed(
19+
internal fun Modifier.minimumTouchTargetSize(): Modifier = composed(
2020
inspectorInfo = debugInspectorInfo {
2121
name = "minimumTouchTargetSize"
2222

0 commit comments

Comments
 (0)