Skip to content
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
5 changes: 4 additions & 1 deletion app/src/main/java/to/bitkit/ui/components/Button.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fun PrimaryButton(
enabled: Boolean = true,
fullWidth: Boolean = true,
color: Color? = null,
enableGradient: Boolean = true,
) {
val contentPadding = PaddingValues(horizontal = size.horizontalPadding.takeIf { text != null } ?: 0.dp)
val buttonShape = MaterialTheme.shapes.large
Expand All @@ -83,7 +84,8 @@ fun PrimaryButton(
.primaryButtonStyle(
isEnabled = enabled && !isLoading,
shape = buttonShape,
primaryColor = color
primaryColor = color,
enableGradient = enableGradient
)
.alphaFeedback(enabled = enabled && !isLoading)
) {
Expand Down Expand Up @@ -315,6 +317,7 @@ private fun PrimaryButtonPreview() {
onClick = {},
fullWidth = false,
color = Colors.Brand,
enableGradient = false
)
PrimaryButton(
text = "Primary Small Loading",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ private fun ConfirmMnemonicContent(
.testTag("backup_shuffled_words_grid")
) {
shuffledWords.forEachIndexed { index, word ->
val isSelected = pressedStates.getOrElse(index, defaultValue = { false })
PrimaryButton(
text = word,
color = if (pressedStates.getOrNull(index) == true) Colors.White32 else Colors.White16,
color = if (isSelected) Colors.White32 else Colors.White16,
enableGradient = !isSelected,
fullWidth = false,
size = ButtonSize.Small,
onClick = { onWordPress(word, index) },
Expand Down
31 changes: 20 additions & 11 deletions app/src/main/java/to/bitkit/ui/shared/util/Modifiers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ fun Modifier.primaryButtonStyle(
isEnabled: Boolean,
shape: Shape,
primaryColor: Color? = null,
enableGradient: Boolean = true,
): Modifier {
return this
// Step 1: Add shadow (only when enabled)
Expand All @@ -177,17 +178,25 @@ fun Modifier.primaryButtonStyle(
.then(
if (isEnabled) {
Modifier.drawWithContent {
// Draw the main gradient background filling entire button
val mainBrush = Brush.verticalGradient(
colors = listOf(primaryColor ?: Colors.Gray5, Colors.Gray6),
startY = 0f,
endY = size.height
)
drawRect(
brush = mainBrush,
topLeft = Offset.Zero,
size = size
)
// Draw the main background filling entire button
val baseColor = primaryColor ?: Colors.Gray5
if (enableGradient) {
drawRect(
brush = Brush.verticalGradient(
colors = listOf(baseColor, Colors.Gray6),
startY = 0f,
endY = size.height
),
topLeft = Offset.Zero,
size = size
)
} else {
drawRect(
color = baseColor,
topLeft = Offset.Zero,
size = size
)
}

// Draw top border highlight (2dp gradient fade)
val borderHeight = 2.dp.toPx()
Expand Down
Loading