11package to.bitkit.ui.screens.wallets.receive
22
33import android.graphics.Bitmap
4- import androidx.compose.animation.AnimatedVisibility
54import androidx.compose.foundation.layout.Arrangement
65import androidx.compose.foundation.layout.Column
76import androidx.compose.foundation.layout.Row
@@ -17,7 +16,6 @@ import androidx.compose.material3.Card
1716import androidx.compose.material3.CardDefaults
1817import androidx.compose.material3.ExperimentalMaterial3Api
1918import androidx.compose.material3.Icon
20- import androidx.compose.material3.Switch
2119import androidx.compose.material3.rememberTooltipState
2220import androidx.compose.runtime.Composable
2321import androidx.compose.runtime.LaunchedEffect
@@ -29,7 +27,6 @@ import androidx.compose.runtime.rememberCoroutineScope
2927import androidx.compose.runtime.setValue
3028import androidx.compose.ui.Alignment
3129import androidx.compose.ui.Modifier
32- import androidx.compose.ui.draw.rotate
3330import androidx.compose.ui.graphics.painter.Painter
3431import androidx.compose.ui.keepScreenOn
3532import androidx.compose.ui.platform.LocalContext
@@ -45,12 +42,10 @@ import to.bitkit.R
4542import to.bitkit.ext.setClipboardText
4643import to.bitkit.ext.truncate
4744import to.bitkit.models.NodeLifecycleState
48- import to.bitkit.ui.components.BodyM
4945import to.bitkit.ui.components.BodyS
5046import to.bitkit.ui.components.BottomSheetPreview
5147import to.bitkit.ui.components.ButtonSize
5248import to.bitkit.ui.components.Caption13Up
53- import to.bitkit.ui.components.Headline
5449import to.bitkit.ui.components.PrimaryButton
5550import to.bitkit.ui.components.QrCodeImage
5651import to.bitkit.ui.components.Tooltip
@@ -62,10 +57,8 @@ import to.bitkit.ui.shared.util.gradientBackground
6257import to.bitkit.ui.shared.util.shareQrCode
6358import to.bitkit.ui.shared.util.shareText
6459import to.bitkit.ui.theme.AppShapes
65- import to.bitkit.ui.theme.AppSwitchDefaults
6660import to.bitkit.ui.theme.AppThemeSurface
6761import to.bitkit.ui.theme.Colors
68- import to.bitkit.ui.utils.withAccent
6962import to.bitkit.viewmodels.MainUiState
7063
7164@Composable
@@ -169,7 +162,7 @@ fun ReceiveQrScreen(
169162 onchainAddress = walletState.onchainAddress,
170163 bolt11 = walletState.bolt11,
171164 cjitInvoice = cjitInvoice.value,
172- bip21 = walletState.bip21
165+ modifier = Modifier .weight( 1f )
173166 )
174167 } else {
175168 ReceiveQrView (
@@ -314,11 +307,10 @@ private fun ReceiveDetailsView(
314307 onchainAddress : String ,
315308 bolt11 : String ,
316309 cjitInvoice : String? ,
317- bip21 : String ,
318310 modifier : Modifier = Modifier ,
319311) {
320312 Card (
321- colors = CardDefaults .cardColors(containerColor = Colors .White10 ),
313+ colors = CardDefaults .cardColors(containerColor = Colors .Black ),
322314 shape = AppShapes .small,
323315 modifier = modifier
324316 ) {
@@ -370,194 +362,6 @@ private fun ReceiveDetailsView(
370362 }
371363}
372364
373- @Composable
374- private fun ReceiveNodeStateIndicator (
375- selectedTab : ReceiveTab ,
376- cjitActive : Boolean ,
377- ) {
378- when {
379- selectedTab == ReceiveTab .SPENDING && cjitActive -> {
380- BodyS (
381- text = " CJIT Active" ,
382- color = Colors .Purple
383- )
384- }
385- }
386- }
387-
388- @Composable
389- private fun ReceiveLightningFunds (
390- cjitInvoice : MutableState <String ?>,
391- cjitActive : MutableState <Boolean >,
392- onCjitToggle : (Boolean ) -> Unit ,
393- ) {
394- Column {
395- AnimatedVisibility (! cjitActive.value && cjitInvoice.value == null ) {
396- Headline (
397- text = stringResource(R .string.wallet__receive_text_lnfunds).withAccent(accentColor = Colors .Purple )
398- )
399- }
400- Row (verticalAlignment = Alignment .CenterVertically ) {
401- BodyM (text = stringResource(R .string.wallet__receive_spending))
402- Spacer (modifier = Modifier .weight(1f ))
403- AnimatedVisibility (! cjitActive.value && cjitInvoice.value == null ) {
404- Icon (
405- painter = painterResource(R .drawable.empty_state_arrow_horizontal),
406- contentDescription = null ,
407- tint = Colors .White64 ,
408- modifier = Modifier
409- .rotate(17.33f )
410- .padding(start = 7.65 .dp, end = 13.19 .dp)
411- )
412- }
413- Switch (
414- checked = cjitActive.value,
415- onCheckedChange = onCjitToggle,
416- colors = AppSwitchDefaults .colorsPurple,
417- )
418- }
419- }
420- }
421-
422- @OptIn(ExperimentalMaterial3Api ::class )
423- @Composable
424- private fun ReceiveQrSlide (
425- uri : String ,
426- qrLogoPainter : Painter ,
427- modifier : Modifier ,
428- onClickEditInvoice : () -> Unit ,
429- ) {
430- val context = LocalContext .current
431-
432- val qrButtonTooltipState = rememberTooltipState()
433- val coroutineScope = rememberCoroutineScope()
434-
435- var qrBitmap by remember { mutableStateOf<Bitmap ?>(null ) }
436-
437- Column (
438- horizontalAlignment = Alignment .CenterHorizontally ,
439- modifier = modifier
440- ) {
441- QrCodeImage (
442- content = uri,
443- logoPainter = qrLogoPainter,
444- tipMessage = stringResource(R .string.wallet__receive_copied),
445- onBitmapGenerated = { bitmap -> qrBitmap = bitmap },
446- testTag = " QRCode" ,
447- modifier = Modifier .weight(1f , fill = false )
448- )
449-
450- Spacer (modifier = Modifier .height(16 .dp))
451- Row (
452- horizontalArrangement = Arrangement .spacedBy(16 .dp),
453- verticalAlignment = Alignment .Top ,
454- ) {
455- PrimaryButton (
456- text = stringResource(R .string.common__edit),
457- size = ButtonSize .Small ,
458- onClick = onClickEditInvoice,
459- fullWidth = false ,
460- color = Colors .White10 ,
461- icon = {
462- Icon (
463- painter = painterResource(R .drawable.ic_pencil_simple),
464- contentDescription = null ,
465- tint = Colors .Brand ,
466- modifier = Modifier .size(18 .dp)
467- )
468- },
469- modifier = Modifier .testTag(" SpecifyInvoiceButton" )
470- )
471- Tooltip (
472- text = stringResource(R .string.wallet__receive_copied),
473- tooltipState = qrButtonTooltipState
474- ) {
475- PrimaryButton (
476- text = stringResource(R .string.common__copy),
477- size = ButtonSize .Small ,
478- onClick = {
479- context.setClipboardText(uri)
480- coroutineScope.launch { qrButtonTooltipState.show() }
481- },
482- fullWidth = false ,
483- color = Colors .White10 ,
484- icon = {
485- Icon (
486- painter = painterResource(R .drawable.ic_copy),
487- contentDescription = null ,
488- tint = Colors .Brand ,
489- modifier = Modifier .size(18 .dp)
490- )
491- },
492- modifier = Modifier .testTag(" ReceiveCopyQR" )
493- )
494- }
495- PrimaryButton (
496- text = stringResource(R .string.common__share),
497- size = ButtonSize .Small ,
498- onClick = {
499- qrBitmap?.let { bitmap ->
500- shareQrCode(context, bitmap, uri)
501- } ? : shareText(context, uri)
502- },
503- fullWidth = false ,
504- color = Colors .White10 ,
505- icon = {
506- Icon (
507- painter = painterResource(R .drawable.ic_share),
508- contentDescription = null ,
509- tint = Colors .Brand ,
510- modifier = Modifier .size(18 .dp)
511- )
512- },
513- )
514- }
515- Spacer (modifier = Modifier .height(16 .dp))
516- }
517- }
518-
519- @Composable
520- private fun CopyValuesBox (
521- onchainAddress : String ,
522- bolt11 : String ,
523- cjitInvoice : String? ,
524- selectedTab : ReceiveTab ,
525- ) {
526- Card (
527- colors = CardDefaults .cardColors(containerColor = Colors .White10 ),
528- shape = AppShapes .small,
529- ) {
530- Column {
531- if (onchainAddress.isNotEmpty() && cjitInvoice == null ) {
532- CopyAddressCard (
533- title = stringResource(R .string.wallet__receive_bitcoin_invoice),
534- address = onchainAddress,
535- type = CopyAddressType .ONCHAIN ,
536- testTag = " ReceiveOnchainAddress" ,
537- )
538- }
539-
540- if (selectedTab == ReceiveTab .AUTO || selectedTab == ReceiveTab .SPENDING ) {
541- if (bolt11.isNotEmpty()) {
542- CopyAddressCard (
543- title = stringResource(R .string.wallet__receive_lightning_invoice),
544- address = bolt11,
545- type = CopyAddressType .LIGHTNING ,
546- testTag = " ReceiveLightningAddress" ,
547- )
548- } else if (cjitInvoice != null ) {
549- CopyAddressCard (
550- title = stringResource(R .string.wallet__receive_lightning_invoice),
551- address = cjitInvoice,
552- type = CopyAddressType .LIGHTNING ,
553- testTag = " ReceiveLightningAddress" ,
554- )
555- }
556- }
557- }
558- }
559- }
560-
561365enum class CopyAddressType { ONCHAIN , LIGHTNING }
562366
563367@OptIn(ExperimentalMaterial3Api ::class )
@@ -807,21 +611,24 @@ private fun PreviewSmall() {
807611 }
808612}
809613
614+
810615@Suppress(" SpellCheckingInspection" )
811- @Preview(showBackground = true )
616+ @Preview(showSystemUi = true , name = " Auto Mode " )
812617@Composable
813- private fun PreviewSlide2 () {
618+ private fun PreviewDetailsMode () {
814619 AppThemeSurface {
815620 Column (
816621 modifier = Modifier
817622 .gradientBackground()
623+ .fillMaxSize()
818624 .padding(16 .dp)
819625 ) {
820- CopyValuesBox (
626+ ReceiveDetailsView (
627+ tab = ReceiveTab .AUTO ,
821628 onchainAddress = " bcrt1qfserxgtuesul4m9zva56wzk849yf9l8rk4qy0l" ,
822629 bolt11 = " lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79..." ,
823630 cjitInvoice = null ,
824- selectedTab = ReceiveTab . AUTO
631+ modifier = Modifier .weight( 1f )
825632 )
826633 }
827634 }
0 commit comments