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-15041: Update stepper buttons #4330

Merged
merged 1 commit into from
Nov 19, 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
@@ -0,0 +1,55 @@
package com.x8bit.bitwarden.ui.platform.components.button

import androidx.annotation.DrawableRes
import androidx.compose.material3.FilledIconButton
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.button.color.bitwardenFilledIconButtonColors
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme

/**
* A filled icon button that displays an icon.
Copy link
Collaborator

Choose a reason for hiding this comment

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

๐Ÿ‘จโ€๐Ÿณ ๐Ÿ’‹

*
* @param vectorIconRes Icon to display on the button.
* @param contentDescription The content description for this icon button.
* @param onClick Callback for when the icon button is clicked.
* @param modifier A [Modifier] for the composable.
* @param isEnabled Whether or not the button should be enabled.
*/
@Composable
fun BitwardenFilledIconButton(
@DrawableRes vectorIconRes: Int,
contentDescription: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
isEnabled: Boolean = true,
) {
FilledIconButton(
modifier = modifier.semantics(mergeDescendants = true) {},
onClick = onClick,
colors = bitwardenFilledIconButtonColors(),
enabled = isEnabled,
) {
Icon(
painter = rememberVectorPainter(id = vectorIconRes),
contentDescription = contentDescription,
)
}
}

@Preview(showBackground = true)
@Composable
private fun BitwardenFilledIconButton_preview() {
BitwardenTheme {
BitwardenFilledIconButton(
vectorIconRes = R.drawable.ic_question_circle,
contentDescription = "Sample Icon",
onClick = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme

/**
* Provides a default set of Bitwarden-styled colors for a filled icon button.
*/
@Composable
fun bitwardenFilledIconButtonColors(): IconButtonColors = IconButtonColors(
containerColor = BitwardenTheme.colorScheme.filledButton.background,
contentColor = BitwardenTheme.colorScheme.filledButton.foreground,
disabledContainerColor = BitwardenTheme.colorScheme.filledButton.backgroundDisabled,
disabledContentColor = BitwardenTheme.colorScheme.filledButton.foregroundDisabled,
)

/**
* Provides a default set of Bitwarden-styled colors for a standard icon button.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.compose.ui.text.input.KeyboardType
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.ZERO_WIDTH_CHARACTER
import com.x8bit.bitwarden.ui.platform.base.util.orNullIfBlank
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTonalIconButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledIconButton
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextFieldWithActions

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ fun BitwardenStepper(
value = clampedValue?.toString() ?: ZERO_WIDTH_CHARACTER,
actionsTestTag = stepperActionsTestTag,
actions = {
BitwardenTonalIconButton(
BitwardenFilledIconButton(
vectorIconRes = R.drawable.ic_minus,
contentDescription = "\u2212",
onClick = {
Expand All @@ -63,7 +63,7 @@ fun BitwardenStepper(
isEnabled = isDecrementEnabled && !isAtRangeMinimum,
modifier = Modifier.testTag("DecrementValue"),
)
BitwardenTonalIconButton(
BitwardenFilledIconButton(
vectorIconRes = R.drawable.ic_plus,
contentDescription = "+",
onClick = {
Expand Down