Remove magic value from UnittoSlider

adjusted wave height
This commit is contained in:
Sad Ellie 2024-01-08 14:58:48 +03:00
parent d257b9cad3
commit a726c4c5bf

View File

@ -18,6 +18,7 @@
package com.sadellie.unitto.core.ui.common package com.sadellie.unitto.core.ui.common
import androidx.annotation.FloatRange
import androidx.compose.animation.core.Spring import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.spring import androidx.compose.animation.core.spring
@ -77,12 +78,13 @@ fun UnittoSlider(
private fun SquigglyTrack( private fun SquigglyTrack(
sliderState: SliderState, sliderState: SliderState,
eachWaveWidth: Float = 80f, eachWaveWidth: Float = 80f,
@FloatRange(0.0, 1.0) waveHeight: Float = 0.7f,
strokeWidth: Float = 15f, strokeWidth: Float = 15f,
filledColor: Color = MaterialTheme.colorScheme.primary, filledColor: Color = MaterialTheme.colorScheme.primary,
unfilledColor: Color = MaterialTheme.colorScheme.surfaceVariant unfilledColor: Color = MaterialTheme.colorScheme.surfaceVariant
) { ) {
val coroutineScope = rememberCoroutineScope() val coroutineScope = rememberCoroutineScope()
var direct by remember { mutableFloatStateOf(0.72f) } var direct by remember { mutableFloatStateOf(waveHeight * (100f - strokeWidth * 2f ) / 100f ) }
val animatedDirect = animateFloatAsState( val animatedDirect = animateFloatAsState(
targetValue = direct, targetValue = direct,
animationSpec = spring(stiffness = Spring.StiffnessLow), animationSpec = spring(stiffness = Spring.StiffnessLow),