Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM-14036: Update the slider UI #4164

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package com.x8bit.bitwarden.ui.platform.components.slider

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Slider
import androidx.compose.material3.SliderDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -21,7 +20,9 @@ import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onPreviewKeyEvent
Expand Down Expand Up @@ -68,12 +69,9 @@ fun BitwardenSlider(
val density = LocalDensity.current
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
.semantics(mergeDescendants = true) {},
modifier = modifier.semantics(mergeDescendants = true) {},
) {
OutlinedTextField(
TextField(
value = sliderValue.toString(),
textStyle = BitwardenTheme.typography.bodyLarge,
readOnly = true,
Expand All @@ -90,7 +88,11 @@ fun BitwardenSlider(
},
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
colors = bitwardenTextFieldColors(),
colors = bitwardenTextFieldColors(
disabledBorderColor = Color.Transparent,
focusedBorderColor = Color.Transparent,
unfocusedBorderColor = Color.Transparent,
),
modifier = Modifier
.onPreviewKeyEvent { keyEvent ->
when (keyEvent.key) {
Expand Down Expand Up @@ -125,6 +127,7 @@ fun BitwardenSlider(
interactionSource = remember { MutableInteractionSource() },
colors = bitwardenSliderColors(),
thumbSize = DpSize(width = 20.dp, height = 20.dp),
modifier = Modifier.shadow(elevation = 2.dp, shape = CircleShape),
)
},
track = { sliderState ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ private fun ColumnScope.PasswordTypeContent(
range = passwordTypeState.computedMinimumLength..passwordTypeState.maxLength,
sliderTag = "PasswordLengthSlider",
valueTag = "PasswordLengthLabel",
modifier = Modifier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ‘

.fillMaxWidth()
.padding(end = 16.dp),
)

Spacer(modifier = Modifier.height(8.dp))
Expand Down