File tree Expand file tree Collapse file tree 3 files changed +27
-13
lines changed
app/src/main/java/to/bitkit/ui Expand file tree Collapse file tree 3 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ fun PrimaryButton(
6464 enabled : Boolean = true,
6565 fullWidth : Boolean = true,
6666 color : Color ? = null,
67+ enableGradient : Boolean = true,
6768) {
6869 val contentPadding = PaddingValues (horizontal = size.horizontalPadding.takeIf { text != null } ? : 0 .dp)
6970 val buttonShape = MaterialTheme .shapes.large
@@ -83,7 +84,8 @@ fun PrimaryButton(
8384 .primaryButtonStyle(
8485 isEnabled = enabled && ! isLoading,
8586 shape = buttonShape,
86- primaryColor = color
87+ primaryColor = color,
88+ enableGradient = enableGradient
8789 )
8890 .alphaFeedback(enabled = enabled && ! isLoading)
8991 ) {
@@ -315,6 +317,7 @@ private fun PrimaryButtonPreview() {
315317 onClick = {},
316318 fullWidth = false ,
317319 color = Colors .Brand ,
320+ enableGradient = false
318321 )
319322 PrimaryButton (
320323 text = " Primary Small Loading" ,
Original file line number Diff line number Diff line change @@ -159,9 +159,11 @@ private fun ConfirmMnemonicContent(
159159 .testTag(" backup_shuffled_words_grid" )
160160 ) {
161161 shuffledWords.forEachIndexed { index, word ->
162+ val isSelected = pressedStates.getOrElse(index, defaultValue = { false })
162163 PrimaryButton (
163164 text = word,
164- color = if (pressedStates.getOrNull(index) == true ) Colors .White32 else Colors .White16 ,
165+ color = if (isSelected) Colors .White32 else Colors .White16 ,
166+ enableGradient = ! isSelected,
165167 fullWidth = false ,
166168 size = ButtonSize .Small ,
167169 onClick = { onWordPress(word, index) },
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ fun Modifier.primaryButtonStyle(
157157 isEnabled : Boolean ,
158158 shape : Shape ,
159159 primaryColor : Color ? = null,
160+ enableGradient : Boolean = true,
160161): Modifier {
161162 return this
162163 // Step 1: Add shadow (only when enabled)
@@ -177,17 +178,25 @@ fun Modifier.primaryButtonStyle(
177178 .then(
178179 if (isEnabled) {
179180 Modifier .drawWithContent {
180- // Draw the main gradient background filling entire button
181- val mainBrush = Brush .verticalGradient(
182- colors = listOf (primaryColor ? : Colors .Gray5 , Colors .Gray6 ),
183- startY = 0f ,
184- endY = size.height
185- )
186- drawRect(
187- brush = mainBrush,
188- topLeft = Offset .Zero ,
189- size = size
190- )
181+ // Draw the main background filling entire button
182+ val baseColor = primaryColor ? : Colors .Gray5
183+ if (enableGradient) {
184+ drawRect(
185+ brush = Brush .verticalGradient(
186+ colors = listOf (baseColor, Colors .Gray6 ),
187+ startY = 0f ,
188+ endY = size.height
189+ ),
190+ topLeft = Offset .Zero ,
191+ size = size
192+ )
193+ } else {
194+ drawRect(
195+ color = baseColor,
196+ topLeft = Offset .Zero ,
197+ size = size
198+ )
199+ }
191200
192201 // Draw top border highlight (2dp gradient fade)
193202 val borderHeight = 2 .dp.toPx()
You can’t perform that action at this time.
0 commit comments