diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index f8c8fa315..b175032ad 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -39,7 +39,6 @@ diff --git a/app/src/main/java/to/bitkit/ui/components/NumberPadActionButton.kt b/app/src/main/java/to/bitkit/ui/components/NumberPadActionButton.kt index 9fde35af7..f0691860b 100644 --- a/app/src/main/java/to/bitkit/ui/components/NumberPadActionButton.kt +++ b/app/src/main/java/to/bitkit/ui/components/NumberPadActionButton.kt @@ -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 @@ -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 @@ -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, - ) } } } diff --git a/app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveQrScreen.kt b/app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveQrScreen.kt index db350a194..0b23f52f9 100644 --- a/app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveQrScreen.kt +++ b/app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveQrScreen.kt @@ -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 @@ -236,6 +235,7 @@ fun ReceiveQrScreen( tab = tab, walletState = walletState, cjitInvoice = cjitInvoice, + onClickEditInvoice = onClickEditInvoice, modifier = Modifier.weight(1f) ) } @@ -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), @@ -398,6 +403,7 @@ private fun ReceiveQrView( modifier = Modifier.size(18.dp) ) }, + modifier = Modifier.weight(1f) ) } Spacer(modifier = Modifier.height(16.dp)) @@ -452,6 +458,7 @@ private fun ReceiveDetailsView( tab: ReceiveTab, walletState: MainUiState, cjitInvoice: String?, + onClickEditInvoice: () -> Unit, modifier: Modifier = Modifier, ) { Card( @@ -471,6 +478,7 @@ private fun ReceiveDetailsView( ), body = walletState.onchainAddress, type = CopyAddressType.ONCHAIN, + onClickEditInvoice = onClickEditInvoice, testTag = "ReceiveOnchainAddress", ) } @@ -487,6 +495,7 @@ private fun ReceiveDetailsView( ), body = walletState.onchainAddress, type = CopyAddressType.ONCHAIN, + onClickEditInvoice = onClickEditInvoice, testTag = "ReceiveOnchainAddress", ) } @@ -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", ) } @@ -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", ) } @@ -523,6 +534,7 @@ private fun CopyAddressCard( title: String, address: String, type: CopyAddressType, + onClickEditInvoice: () -> Unit, body: String? = null, testTag: String? = null, ) { @@ -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(), @@ -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), @@ -804,6 +829,7 @@ private fun PreviewDetailsMode() { bolt11 = "lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79...", ), cjitInvoice = null, + onClickEditInvoice = {}, modifier = Modifier.weight(1f) ) } diff --git a/app/src/main/res/drawable/ic_share.xml b/app/src/main/res/drawable/ic_share.xml index b7aa4ce87..e63379543 100644 --- a/app/src/main/res/drawable/ic_share.xml +++ b/app/src/main/res/drawable/ic_share.xml @@ -1,19 +1,18 @@ + android:width="16dp" + android:height="16dp" + android:viewportWidth="16" + android:viewportHeight="16"> + 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"/>