Skip to content

Commit e9f9483

Browse files
authored
Merge pull request #517 from synonymdev/feat/numpad-button-v59
feat: Numpad v59 design
2 parents 316a02a + 5095067 commit e9f9483

File tree

4 files changed

+157
-93
lines changed

4 files changed

+157
-93
lines changed

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/to/bitkit/ui/components/NumberPadActionButton.kt

Lines changed: 69 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package to.bitkit.ui.components
22

33
import androidx.annotation.DrawableRes
44
import androidx.compose.foundation.BorderStroke
5-
import androidx.compose.foundation.clickable
65
import androidx.compose.foundation.layout.Arrangement
76
import androidx.compose.foundation.layout.Column
87
import androidx.compose.foundation.layout.PaddingValues
98
import androidx.compose.foundation.layout.Row
109
import androidx.compose.foundation.layout.padding
10+
import androidx.compose.foundation.layout.requiredHeight
1111
import androidx.compose.foundation.layout.size
12+
import androidx.compose.foundation.shape.RoundedCornerShape
13+
import androidx.compose.material3.Button
1214
import androidx.compose.material3.Icon
13-
import androidx.compose.material3.Surface
15+
import androidx.compose.material3.OutlinedButton
1416
import androidx.compose.runtime.Composable
1517
import androidx.compose.ui.Alignment
1618
import androidx.compose.ui.Modifier
@@ -19,7 +21,9 @@ import androidx.compose.ui.res.painterResource
1921
import androidx.compose.ui.tooling.preview.Preview
2022
import androidx.compose.ui.unit.dp
2123
import to.bitkit.R
22-
import to.bitkit.ui.theme.AppShapes
24+
import to.bitkit.ui.shared.modifiers.alphaFeedback
25+
import to.bitkit.ui.shared.util.primaryButtonStyle
26+
import to.bitkit.ui.theme.AppButtonDefaults
2327
import to.bitkit.ui.theme.AppThemeSurface
2428
import to.bitkit.ui.theme.Colors
2529

