Update Slider UI after Compose BOM update (#3885)

This commit is contained in:
David Perez 2024-09-09 14:50:48 -05:00 committed by GitHub
parent b7544ef7f4
commit fa93985a2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@
package com.x8bit.bitwarden.ui.tools.feature.generator
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
@ -49,6 +50,7 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.hilt.navigation.compose.hiltViewModel
@ -582,6 +584,7 @@ private fun ColumnScope.PasswordTypeContent(
)
}
@OptIn(ExperimentalMaterial3Api::class)
@Suppress("LongMethod")
@Composable
private fun PasswordLengthSliderItem(
@ -646,6 +649,12 @@ private fun PasswordLengthSliderItem(
.width(16.dp + labelTextWidth + 16.dp),
)
val colors = SliderDefaults.colors(
activeTickColor = Color.Transparent,
inactiveTickColor = Color.Transparent,
disabledActiveTickColor = Color.Transparent,
disabledInactiveTickColor = Color.Transparent,
)
Slider(
value = sliderValue.toFloat(),
onValueChange = { newValue ->
@ -656,16 +665,27 @@ private fun PasswordLengthSliderItem(
},
valueRange = sliderRange,
steps = maxValue - 1,
colors = SliderDefaults.colors(
activeTickColor = Color.Transparent,
inactiveTickColor = Color.Transparent,
disabledActiveTickColor = Color.Transparent,
disabledInactiveTickColor = Color.Transparent,
),
colors = colors,
thumb = {
SliderDefaults.Thumb(
interactionSource = remember { MutableInteractionSource() },
colors = colors,
thumbSize = DpSize(width = 20.dp, height = 20.dp),
)
},
track = { sliderState ->
SliderDefaults.Track(
modifier = Modifier.height(height = 4.dp),
drawStopIndicator = null,
colors = colors,
sliderState = sliderState,
thumbTrackGapSize = 0.dp,
)
},
modifier = Modifier
.focusProperties { canFocus = false }
.testTag("PasswordLengthSlider")
.weight(1f),
.testTag(tag = "PasswordLengthSlider")
.weight(weight = 1f),
)
}
}