Skip to content

Commit 394a906

Browse files
committed
style: apply spotless
1 parent af26b80 commit 394a906

File tree

7 files changed

+20
-33
lines changed

7 files changed

+20
-33
lines changed

demo/src/main/java/io/monstarlab/mosaic/MainActivity.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
66
import androidx.activity.enableEdgeToEdge
7-
import androidx.compose.material3.Slider
87
import androidx.compose.material3.Text
98
import androidx.compose.runtime.Composable
109
import androidx.compose.ui.Modifier
1110
import androidx.compose.ui.tooling.preview.Preview
1211
import io.monstarlab.mosaic.features.SliderDemo
1312
import io.monstarlab.mosaic.ui.theme.MosaicTheme
14-
import kotlinx.coroutines.delay
15-
import kotlin.time.Duration
16-
import kotlin.time.Duration.Companion.seconds
1713

1814
class MainActivity : ComponentActivity() {
1915
override fun onCreate(savedInstanceState: Bundle?) {

demo/src/main/java/io/monstarlab/mosaic/features/SliderDemo.kt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import androidx.compose.material3.Text
1212
import androidx.compose.runtime.Composable
1313
import androidx.compose.runtime.getValue
1414
import androidx.compose.runtime.mutableFloatStateOf
15-
import androidx.compose.runtime.mutableStateOf
1615
import androidx.compose.runtime.remember
1716
import androidx.compose.runtime.setValue
1817
import androidx.compose.ui.Modifier
@@ -25,20 +24,19 @@ import io.monstarlab.mosaic.slider.SliderColors
2524
import androidx.compose.material3.Slider as MaterialSlider
2625
@Composable
2726
fun SliderDemo() = Scaffold(modifier = Modifier) {
28-
2927
var materialSliderValue by remember { mutableFloatStateOf(50f) }
3028
var mosaicSliderValue by remember { mutableFloatStateOf(50f) }
31-
32-
33-
Column(modifier = Modifier
34-
.padding(it)
35-
.padding(16.dp)
36-
.background(Color.LightGray)) {
3729

30+
Column(
31+
modifier = Modifier
32+
.padding(it)
33+
.padding(16.dp)
34+
.background(Color.LightGray),
35+
) {
3836
MaterialSlider(
3937
value = materialSliderValue,
40-
onValueChange = { materialSliderValue = it},
41-
valueRange = 0f..100f
38+
onValueChange = { materialSliderValue = it },
39+
valueRange = 0f..100f,
4240
)
4341
Text(text = materialSliderValue.toString())
4442

@@ -49,13 +47,11 @@ fun SliderDemo() = Scaffold(modifier = Modifier) {
4947
onValueChange = { mosaicSliderValue = it },
5048
colors = SliderColors(Color.Red),
5149
modifier = Modifier.clip(RoundedCornerShape(2.dp)),
52-
range = 0f..100f
50+
range = 0f..100f,
5351
) {
5452
Box(modifier = Modifier.background(Color.Yellow).size(32.dp))
5553
}
5654
Text(text = mosaicSliderValue.toString())
57-
58-
5955
}
6056
}
6157

slider/src/main/java/io/monstarlab/mosaic/slider/MathUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ internal fun scale(a1: Float, b1: Float, x1: Float, a2: Float, b2: Float) =
66
lerp(a2, b2, calcFraction(a1, b1, x1))
77

88
internal fun calcFraction(a: Float, b: Float, pos: Float) =
9-
(if (b - a == 0f) 0f else (pos - a) / (b - a)).coerceIn(0f, 1f)
9+
(if (b - a == 0f) 0f else (pos - a) / (b - a)).coerceIn(0f, 1f)

slider/src/main/java/io/monstarlab/mosaic/slider/Slider.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.Box
88
import androidx.compose.foundation.layout.size
99
import androidx.compose.foundation.shape.CircleShape
1010
import androidx.compose.runtime.Composable
11-
import androidx.compose.runtime.LaunchedEffect
1211
import androidx.compose.runtime.remember
1312
import androidx.compose.ui.Modifier
1413
import androidx.compose.ui.graphics.Color
@@ -52,7 +51,7 @@ public fun Slider(
5251
)
5352
},
5453
onDimensionsResolved = state::updateDimensions,
55-
value = state.valueAsFraction
54+
value = state.valueAsFraction,
5655
)
5756
}
5857

slider/src/main/java/io/monstarlab/mosaic/slider/SliderLayout.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public fun SliderLayout(
6262
layout(sliderWidth, sliderHeight) {
6363
trackPlaceable.placeRelative(
6464
trackOffsetX,
65-
trackOffsetY
65+
trackOffsetY,
6666
)
6767
thumbPlaceable.placeRelative(
6868
thumbOffsetX,
69-
thumbOffsetY
69+
thumbOffsetY,
7070
)
71+
}
7172
}
7273
}
73-
}
7474

7575
internal enum class SliderLayoutElements {
7676
Track,

slider/src/main/java/io/monstarlab/mosaic/slider/SliderState.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import androidx.compose.runtime.remember
1111
import androidx.compose.runtime.setValue
1212

1313
public class SliderState(
14-
private val valueDistribution: SliderValueDistribution
14+
private val valueDistribution: SliderValueDistribution,
1515
) : DraggableState {
1616

1717
private var isDragging by mutableStateOf(false)
@@ -39,7 +39,6 @@ public class SliderState(
3939
override fun dragBy(pixels: Float): Unit = dispatchRawDelta(pixels)
4040
}
4141

42-
4342
override fun dispatchRawDelta(delta: Float) {
4443
rawOffset += delta
4544
onValueChange(scaleToUserValue(rawOffset))
@@ -56,15 +55,13 @@ public class SliderState(
5655
this.thumbWidth = thumbWidth
5756
}
5857

59-
private fun scaleToUserValue(value: Float) : Float {
58+
private fun scaleToUserValue(value: Float): Float {
6059
return scale(0f, totalWidth, value, range.start, range.endInclusive)
6160
}
6261

63-
private fun scaleToOffset(value: Float) : Float {
62+
private fun scaleToOffset(value: Float): Float {
6463
return scale(range.start, range.endInclusive, value, 0f, totalWidth)
6564
}
66-
67-
6865
}
6966

7067
@Composable

slider/src/main/java/io/monstarlab/mosaic/slider/SliderValueDistribution.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ package io.monstarlab.mosaic.slider
22

33
public interface SliderValueDistribution {
44

5-
public fun interpolate(value: Float) : Float
6-
7-
public fun inverse(value: Float) : Float
5+
public fun interpolate(value: Float): Float
86

7+
public fun inverse(value: Float): Float
98

109
public companion object {
1110
public val Linear: SliderValueDistribution = object : SliderValueDistribution {
@@ -18,4 +17,4 @@ public interface SliderValueDistribution {
1817
}
1918
}
2019
}
21-
}
20+
}

0 commit comments

Comments
 (0)