@@ -32,36 +36,72 @@ fun NumberPadActionButton(
3236
enabled: Boolean = true,
3337
@DrawableRes icon: Int? = null,
3438
) {
35-
val borderColor = if (enabled) Color.Transparent else color
36-
val bgColor = if (enabled) Colors.White10 else Color.Transparent
39+
val contentPadding = PaddingValues(horizontal = 8.dp, vertical = 5.dp)
40+
val height = 28.dp
41+
val buttonShape = RoundedCornerShape(8.dp)
3742

38-
Surface(
39-
color = bgColor,
40-
shape = AppShapes.small,
41-
border = BorderStroke(1.dp, borderColor),
42-
modifier = modifier
43-
.clickable(
44-
enabled = enabled,
45-
onClick = onClick,
46-
)
47-
) {
48-
Row(
49-
verticalAlignment = Alignment.CenterVertically,
50-
horizontalArrangement = Arrangement.spacedBy(8.dp),
51-
modifier = Modifier.padding(PaddingValues(8.dp, 5.dp))
43+
if (enabled) {
44+
Button(
45+
onClick = onClick,
46+
colors = AppButtonDefaults.primaryColors.copy(
47+
containerColor = Color.Transparent,
48+
disabledContainerColor = Color.Transparent
49+
),
50+
contentPadding = contentPadding,
51+
shape = buttonShape,
52+
modifier = modifier
53+
.requiredHeight(height)
54+
.primaryButtonStyle(
55+
isEnabled = true,
56+
shape = buttonShape,
57+
)
58+
.alphaFeedback(enabled = enabled)
5259
) {
53-
if (icon != null) {
54-
Icon(
55-
painter = painterResource(icon),
56-
contentDescription = text,
57-
tint = color,
58-
modifier = Modifier.size(16.dp)
60+
Row(
61+
verticalAlignment = Alignment.CenterVertically,
62+
horizontalArrangement = Arrangement.spacedBy(8.dp),
63+
) {
64+
if (icon != null) {
65+
Icon(
66+
painter = painterResource(icon),
67+
contentDescription = text,
68+
tint = color,
69+
modifier = Modifier.size(16.dp)
70+
)
71+
}
72+
Caption13Up(
73+
text = text,
74+
color = color,
75+
)
76+
}
77+
}
78+
} else {
79+
OutlinedButton(
80+
onClick = onClick,
81+
shape = buttonShape,
82+
colors = AppButtonDefaults.secondaryColors,
83+
contentPadding = contentPadding,
84+
border = BorderStroke(width = 1.dp, color = color),
85+
modifier = modifier
86+
.requiredHeight(height)
87+
) {
88+
Row(
89+
verticalAlignment = Alignment.CenterVertically,
90+
horizontalArrangement = Arrangement.spacedBy(8.dp),
91+
) {
92+
if (icon != null) {
93+
Icon(
94+
painter = painterResource(icon),
95+
contentDescription = text,
96+
tint = color,
97+
modifier = Modifier.size(16.dp)
98+
)
99+
}
100+
Caption13Up(
101+
text = text,
102+
color = color,
59103
)
60104
}
61-
Caption13Up(
62-
text = text,
63-
color = color,
64-
)
65105
}
66106
}
67107
}

app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveQrScreen.kt

Lines changed: 77 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.height
1818
import androidx.compose.foundation.layout.navigationBarsPadding
1919
import androidx.compose.foundation.layout.padding
2020
import androidx.compose.foundation.layout.size
21-
import androidx.compose.foundation.layout.width
2221
import androidx.compose.foundation.lazy.LazyRow
2322
import androidx.compose.foundation.lazy.itemsIndexed
2423
import androidx.compose.foundation.lazy.rememberLazyListState
@@ -236,6 +235,7 @@ fun ReceiveQrScreen(
236235
tab = tab,
237236
walletState = walletState,
238237
cjitInvoice = cjitInvoice,
238+
onClickEditInvoice = onClickEditInvoice,
239239
modifier = Modifier.weight(1f)
240240
)
241241
}
@@ -354,31 +354,36 @@ private fun ReceiveQrView(
354354
modifier = Modifier.size(18.dp)
355355
)
356356
},
357-
modifier = Modifier.testTag("SpecifyInvoiceButton")
357+
modifier = Modifier
358+
.weight(1f)
359+
.testTag("SpecifyInvoiceButton")
358360
)
359-
Tooltip(
360-
text = stringResource(R.string.wallet__receive_copied),
361-
tooltipState = qrButtonTooltipState
362-
) {
363-
PrimaryButton(
364-
text = stringResource(R.string.common__copy),
365-
size = ButtonSize.Small,
366-
onClick = {
367-
context.setClipboardText(uri)
368-
coroutineScope.launch { qrButtonTooltipState.show() }
369-
},
370-
fullWidth = false,
371-
color = Colors.White10,
372-
icon = {
373-
Icon(
374-
painter = painterResource(R.drawable.ic_copy),
375-
contentDescription = null,
376-
tint = tab.accentColor,
377-
modifier = Modifier.size(18.dp)
378-
)
379-
},
380-
modifier = Modifier.testTag("ReceiveCopyQR")
381-
)
361+
Box(modifier = Modifier.weight(1f)) {
362+
Tooltip(
363+
text = stringResource(R.string.wallet__receive_copied),
364+
tooltipState = qrButtonTooltipState
365+
) {
366+
PrimaryButton(
367+
text = stringResource(R.string.common__copy),
368+
size = ButtonSize.Small,
369+
onClick = {
370+
context.setClipboardText(uri)
371+
coroutineScope.launch { qrButtonTooltipState.show() }
372+
},
373+
fullWidth = true,
374+
color = Colors.White10,
375+
icon = {
376+
Icon(
377+
painter = painterResource(R.drawable.ic_copy),
378+
contentDescription = null,
379+
tint = tab.accentColor,
380+
modifier = Modifier.size(18.dp)
381+
)
382+
},
383+
modifier = Modifier
384+
.testTag("ReceiveCopyQR")
385+
)
386+
}
382387
}
383388
PrimaryButton(
384389
text = stringResource(R.string.common__share),
@@ -398,6 +403,7 @@ private fun ReceiveQrView(
398403
modifier = Modifier.size(18.dp)
399404
)
400405
},
406+
modifier = Modifier.weight(1f)
401407
)
402408
}
403409
Spacer(modifier = Modifier.height(16.dp))
@@ -452,6 +458,7 @@ private fun ReceiveDetailsView(
452458
tab: ReceiveTab,
453459
walletState: MainUiState,
454460
cjitInvoice: String?,
461+
onClickEditInvoice: () -> Unit,
455462
modifier: Modifier = Modifier,
456463
) {
457464
Card(
@@ -471,6 +478,7 @@ private fun ReceiveDetailsView(
471478
),
472479
body = walletState.onchainAddress,
473480
type = CopyAddressType.ONCHAIN,
481+
onClickEditInvoice = onClickEditInvoice,
474482
testTag = "ReceiveOnchainAddress",
475483
)
476484
}
@@ -487,6 +495,7 @@ private fun ReceiveDetailsView(
487495
),
488496
body = walletState.onchainAddress,
489497
type = CopyAddressType.ONCHAIN,
498+
onClickEditInvoice = onClickEditInvoice,
490499
testTag = "ReceiveOnchainAddress",
491500
)
492501
}
@@ -495,6 +504,7 @@ private fun ReceiveDetailsView(
495504
title = stringResource(R.string.wallet__receive_lightning_invoice),
496505
address = cjitInvoice ?: walletState.bolt11,
497506
type = CopyAddressType.LIGHTNING,
507+
onClickEditInvoice = onClickEditInvoice,
498508
testTag = "ReceiveLightningAddress",
499509
)
500510
}
@@ -506,6 +516,7 @@ private fun ReceiveDetailsView(
506516
title = stringResource(R.string.wallet__receive_lightning_invoice),
507517
address = cjitInvoice ?: walletState.bolt11,
508518
type = CopyAddressType.LIGHTNING,
519+
onClickEditInvoice = onClickEditInvoice,
509520
testTag = "ReceiveLightningAddress",
510521
)
511522
}
@@ -523,6 +534,7 @@ private fun CopyAddressCard(
523534
title: String,
524535
address: String,
525536
type: CopyAddressType,
537+
onClickEditInvoice: () -> Unit,
526538
body: String? = null,
527539
testTag: String? = null,
528540
) {
@@ -536,14 +548,7 @@ private fun CopyAddressCard(
536548
.fillMaxWidth()
537549
.padding(24.dp)
538550
) {
539-
Row {
540-
Caption13Up(text = title, color = Colors.White64)
541-
542-
Spacer(modifier = Modifier.width(3.dp))
543-
544-
val iconRes = if (type == CopyAddressType.ONCHAIN) R.drawable.ic_bitcoin else R.drawable.ic_lightning_alt
545-
Icon(painter = painterResource(iconRes), contentDescription = null, tint = Colors.White64)
546-
}
551+
Caption13Up(text = title, color = Colors.White64)
547552
Spacer(modifier = Modifier.height(16.dp))
548553
BodyS(
549554
text = (body ?: address).truncate(32).uppercase(),
@@ -553,28 +558,48 @@ private fun CopyAddressCard(
553558
Row(
554559
horizontalArrangement = Arrangement.spacedBy(16.dp)
555560
) {
561+
PrimaryButton(
562+
text = stringResource(R.string.common__edit),
563+
size = ButtonSize.Small,
564+
onClick = onClickEditInvoice,
565+
fullWidth = false,
566+
color = Colors.White10,
567+
icon = {
568+
Icon(
569+
painter = painterResource(R.drawable.ic_pencil_simple),
570+
contentDescription = null,
571+
tint = if (type == CopyAddressType.ONCHAIN) Colors.Brand else Colors.Purple,
572+
modifier = Modifier.size(18.dp)
573+
)
574+
},
575+
modifier = Modifier
576+
.weight(1f)
577+
.testTag("SpecifyInvoiceButton")
578+
)
556579
Tooltip(
557580
text = stringResource(R.string.wallet__receive_copied),
558581
tooltipState = tooltipState,
559582
) {
560-
PrimaryButton(
561-
text = stringResource(R.string.common__copy),
562-
size = ButtonSize.Small,
563-
onClick = {
564-
context.setClipboardText(address)
565-
coroutineScope.launch { tooltipState.show() }
566-
},
567-
fullWidth = false,
568-
color = Colors.White10,
569-
icon = {
570-
Icon(
571-
painter = painterResource(R.drawable.ic_copy),
572-
contentDescription = null,
573-
tint = if (type == CopyAddressType.ONCHAIN) Colors.Brand else Colors.Purple,
574-
modifier = Modifier.size(18.dp)
575-
)
576-
},
577-
)
583+
Box(modifier = Modifier.weight(1f)) {
584+
PrimaryButton(
585+
text = stringResource(R.string.common__copy),
586+
size = ButtonSize.Small,
587+
onClick = {
588+
context.setClipboardText(address)
589+
coroutineScope.launch { tooltipState.show() }
590+
},
591+
fullWidth = false,
592+
color = Colors.White10,
593+
icon = {
594+
Icon(
595+
painter = painterResource(R.drawable.ic_copy),
596+
contentDescription = null,
597+
tint = if (type == CopyAddressType.ONCHAIN) Colors.Brand else Colors.Purple,
598+
modifier = Modifier.size(18.dp)
599+
)
600+
},
601+
)
602+
}
578603
}
579604
PrimaryButton(
580605
text = stringResource(R.string.common__share),
@@ -804,6 +829,7 @@ private fun PreviewDetailsMode() {
804829
bolt11 = "lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79...",
805830
),
806831
cjitInvoice = null,
832+
onClickEditInvoice = {},
807833
modifier = Modifier.weight(1f)
808834
)
809835
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2-
android:width="32dp"
3-
android:height="32dp"
4-
android:viewportWidth="32"
5-
android:viewportHeight="32">
2+
android:width="16dp"
3+
android:height="16dp"
4+
android:viewportWidth="16"
5+
android:viewportHeight="16">
66
<path
7-
android:pathData="M22,29a4,4 0,1 0,0 -8,4 4,0 0,0 0,8M22,11a4,4 0,1 0,0 -8,4 4,0 0,0 0,8"
8-
android:strokeAlpha="0.2"
9-
android:fillColor="#FFFFFF"
10-
android:fillAlpha="0.2"/>
7+
android:pathData="M10.646,3.146C10.842,2.951 11.158,2.951 11.354,3.146L14.354,6.146C14.549,6.342 14.549,6.658 14.354,6.854L11.354,9.854C11.158,10.049 10.842,10.049 10.646,9.854C10.451,9.658 10.451,9.342 10.646,9.146L13.293,6.5L10.646,3.854C10.451,3.658 10.451,3.342 10.646,3.146Z"
8+
android:fillColor="#FF4400"
9+
android:fillType="evenOdd"/>
1110
<path
12-
android:pathData="M8,13a3,3 0,1 0,0 6,3 3,0 0,0 0,-6m-5,3a5,5 0,1 1,10 0,5 5,0 0,1 -10,0M22,22a3,3 0,1 0,0 6,3 3,0 0,0 0,-6m-5,3a5,5 0,1 1,10 0,5 5,0 0,1 -10,0M22,4a3,3 0,1 0,0 6,3 3,0 0,0 0,-6m-5,3a5,5 0,1 1,10 0,5 5,0 0,1 -10,0"
13-
android:fillColor="#FFFFFF"
11+
android:pathData="M2,5C2.276,5 2.5,5.224 2.5,5.5V13H12C12.276,13 12.5,13.224 12.5,13.5C12.5,13.776 12.276,14 12,14H2.5C2.235,14 1.98,13.895 1.793,13.707C1.605,13.52 1.5,13.265 1.5,13V5.5C1.5,5.224 1.724,5 2,5Z"
12+
android:fillColor="#FF4400"
1413
android:fillType="evenOdd"/>
1514
<path
16-
android:pathData="M19.477,8.622a1,1 0,0 1,-0.3 1.382l-7.272,4.675a1,1 0,1 1,-1.082 -1.683l7.272,-4.674a1,1 0,0 1,1.382 0.3M10.523,17.622a1,1 0,0 1,1.382 -0.3l7.271,4.674a1,1 0,1 1,-1.081 1.682l-7.272,-4.674a1,1 0,0 1,-0.3 -1.382"
17-
android:fillColor="#FFFFFF"
15+
android:pathData="M10.5,7C9.28,7 8.095,7.405 7.131,8.152C6.167,8.899 5.478,9.944 5.173,11.125C5.104,11.392 4.831,11.553 4.563,11.484C4.296,11.415 4.135,11.142 4.205,10.875C4.565,9.48 5.379,8.244 6.519,7.361C7.658,6.479 9.058,6 10.5,6H14C14.276,6 14.5,6.224 14.5,6.5C14.5,6.776 14.276,7 14,7H10.5C10.5,7 10.5,7 10.5,7Z"
16+
android:fillColor="#FF4400"
1817
android:fillType="evenOdd"/>
1918
</vector>

0 commit comments

Comments
 (0)