Tweak BitwardenListHeaderText and BitwardenWideSwitch to follow patterns. (#195)

This commit is contained in:
David Perez 2023-11-01 16:14:54 -05:00 committed by Álison Fernandes
parent c6cf9712e1
commit 5dbe07a2cc
5 changed files with 70 additions and 58 deletions

View file

@ -24,7 +24,10 @@ fun BitwardenListHeaderText(
text = label,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = modifier.padding(top = 8.dp),
modifier = modifier.padding(
top = 12.dp,
bottom = 4.dp,
),
)
}

View file

@ -4,8 +4,10 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.MaterialTheme
@ -44,7 +46,6 @@ fun BitwardenWideSwitch(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.clickable(
interactionSource = remember { MutableInteractionSource() },
@ -53,9 +54,7 @@ fun BitwardenWideSwitch(
)
.semantics(mergeDescendants = true) {
toggleableState = ToggleableState(isChecked)
if (contentDescription != null) {
this.contentDescription = contentDescription
}
contentDescription?.let { this.contentDescription = it }
}
.then(modifier),
) {
@ -63,8 +62,13 @@ fun BitwardenWideSwitch(
text = label,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface,
modifier = Modifier
.weight(1f)
.padding(vertical = 8.dp),
)
Spacer(modifier = Modifier.width(16.dp))
Switch(
modifier = Modifier
.height(56.dp),

View file

@ -161,7 +161,7 @@ private fun ContentColum(
isChecked = state.isSubmitCrashLogsEnabled,
onCheckedChange = onSubmitCrashLogsCheckedChange,
modifier = Modifier
.defaultMinSize(56.dp)
.fillMaxWidth()
.padding(horizontal = 16.dp),
contentDescription = stringResource(id = R.string.submit_crash_logs),
)

View file

@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
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
@ -47,14 +46,14 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.toDp
import com.x8bit.bitwarden.ui.platform.components.BitwardenIconButtonWithResource
import com.x8bit.bitwarden.ui.platform.components.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.BitwardenMediumTopAppBar
import com.x8bit.bitwarden.ui.platform.components.BitwardenMultiSelectButton
import com.x8bit.bitwarden.ui.platform.components.BitwardenOverflowActionItem
import com.x8bit.bitwarden.ui.platform.components.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.BitwardenReadOnlyTextFieldWithActions
import com.x8bit.bitwarden.ui.platform.components.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.BitwardenIconButtonWithResource
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Passcode.PasscodeType.Password.Companion.PASSWORD_LENGTH_SLIDER_MAX
@ -167,15 +166,12 @@ private fun ScrollContent(
onMainStateOptionClicked = onMainStateOptionClicked,
)
Row(
Modifier.height(32.dp),
verticalAlignment = Alignment.Bottom,
) {
BitwardenListHeaderText(
label = stringResource(id = R.string.options),
modifier = Modifier.padding(horizontal = 16.dp),
)
}
BitwardenListHeaderText(
label = stringResource(id = R.string.options),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
when (val selectedType = state.selectedType) {
is GeneratorState.MainType.Passcode -> {
@ -419,7 +415,9 @@ private fun PasswordCapitalLettersToggleItem(
label = "A—Z",
isChecked = useCapitals,
onCheckedChange = onPasswordToggleCapitalLettersChange,
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
contentDescription = stringResource(id = R.string.uppercase_ato_z),
)
}
@ -433,7 +431,9 @@ private fun PasswordLowercaseLettersToggleItem(
label = "a—z",
isChecked = useLowercase,
onCheckedChange = onPasswordToggleLowercaseLettersChange,
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
contentDescription = stringResource(id = R.string.lowercase_ato_z),
)
}
@ -447,7 +447,9 @@ private fun PasswordNumbersToggleItem(
label = "0-9",
isChecked = useNumbers,
onCheckedChange = onPasswordToggleNumbersChange,
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
contentDescription = stringResource(id = R.string.numbers_zero_to_nine),
)
}
@ -461,7 +463,9 @@ private fun PasswordSpecialCharactersToggleItem(
label = "!@#$%^&*",
isChecked = useSpecialChars,
onCheckedChange = onPasswordToggleSpecialCharactersChange,
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
contentDescription = stringResource(id = R.string.special_characters),
)
}
@ -539,7 +543,9 @@ private fun PasswordAvoidAmbiguousCharsToggleItem(
label = stringResource(id = R.string.avoid_ambiguous_characters),
isChecked = avoidAmbiguousChars,
onCheckedChange = onPasswordToggleAvoidAmbiguousCharsChange,
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
}
@ -636,7 +642,9 @@ private fun PassphraseCapitalizeToggleItem(
label = stringResource(id = R.string.capitalize),
isChecked = capitalize,
onCheckedChange = onPassphraseCapitalizeToggleChange,
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
}
@ -649,7 +657,9 @@ private fun PassphraseIncludeNumberToggleItem(
label = stringResource(id = R.string.include_number),
isChecked = includeNumber,
onCheckedChange = onPassphraseIncludeNumberToggleChange,
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
}

View file

@ -103,7 +103,6 @@ fun VaultAddItemScreen(
modifier = Modifier
.padding(innerPadding)
.background(MaterialTheme.colorScheme.surface)
.padding(top = 8.dp)
.fillMaxSize()
.verticalScroll(scrollState),
verticalArrangement = Arrangement.spacedBy(16.dp),
@ -111,7 +110,9 @@ fun VaultAddItemScreen(
BitwardenListHeaderText(
label = stringResource(id = R.string.item_information),
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
TypeOptionsItem(
selectedType = state.selectedType,
@ -227,11 +228,10 @@ private fun AddLoginTypeItemContent(
BitwardenListHeaderText(
label = stringResource(id = R.string.authenticator_key),
modifier = Modifier.padding(
top = 8.dp,
start = 16.dp,
end = 16.dp,
),
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp),
)
BitwardenFilledButtonWithIcon(
@ -245,11 +245,10 @@ private fun AddLoginTypeItemContent(
BitwardenListHeaderText(
label = stringResource(id = R.string.ur_is),
modifier = Modifier.padding(
top = 8.dp,
start = 16.dp,
end = 16.dp,
),
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp),
)
BitwardenTextFieldWithActions(
@ -278,11 +277,10 @@ private fun AddLoginTypeItemContent(
BitwardenListHeaderText(
label = stringResource(id = R.string.miscellaneous),
modifier = Modifier.padding(
top = 8.dp,
start = 16.dp,
end = 16.dp,
),
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp),
)
BitwardenMultiSelectButton(
@ -326,11 +324,10 @@ private fun AddLoginTypeItemContent(
BitwardenListHeaderText(
label = stringResource(id = R.string.notes),
modifier = Modifier.padding(
top = 8.dp,
start = 16.dp,
end = 16.dp,
),
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp),
)
Column(
@ -348,11 +345,10 @@ private fun AddLoginTypeItemContent(
BitwardenListHeaderText(
label = stringResource(id = R.string.custom_fields),
modifier = Modifier.padding(
top = 8.dp,
start = 16.dp,
end = 16.dp,
),
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp),
)
BitwardenFilledTonalButton(
@ -365,11 +361,10 @@ private fun AddLoginTypeItemContent(
BitwardenListHeaderText(
label = stringResource(id = R.string.ownership),
modifier = Modifier.padding(
top = 8.dp,
start = 16.dp,
end = 16.dp,
),
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp),
)
BitwardenMultiSelectButton(