mirror of
https://github.com/bitwarden/android.git
synced 2024-11-22 01:16:02 +03:00
Clean up text field typography (#4011)
This commit is contained in:
parent
53b1bec42b
commit
757baf0290
5 changed files with 8 additions and 7 deletions
|
@ -24,6 +24,7 @@ import com.x8bit.bitwarden.R
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.mirrorIfRtl
|
import com.x8bit.bitwarden.ui.platform.base.util.mirrorIfRtl
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.tabNavigation
|
import com.x8bit.bitwarden.ui.platform.base.util.tabNavigation
|
||||||
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
|
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
|
||||||
|
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Bitwarden styled [TopAppBar] that assumes the following components:
|
* Represents a Bitwarden styled [TopAppBar] that assumes the following components:
|
||||||
|
@ -74,6 +75,7 @@ fun BitwardenSearchTopAppBar(
|
||||||
focusedIndicatorColor = Color.Transparent,
|
focusedIndicatorColor = Color.Transparent,
|
||||||
unfocusedIndicatorColor = Color.Transparent,
|
unfocusedIndicatorColor = Color.Transparent,
|
||||||
),
|
),
|
||||||
|
textStyle = BitwardenTheme.typography.bodyLarge,
|
||||||
placeholder = { Text(text = placeholder) },
|
placeholder = { Text(text = placeholder) },
|
||||||
value = searchTerm,
|
value = searchTerm,
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
|
|
|
@ -27,7 +27,7 @@ fun BitwardenHiddenPasswordField(
|
||||||
) {
|
) {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
textStyle = BitwardenTheme.typography.bodyLarge,
|
textStyle = BitwardenTheme.typography.sensitiveInfoSmall,
|
||||||
label = { Text(text = label) },
|
label = { Text(text = label) },
|
||||||
value = value,
|
value = value,
|
||||||
onValueChange = { },
|
onValueChange = { },
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.x8bit.bitwarden.ui.platform.components.field
|
||||||
|
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.LocalTextStyle
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -61,7 +60,7 @@ fun BitwardenTextField(
|
||||||
singleLine: Boolean = true,
|
singleLine: Boolean = true,
|
||||||
readOnly: Boolean = false,
|
readOnly: Boolean = false,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
textStyle: TextStyle? = null,
|
textStyle: TextStyle = BitwardenTheme.typography.bodyLarge,
|
||||||
shouldAddCustomLineBreaks: Boolean = false,
|
shouldAddCustomLineBreaks: Boolean = false,
|
||||||
keyboardType: KeyboardType = KeyboardType.Text,
|
keyboardType: KeyboardType = KeyboardType.Text,
|
||||||
isError: Boolean = false,
|
isError: Boolean = false,
|
||||||
|
@ -70,12 +69,11 @@ fun BitwardenTextField(
|
||||||
) {
|
) {
|
||||||
var widthPx by remember { mutableIntStateOf(0) }
|
var widthPx by remember { mutableIntStateOf(0) }
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
val currentTextStyle = textStyle ?: LocalTextStyle.current
|
|
||||||
val formattedText = if (shouldAddCustomLineBreaks) {
|
val formattedText = if (shouldAddCustomLineBreaks) {
|
||||||
value.withLineBreaksAtWidth(
|
value.withLineBreaksAtWidth(
|
||||||
// Adjust for built in padding
|
// Adjust for built in padding
|
||||||
widthPx = widthPx - 16.dp.toPx(),
|
widthPx = widthPx - 16.dp.toPx(),
|
||||||
monospacedTextStyle = currentTextStyle,
|
monospacedTextStyle = textStyle,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
value
|
value
|
||||||
|
@ -114,7 +112,7 @@ fun BitwardenTextField(
|
||||||
onValueChange = onValueChange,
|
onValueChange = onValueChange,
|
||||||
singleLine = singleLine,
|
singleLine = singleLine,
|
||||||
readOnly = readOnly,
|
readOnly = readOnly,
|
||||||
textStyle = currentTextStyle,
|
textStyle = textStyle,
|
||||||
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
|
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
|
||||||
isError = isError,
|
isError = isError,
|
||||||
visualTransformation = visualTransformation,
|
visualTransformation = visualTransformation,
|
||||||
|
|
|
@ -49,7 +49,7 @@ fun BitwardenTextFieldWithActions(
|
||||||
value: String,
|
value: String,
|
||||||
onValueChange: (String) -> Unit,
|
onValueChange: (String) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
textStyle: TextStyle? = null,
|
textStyle: TextStyle = BitwardenTheme.typography.bodyLarge,
|
||||||
shouldAddCustomLineBreaks: Boolean = false,
|
shouldAddCustomLineBreaks: Boolean = false,
|
||||||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||||
readOnly: Boolean = false,
|
readOnly: Boolean = false,
|
||||||
|
|
|
@ -74,6 +74,7 @@ fun BitwardenSlider(
|
||||||
) {
|
) {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = sliderValue.toString(),
|
value = sliderValue.toString(),
|
||||||
|
textStyle = BitwardenTheme.typography.bodyLarge,
|
||||||
readOnly = true,
|
readOnly = true,
|
||||||
onValueChange = { },
|
onValueChange = { },
|
||||||
label = {
|
label = {
|
||||||
|
|
Loading…
Reference in a new issue