[#1280] Improve button sizing

- Applied to both Primary and secondary buttons
- Changelog update
- Closes #1280
This commit is contained in:
Honza Rychnovský 2024-03-04 18:06:44 +01:00 committed by GitHub
parent 5bf7a635ff
commit e000745885
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 67 additions and 44 deletions

View File

@ -16,6 +16,9 @@ directly impact users rather than highlighting other key architectural updates.*
lightwalletd servers in runtime. lightwalletd servers in runtime.
- The About screen now contains a link to the new Zashi Privacy Policy website - The About screen now contains a link to the new Zashi Privacy Policy website
### Fixed
- Button sizing has been updated to align with the design guidelines and preserve stretching if necessary
## [0.2.0 (560)] - 2024-02-27 ## [0.2.0 (560)] - 2024-02-27
### Added ### Added

View File

@ -50,7 +50,8 @@ private fun ButtonComposablePreview() {
GradientSurface { GradientSurface {
Column(Modifier.padding(ZcashTheme.dimens.spacingDefault)) { Column(Modifier.padding(ZcashTheme.dimens.spacingDefault)) {
PrimaryButton(onClick = { }, text = "Primary") PrimaryButton(onClick = { }, text = "Primary")
PrimaryButton(onClick = { }, text = "Primary", showProgressBar = true) PrimaryButton(onClick = { }, text = "Primary...", showProgressBar = true)
PrimaryButton(onClick = { }, text = "Primary Small", minHeight = ZcashTheme.dimens.buttonHeightSmall)
SecondaryButton(onClick = { }, text = "Secondary") SecondaryButton(onClick = { }, text = "Secondary")
TertiaryButton(onClick = { }, text = "Tertiary") TertiaryButton(onClick = { }, text = "Tertiary")
TertiaryButton(onClick = { }, text = "Tertiary", enabled = false) TertiaryButton(onClick = { }, text = "Tertiary", enabled = false)
@ -67,6 +68,8 @@ fun PrimaryButton(
onClick: () -> Unit, onClick: () -> Unit,
text: String, text: String,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
minWidth: Dp = ZcashTheme.dimens.buttonWidth,
minHeight: Dp = ZcashTheme.dimens.buttonHeight,
enabled: Boolean = true, enabled: Boolean = true,
showProgressBar: Boolean = false, showProgressBar: Boolean = false,
buttonColor: Color = MaterialTheme.colorScheme.primary, buttonColor: Color = MaterialTheme.colorScheme.primary,
@ -76,29 +79,34 @@ fun PrimaryButton(
PaddingValues( PaddingValues(
horizontal = ZcashTheme.dimens.spacingNone, horizontal = ZcashTheme.dimens.spacingNone,
vertical = ZcashTheme.dimens.spacingSmall vertical = ZcashTheme.dimens.spacingSmall
) ),
contentPaddingValues: PaddingValues = PaddingValues(all = 16.dp)
) { ) {
Button( Button(
shape = RectangleShape, shape = RectangleShape,
enabled = enabled, enabled = enabled,
contentPadding = contentPaddingValues,
modifier = modifier =
modifier.then(Modifier.fillMaxWidth()) modifier.then(
.padding(outerPaddingValues) Modifier
.shadow( .padding(outerPaddingValues)
contentColor = textColor, .shadow(
strokeColor = buttonColor, contentColor = textColor,
strokeWidth = 1.dp, strokeColor = buttonColor,
offsetX = ZcashTheme.dimens.buttonShadowOffsetX, strokeWidth = 1.dp,
offsetY = ZcashTheme.dimens.buttonShadowOffsetY, offsetX = ZcashTheme.dimens.buttonShadowOffsetX,
spread = ZcashTheme.dimens.buttonShadowSpread, offsetY = ZcashTheme.dimens.buttonShadowOffsetY,
) spread = ZcashTheme.dimens.buttonShadowSpread,
.translationClick( )
// + 6dp to exactly cover the bottom shadow .translationClick(
translationX = ZcashTheme.dimens.buttonShadowOffsetX + 6.dp, // + 6dp to exactly cover the bottom shadow
translationY = ZcashTheme.dimens.buttonShadowOffsetX + 6.dp translationX = ZcashTheme.dimens.buttonShadowOffsetX + 6.dp,
) translationY = ZcashTheme.dimens.buttonShadowOffsetX + 6.dp
.defaultMinSize(ZcashTheme.dimens.buttonWidth, ZcashTheme.dimens.buttonHeight) )
.border(1.dp, Color.Black), .defaultMinSize(minWidth, minHeight)
.fillMaxWidth()
.border(1.dp, Color.Black)
),
colors = colors =
buttonColors( buttonColors(
containerColor = buttonColor, containerColor = buttonColor,
@ -107,9 +115,7 @@ fun PrimaryButton(
), ),
onClick = onClick, onClick = onClick,
) { ) {
ConstraintLayout( ConstraintLayout {
modifier = Modifier.fillMaxWidth(),
) {
val (title, spacer, progress) = createRefs() val (title, spacer, progress) = createRefs()
Text( Text(
@ -162,35 +168,42 @@ fun SecondaryButton(
onClick: () -> Unit, onClick: () -> Unit,
text: String, text: String,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
minWidth: Dp = ZcashTheme.dimens.buttonWidth,
minHeight: Dp = ZcashTheme.dimens.buttonHeight,
enabled: Boolean = true,
buttonColor: Color = MaterialTheme.colorScheme.secondary,
textColor: Color = MaterialTheme.colorScheme.onSecondary,
outerPaddingValues: PaddingValues = outerPaddingValues: PaddingValues =
PaddingValues( PaddingValues(
horizontal = ZcashTheme.dimens.spacingNone, horizontal = ZcashTheme.dimens.spacingNone,
vertical = ZcashTheme.dimens.spacingSmall vertical = ZcashTheme.dimens.spacingSmall
), ),
enabled: Boolean = true, contentPaddingValues: PaddingValues = PaddingValues(all = 16.dp)
buttonColor: Color = MaterialTheme.colorScheme.secondary,
textColor: Color = MaterialTheme.colorScheme.onSecondary,
) { ) {
Button( Button(
shape = RectangleShape, shape = RectangleShape,
enabled = enabled, enabled = enabled,
contentPadding = contentPaddingValues,
modifier = modifier =
modifier.then(Modifier.fillMaxWidth()) modifier.then(
.padding(outerPaddingValues) Modifier
.shadow( .padding(outerPaddingValues)
contentColor = textColor, .shadow(
strokeColor = textColor, contentColor = textColor,
offsetX = ZcashTheme.dimens.buttonShadowOffsetX, strokeColor = textColor,
offsetY = ZcashTheme.dimens.buttonShadowOffsetY, offsetX = ZcashTheme.dimens.buttonShadowOffsetX,
spread = ZcashTheme.dimens.buttonShadowSpread, offsetY = ZcashTheme.dimens.buttonShadowOffsetY,
) spread = ZcashTheme.dimens.buttonShadowSpread,
.translationClick( )
// + 6dp to exactly cover the bottom shadow .translationClick(
translationX = ZcashTheme.dimens.buttonShadowOffsetX + 6.dp, // + 6dp to exactly cover the bottom shadow
translationY = ZcashTheme.dimens.buttonShadowOffsetX + 6.dp translationX = ZcashTheme.dimens.buttonShadowOffsetX + 6.dp,
) translationY = ZcashTheme.dimens.buttonShadowOffsetX + 6.dp
.defaultMinSize(ZcashTheme.dimens.buttonWidth, ZcashTheme.dimens.buttonHeight) )
.border(1.dp, Color.Black), .defaultMinSize(minWidth, minHeight)
.fillMaxWidth()
.border(1.dp, Color.Black)
),
colors = colors =
buttonColors( buttonColors(
containerColor = buttonColor, containerColor = buttonColor,

View File

@ -25,6 +25,7 @@ data class Dimens(
val buttonShadowSpread: Dp, val buttonShadowSpread: Dp,
val buttonWidth: Dp, val buttonWidth: Dp,
val buttonHeight: Dp, val buttonHeight: Dp,
val buttonHeightSmall: Dp,
// Chip // Chip
val chipShadowElevation: Dp, val chipShadowElevation: Dp,
val chipStroke: Dp, val chipStroke: Dp,
@ -65,7 +66,8 @@ private val defaultDimens =
buttonShadowOffsetY = 20.dp, buttonShadowOffsetY = 20.dp,
buttonShadowSpread = 10.dp, buttonShadowSpread = 10.dp,
buttonWidth = 244.dp, buttonWidth = 244.dp,
buttonHeight = 70.dp, buttonHeight = 56.dp,
buttonHeightSmall = 38.dp,
chipShadowElevation = 4.dp, chipShadowElevation = 4.dp,
chipStroke = 0.5.dp, chipStroke = 0.5.dp,
circularScreenProgressWidth = 48.dp, circularScreenProgressWidth = 48.dp,

View File

@ -240,10 +240,14 @@ val LocalExtendedTypography =
fontSize = 14.sp, fontSize = 14.sp,
lineHeight = 20.sp lineHeight = 20.sp
), ),
buttonText = PrimaryTypography.bodySmall, buttonText =
PrimaryTypography.bodySmall.copy(
fontWeight = FontWeight.Medium
),
buttonTextSmall = buttonTextSmall =
PrimaryTypography.bodySmall.copy( PrimaryTypography.bodySmall.copy(
fontSize = 11.sp fontSize = 11.sp,
fontWeight = FontWeight.Medium
), ),
checkboxText = checkboxText =
PrimaryTypography.bodyMedium.copy( PrimaryTypography.bodyMedium.copy(

View File

@ -272,6 +272,7 @@ fun TransparentBalancePanel(
text = stringResource(R.string.balances_transparent_balance_shield), text = stringResource(R.string.balances_transparent_balance_shield),
textStyle = ZcashTheme.extendedTypography.buttonTextSmall, textStyle = ZcashTheme.extendedTypography.buttonTextSmall,
enabled = shieldState == ShieldState.Available, enabled = shieldState == ShieldState.Available,
minHeight = ZcashTheme.dimens.buttonHeightSmall,
outerPaddingValues = outerPaddingValues =
PaddingValues( PaddingValues(
horizontal = 54.dp, horizontal = 54.dp,