Skip to content
1 change: 0 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 69 additions & 29 deletions app/src/main/java/to/bitkit/ui/components/NumberPadActionButton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ package to.bitkit.ui.components

import androidx.annotation.DrawableRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.Surface
import androidx.compose.material3.OutlinedButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -19,7 +21,9 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import to.bitkit.R
import to.bitkit.ui.theme.AppShapes
import to.bitkit.ui.shared.modifiers.alphaFeedback
import to.bitkit.ui.shared.util.primaryButtonStyle
import to.bitkit.ui.theme.AppButtonDefaults
import to.bitkit.ui.theme.AppThemeSurface
import to.bitkit.ui.theme.Colors

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

Surface(
color = bgColor,
shape = AppShapes.small,
border = BorderStroke(1.dp, borderColor),
modifier = modifier
.clickable(
enabled = enabled,
onClick = onClick,
)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.padding(PaddingValues(8.dp, 5.dp))
if (enabled) {
Button(
onClick = onClick,
colors = AppButtonDefaults.primaryColors.copy(
containerColor = Color.Transparent,
disabledContainerColor = Color.Transparent
),
contentPadding = contentPadding,
shape = buttonShape,
modifier = modifier
.requiredHeight(height)
.primaryButtonStyle(
isEnabled = true,
shape = buttonShape,
)
.alphaFeedback(enabled = enabled)
) {
if (icon != null) {
Icon(
painter = painterResource(icon),
contentDescription = text,
tint = color,
modifier = Modifier.size(16.dp)
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
if (icon != null) {
Icon(
painter = painterResource(icon),
contentDescription = text,
tint = color,
modifier = Modifier.size(16.dp)
)
}
Caption13Up(
text = text,
color = color,
)
}
}
} else {
OutlinedButton(
onClick = onClick,
shape = buttonShape,
colors = AppButtonDefaults.secondaryColors,
contentPadding = contentPadding,
border = BorderStroke(width = 1.dp, color = color),
modifier = modifier
.requiredHeight(height)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
if (icon != null) {
Icon(
painter = painterResource(icon),
contentDescription = text,
tint = color,
modifier = Modifier.size(16.dp)
)
}
Caption13Up(
text = text,
color = color,
)
}
Caption13Up(
text = text,
color = color,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
Expand Down Expand Up @@ -236,6 +235,7 @@ fun ReceiveQrScreen(
tab = tab,
walletState = walletState,
cjitInvoice = cjitInvoice,
onClickEditInvoice = onClickEditInvoice,
modifier = Modifier.weight(1f)
)
}
Expand Down Expand Up @@ -354,31 +354,36 @@ private fun ReceiveQrView(
modifier = Modifier.size(18.dp)
)
},
modifier = Modifier.testTag("SpecifyInvoiceButton")
modifier = Modifier
.weight(1f)
.testTag("SpecifyInvoiceButton")
)
Tooltip(
text = stringResource(R.string.wallet__receive_copied),
tooltipState = qrButtonTooltipState
) {
PrimaryButton(
text = stringResource(R.string.common__copy),
size = ButtonSize.Small,
onClick = {
context.setClipboardText(uri)
coroutineScope.launch { qrButtonTooltipState.show() }
},
fullWidth = false,
color = Colors.White10,
icon = {
Icon(
painter = painterResource(R.drawable.ic_copy),
contentDescription = null,
tint = tab.accentColor,
modifier = Modifier.size(18.dp)
)
},
modifier = Modifier.testTag("ReceiveCopyQR")
)
Box(modifier = Modifier.weight(1f)) {
Tooltip(
text = stringResource(R.string.wallet__receive_copied),
tooltipState = qrButtonTooltipState
) {
PrimaryButton(
text = stringResource(R.string.common__copy),
size = ButtonSize.Small,
onClick = {
context.setClipboardText(uri)
coroutineScope.launch { qrButtonTooltipState.show() }
},
fullWidth = true,
color = Colors.White10,
icon = {
Icon(
painter = painterResource(R.drawable.ic_copy),
contentDescription = null,
tint = tab.accentColor,
modifier = Modifier.size(18.dp)
)
},
modifier = Modifier
.testTag("ReceiveCopyQR")
)
}
}
PrimaryButton(
text = stringResource(R.string.common__share),
Expand All @@ -398,6 +403,7 @@ private fun ReceiveQrView(
modifier = Modifier.size(18.dp)
)
},
modifier = Modifier.weight(1f)
)
}
Spacer(modifier = Modifier.height(16.dp))
Expand Down Expand Up @@ -452,6 +458,7 @@ private fun ReceiveDetailsView(
tab: ReceiveTab,
walletState: MainUiState,
cjitInvoice: String?,
onClickEditInvoice: () -> Unit,
modifier: Modifier = Modifier,
) {
Card(
Expand All @@ -471,6 +478,7 @@ private fun ReceiveDetailsView(
),
body = walletState.onchainAddress,
type = CopyAddressType.ONCHAIN,
onClickEditInvoice = onClickEditInvoice,
testTag = "ReceiveOnchainAddress",
)
}
Expand All @@ -487,6 +495,7 @@ private fun ReceiveDetailsView(
),
body = walletState.onchainAddress,
type = CopyAddressType.ONCHAIN,
onClickEditInvoice = onClickEditInvoice,
testTag = "ReceiveOnchainAddress",
)
}
Expand All @@ -495,6 +504,7 @@ private fun ReceiveDetailsView(
title = stringResource(R.string.wallet__receive_lightning_invoice),
address = cjitInvoice ?: walletState.bolt11,
type = CopyAddressType.LIGHTNING,
onClickEditInvoice = onClickEditInvoice,
testTag = "ReceiveLightningAddress",
)
}
Expand All @@ -506,6 +516,7 @@ private fun ReceiveDetailsView(
title = stringResource(R.string.wallet__receive_lightning_invoice),
address = cjitInvoice ?: walletState.bolt11,
type = CopyAddressType.LIGHTNING,
onClickEditInvoice = onClickEditInvoice,
testTag = "ReceiveLightningAddress",
)
}
Expand All @@ -523,6 +534,7 @@ private fun CopyAddressCard(
title: String,
address: String,
type: CopyAddressType,
onClickEditInvoice: () -> Unit,
body: String? = null,
testTag: String? = null,
) {
Expand All @@ -536,14 +548,7 @@ private fun CopyAddressCard(
.fillMaxWidth()
.padding(24.dp)
) {
Row {
Caption13Up(text = title, color = Colors.White64)

Spacer(modifier = Modifier.width(3.dp))

val iconRes = if (type == CopyAddressType.ONCHAIN) R.drawable.ic_bitcoin else R.drawable.ic_lightning_alt
Icon(painter = painterResource(iconRes), contentDescription = null, tint = Colors.White64)
}
Caption13Up(text = title, color = Colors.White64)
Spacer(modifier = Modifier.height(16.dp))
BodyS(
text = (body ?: address).truncate(32).uppercase(),
Expand All @@ -553,28 +558,48 @@ private fun CopyAddressCard(
Row(
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
PrimaryButton(
text = stringResource(R.string.common__edit),
size = ButtonSize.Small,
onClick = onClickEditInvoice,
fullWidth = false,
color = Colors.White10,
icon = {
Icon(
painter = painterResource(R.drawable.ic_pencil_simple),
contentDescription = null,
tint = if (type == CopyAddressType.ONCHAIN) Colors.Brand else Colors.Purple,
modifier = Modifier.size(18.dp)
)
},
modifier = Modifier
.weight(1f)
.testTag("SpecifyInvoiceButton")
)
Tooltip(
text = stringResource(R.string.wallet__receive_copied),
tooltipState = tooltipState,
) {
PrimaryButton(
text = stringResource(R.string.common__copy),
size = ButtonSize.Small,
onClick = {
context.setClipboardText(address)
coroutineScope.launch { tooltipState.show() }
},
fullWidth = false,
color = Colors.White10,
icon = {
Icon(
painter = painterResource(R.drawable.ic_copy),
contentDescription = null,
tint = if (type == CopyAddressType.ONCHAIN) Colors.Brand else Colors.Purple,
modifier = Modifier.size(18.dp)
)
},
)
Box(modifier = Modifier.weight(1f)) {
PrimaryButton(
text = stringResource(R.string.common__copy),
size = ButtonSize.Small,
onClick = {
context.setClipboardText(address)
coroutineScope.launch { tooltipState.show() }
},
fullWidth = false,
color = Colors.White10,
icon = {
Icon(
painter = painterResource(R.drawable.ic_copy),
contentDescription = null,
tint = if (type == CopyAddressType.ONCHAIN) Colors.Brand else Colors.Purple,
modifier = Modifier.size(18.dp)
)
},
)
}
}
PrimaryButton(
text = stringResource(R.string.common__share),
Expand Down Expand Up @@ -804,6 +829,7 @@ private fun PreviewDetailsMode() {
bolt11 = "lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79...",
),
cjitInvoice = null,
onClickEditInvoice = {},
modifier = Modifier.weight(1f)
)
}
Expand Down
23 changes: 11 additions & 12 deletions app/src/main/res/drawable/ic_share.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
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"
android:strokeAlpha="0.2"
android:fillColor="#FFFFFF"
android:fillAlpha="0.2"/>
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"
android:fillColor="#FF4400"
android:fillType="evenOdd"/>
<path
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"
android:fillColor="#FFFFFF"
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"
android:fillColor="#FF4400"
android:fillType="evenOdd"/>
<path
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"
android:fillColor="#FFFFFF"
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"
android:fillColor="#FF4400"
android:fillType="evenOdd"/>
</vector>
Loading