Skip to content

Commit 3b796ba

Browse files
change ColorBrush to SliderColorBrush
1 parent dc3664a commit 3b796ba

File tree

4 files changed

+60
-61
lines changed

4 files changed

+60
-61
lines changed

colorpicker/src/main/java/com/smarttoolfactory/colorpicker/selector/gradient/SliderWithPercent.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.smarttoolfactory.colorpicker.selector.gradient
22

33
import androidx.compose.foundation.layout.Row
44
import androidx.compose.foundation.layout.Spacer
5-
import androidx.compose.foundation.layout.padding
65
import androidx.compose.foundation.layout.width
76
import androidx.compose.material.Text
87
import androidx.compose.runtime.Composable
@@ -13,7 +12,7 @@ import androidx.compose.ui.unit.dp
1312
import androidx.compose.ui.unit.sp
1413
import com.smarttoolfactory.colorpicker.ui.Grey400
1514
import com.smarttoolfactory.colorpicker.util.fractionToIntPercent
16-
import com.smarttoolfactory.slider.ColorBrush
15+
import com.smarttoolfactory.slider.SliderBrushColor
1716
import com.smarttoolfactory.slider.ColorfulSlider
1817
import com.smarttoolfactory.slider.MaterialSliderDefaults
1918
import com.smarttoolfactory.slider.ui.InactiveTrackColor
@@ -47,7 +46,7 @@ internal fun SliderWithPercent(
4746
thumbRadius = 10.dp,
4847
trackHeight = 8.dp,
4948
colors = MaterialSliderDefaults.materialColors(
50-
inactiveTrackColor = ColorBrush(InactiveTrackColor)
49+
inactiveTrackColor = SliderBrushColor(InactiveTrackColor)
5150
)
5251
)
5352
Spacer(modifier = Modifier.width(10.dp))

colorpicker/src/main/java/com/smarttoolfactory/colorpicker/slider/Slider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import androidx.compose.ui.unit.dp
1414
import com.smarttoolfactory.colorpicker.ui.brush.*
1515
import com.smarttoolfactory.colorpicker.util.roundToTwoDigits
1616
import com.smarttoolfactory.colorpicker.widget.drawChecker
17-
import com.smarttoolfactory.slider.ColorBrush
17+
import com.smarttoolfactory.slider.SliderBrushColor
1818
import com.smarttoolfactory.slider.ColorfulSlider
1919
import com.smarttoolfactory.slider.MaterialSliderDefaults
2020

@@ -379,7 +379,7 @@ fun CheckeredColorfulSlider(
379379
valueRange = valueRange,
380380
coerceThumbInTrack = true,
381381
colors = MaterialSliderDefaults.materialColors(
382-
activeTrackColor = ColorBrush(brush = brush),
382+
activeTrackColor = SliderBrushColor(brush = brush),
383383
),
384384
drawInactiveTrack = false
385385
)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ fun ColorfulSlider(
6969
* of steps between min and max values:
7070
*
7171
* Material Slider allows to choose height for track and thumb radius and selection between
72-
* [Color] or [Brush] using [ColorBrush]. If brush of [ColorBrush.brush] is not null gradient
73-
* provided in this [Brush] is used for drawing otherwise solid color [ColorBrush.solidColor] is used.
72+
* [Color] or [Brush] using [SliderBrushColor]. If brush of [SliderBrushColor.brush] is not null gradient
73+
* provided in this [Brush] is used for drawing otherwise solid color [SliderBrushColor.solidColor] is used.
7474
*
7575
* @param value current value of the Slider. If outside of [valueRange] provided, value will be
7676
* coerced to this range.
@@ -273,8 +273,8 @@ private fun SliderImpl(
273273
* If inactive track is to be drawn it's drawn between start and end of canvas. Active track
274274
* is drawn between start and current value.
275275
*
276-
* Drawing both tracks use [ColorBrush] to draw a nullable [Brush] first. If it's not then
277-
* [ColorBrush.solidColor] is used to draw with solid colors provided by [MaterialSliderColors]
276+
* Drawing both tracks use [SliderBrushColor] to draw a nullable [Brush] first. If it's not then
277+
* [SliderBrushColor.solidColor] is used to draw with solid colors provided by [MaterialSliderColors]
278278
*/
279279
@Composable
280280
private fun Track(

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

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import com.smarttoolfactory.slider.ui.ThumbColor
1717
* Data class that contains color or/and brush property for drawing track section of
1818
* [ColorfulSlider]
1919
*/
20-
data class ColorBrush(
20+
data class SliderBrushColor(
2121
val color: Color = Color.Unspecified,
2222
val brush: Brush? = null
2323
) {
@@ -92,68 +92,68 @@ object MaterialSliderDefaults {
9292
InActive Track
9393
*/
9494
@Composable
95-
private fun inactiveTrackSolidColor(color: ColorBrush) =
95+
private fun inactiveTrackSolidColor(color: SliderBrushColor) =
9696
color.color.copy(alpha = InactiveTrackAlpha)
9797

9898
@Composable
99-
private fun disabledInactiveTrackSolidColor(color: ColorBrush) =
99+
private fun disabledInactiveTrackSolidColor(color: SliderBrushColor) =
100100
color.color.copy(alpha = InactiveTrackAlpha)
101101

102102

103103
/*
104104
Tick
105105
*/
106106
@Composable
107-
private fun activeTickSolidColor(color: ColorBrush) =
107+
private fun activeTickSolidColor(color: SliderBrushColor) =
108108
contentColorFor(color.color).copy(alpha = SliderDefaults.TickAlpha)
109109

110110
@Composable
111-
private fun inActiveTickSolidColor(color: ColorBrush) =
111+
private fun inActiveTickSolidColor(color: SliderBrushColor) =
112112
color.color.copy(alpha = SliderDefaults.TickAlpha)
113113

114114
@Composable
115-
private fun disabledActiveTickSolidColor(color: ColorBrush) =
115+
private fun disabledActiveTickSolidColor(color: SliderBrushColor) =
116116
color.color.copy(alpha = SliderDefaults.DisabledTickAlpha)
117117

118118

119119
@Composable
120-
private fun disabledInactiveTickSolidColor(color: ColorBrush) =
120+
private fun disabledInactiveTickSolidColor(color: SliderBrushColor) =
121121
color.color.copy(alpha = SliderDefaults.DisabledTickAlpha)
122122

123123

124124
/**
125-
* [ColorfulSlider] [ColorBrush] with [MaterialTheme]'s default [Color]s.
125+
* [ColorfulSlider] [SliderBrushColor] with [MaterialTheme]'s default [Color]s.
126126
*/
127127
@Composable
128128
fun defaultColors(
129-
thumbColor: ColorBrush = ColorBrush(
129+
thumbColor: SliderBrushColor = SliderBrushColor(
130130
color = activeThumbSolidColor()
131131
),
132-
disabledThumbColor: ColorBrush = ColorBrush(
132+
disabledThumbColor: SliderBrushColor = SliderBrushColor(
133133
color = disabledThumbSolidColor()
134134
),
135-
activeTrackColor: ColorBrush = ColorBrush(
135+
activeTrackColor: SliderBrushColor = SliderBrushColor(
136136
color = activeTrackSolidColor()
137137
),
138-
disabledActiveTrackColor: ColorBrush = ColorBrush(
138+
disabledActiveTrackColor: SliderBrushColor = SliderBrushColor(
139139
color = disabledActiveTrackSolidColor()
140140
),
141-
inactiveTrackColor: ColorBrush = ColorBrush(
141+
inactiveTrackColor: SliderBrushColor = SliderBrushColor(
142142
color = inactiveTrackSolidColor(activeTrackColor)
143143
),
144-
disabledInactiveTrackColor: ColorBrush = ColorBrush(
144+
disabledInactiveTrackColor: SliderBrushColor = SliderBrushColor(
145145
color = disabledInactiveTrackSolidColor(disabledActiveTrackColor)
146146
),
147-
activeTickColor: ColorBrush = ColorBrush(
147+
activeTickColor: SliderBrushColor = SliderBrushColor(
148148
color = activeTickSolidColor(activeTrackColor)
149149
),
150-
inactiveTickColor: ColorBrush = ColorBrush(
150+
inactiveTickColor: SliderBrushColor = SliderBrushColor(
151151
color = inActiveTickSolidColor(activeTrackColor)
152152
),
153-
disabledActiveTickColor: ColorBrush = ColorBrush(
153+
disabledActiveTickColor: SliderBrushColor = SliderBrushColor(
154154
color = disabledActiveTickSolidColor(color = activeTickColor)
155155
),
156-
disabledInactiveTickColor: ColorBrush = ColorBrush(
156+
disabledInactiveTickColor: SliderBrushColor = SliderBrushColor(
157157
color = disabledInactiveTickSolidColor(
158158
color = disabledInactiveTrackColor
159159
)
@@ -175,39 +175,39 @@ object MaterialSliderDefaults {
175175
}
176176

177177
/**
178-
* [ColorfulSlider] [ColorBrush] set with blue, white and gray [Color] theme.
178+
* [ColorfulSlider] [SliderBrushColor] set with blue, white and gray [Color] theme.
179179
*/
180180
@Composable
181181
fun materialColors(
182-
thumbColor: ColorBrush = ColorBrush(
182+
thumbColor: SliderBrushColor = SliderBrushColor(
183183
color = ThumbColor
184184
),
185-
disabledThumbColor: ColorBrush = ColorBrush(
185+
disabledThumbColor: SliderBrushColor = SliderBrushColor(
186186
color = disabledThumbSolidColor()
187187
),
188-
activeTrackColor: ColorBrush = ColorBrush(
188+
activeTrackColor: SliderBrushColor = SliderBrushColor(
189189
color = ActiveTrackColor
190190
),
191-
disabledActiveTrackColor: ColorBrush = ColorBrush(
191+
disabledActiveTrackColor: SliderBrushColor = SliderBrushColor(
192192
color = disabledActiveTrackSolidColor()
193193
),
194-
inactiveTrackColor: ColorBrush = ColorBrush(
194+
inactiveTrackColor: SliderBrushColor = SliderBrushColor(
195195
color = inactiveTrackSolidColor(activeTrackColor)
196196
),
197-
disabledInactiveTrackColor: ColorBrush = ColorBrush(
197+
disabledInactiveTrackColor: SliderBrushColor = SliderBrushColor(
198198
color = disabledActiveTrackColor.color.copy(alpha = DisabledInactiveTrackAlpha)
199199

200200
),
201-
activeTickColor: ColorBrush = ColorBrush(
201+
activeTickColor: SliderBrushColor = SliderBrushColor(
202202
color = activeTickSolidColor(activeTrackColor)
203203
),
204-
inactiveTickColor: ColorBrush = ColorBrush(
204+
inactiveTickColor: SliderBrushColor = SliderBrushColor(
205205
color = inActiveTickSolidColor(activeTrackColor)
206206
),
207-
disabledActiveTickColor: ColorBrush = ColorBrush(
207+
disabledActiveTickColor: SliderBrushColor = SliderBrushColor(
208208
color = disabledActiveTickSolidColor(activeTickColor)
209209
),
210-
disabledInactiveTickColor: ColorBrush = ColorBrush(
210+
disabledInactiveTickColor: SliderBrushColor = SliderBrushColor(
211211
color = disabledInactiveTickSolidColor(disabledInactiveTrackColor)
212212
)
213213
): MaterialSliderColors {
@@ -227,20 +227,20 @@ object MaterialSliderDefaults {
227227
}
228228

229229
/**
230-
* [ColorfulSlider] [ColorBrush] set with no predefined [Color]s.
230+
* [ColorfulSlider] [SliderBrushColor] set with no predefined [Color]s.
231231
*/
232232
@Composable
233233
fun customColors(
234-
thumbColor: ColorBrush,
235-
disabledThumbColor: ColorBrush,
236-
activeTrackColor: ColorBrush,
237-
disabledActiveTrackColor: ColorBrush,
238-
inactiveTrackColor: ColorBrush,
239-
disabledInactiveTrackColor: ColorBrush,
240-
activeTickColor: ColorBrush,
241-
inactiveTickColor: ColorBrush,
242-
disabledActiveTickColor: ColorBrush,
243-
disabledInactiveTickColor: ColorBrush
234+
thumbColor: SliderBrushColor,
235+
disabledThumbColor: SliderBrushColor,
236+
activeTrackColor: SliderBrushColor,
237+
disabledActiveTrackColor: SliderBrushColor,
238+
inactiveTrackColor: SliderBrushColor,
239+
disabledInactiveTrackColor: SliderBrushColor,
240+
activeTickColor: SliderBrushColor,
241+
inactiveTickColor: SliderBrushColor,
242+
disabledActiveTickColor: SliderBrushColor,
243+
disabledInactiveTickColor: SliderBrushColor
244244

245245
): MaterialSliderColors {
246246

@@ -259,16 +259,16 @@ object MaterialSliderDefaults {
259259
}
260260

261261
class DefaultMaterialSliderColors(
262-
private val thumbColor: ColorBrush,
263-
private val disabledThumbColor: ColorBrush,
264-
private val activeTrackColor: ColorBrush,
265-
private val disabledActiveTrackColor: ColorBrush,
266-
private val inactiveTrackColor: ColorBrush,
267-
private val disabledInactiveTrackColor: ColorBrush,
268-
private val activeTickColor: ColorBrush = ColorBrush(),
269-
private val inactiveTickColor: ColorBrush = ColorBrush(),
270-
private val disabledActiveTickColor: ColorBrush = ColorBrush(),
271-
private val disabledInactiveTickColor: ColorBrush = ColorBrush(),
262+
private val thumbColor: SliderBrushColor,
263+
private val disabledThumbColor: SliderBrushColor,
264+
private val activeTrackColor: SliderBrushColor,
265+
private val disabledActiveTrackColor: SliderBrushColor,
266+
private val inactiveTrackColor: SliderBrushColor,
267+
private val disabledInactiveTrackColor: SliderBrushColor,
268+
private val activeTickColor: SliderBrushColor = SliderBrushColor(),
269+
private val inactiveTickColor: SliderBrushColor = SliderBrushColor(),
270+
private val disabledActiveTickColor: SliderBrushColor = SliderBrushColor(),
271+
private val disabledInactiveTickColor: SliderBrushColor = SliderBrushColor(),
272272
) : MaterialSliderColors {
273273

274274
@Composable
@@ -361,14 +361,14 @@ object MaterialSliderDefaults {
361361

362362
/**
363363
* Interface for providing thumb, track, and tick colors using [Brush]. When providing
364-
* a [Brush] initially a null check is done whether [ColorBrush.brush] is not null,
364+
* a [Brush] initially a null check is done whether [SliderBrushColor.brush] is not null,
365365
* if it's not null gradient is drawn but when tis non-nullable color is used.
366366
*/
367367
@Stable
368368
interface MaterialSliderColors {
369369

370370
/**
371-
* Represents the [ColorBrush] used for the sliders's thumb, depending on [enabled].
371+
* Represents the [SliderBrushColor] used for the sliders's thumb, depending on [enabled].
372372
*
373373
* @param enabled whether the [Slider] is enabled or not
374374
*/

0 commit comments

Comments
 (0)