@@ -40,6 +40,7 @@ import androidx.compose.ui.tooling.preview.Devices.NEXUS_5
4040import androidx.compose.ui.tooling.preview.Preview
4141import androidx.compose.ui.unit.dp
4242import kotlinx.coroutines.launch
43+ import org.lightningdevkit.ldknode.ChannelDetails
4344import to.bitkit.R
4445import to.bitkit.ext.setClipboardText
4546import to.bitkit.ext.truncate
@@ -75,13 +76,14 @@ fun ReceiveQrScreen(
7576 lightningState : to.bitkit.repositories.LightningState ,
7677 onClickEditInvoice : () -> Unit ,
7778 modifier : Modifier = Modifier ,
79+ initialTab : ReceiveTab ? = null,
7880) {
7981 SetMaxBrightness ()
8082
8183 // Tab selection state
8284 var selectedTab by remember {
8385 mutableStateOf(
84- if (walletState.channels.isNotEmpty()) {
86+ initialTab ? : if (walletState.channels.isNotEmpty()) {
8587 ReceiveTab .AUTO
8688 } else {
8789 ReceiveTab .SAVINGS
@@ -635,16 +637,116 @@ private fun CopyAddressCard(
635637 }
636638}
637639
638- @Preview(showSystemUi = true )
640+ @Suppress(" SpellCheckingInspection" )
641+ @Preview(showSystemUi = true , name = " Savings Mode" )
642+ @Composable
643+ private fun PreviewSavingsMode () {
644+ AppThemeSurface {
645+ BottomSheetPreview {
646+ ReceiveQrScreen (
647+ cjitInvoice = remember { mutableStateOf(null ) },
648+ cjitActive = remember { mutableStateOf(false ) },
649+ walletState = MainUiState (
650+ nodeLifecycleState = NodeLifecycleState .Running ,
651+ onchainAddress = " bcrt1qfserxgtuesul4m9zva56wzk849yf9l8rk4qy0l" ,
652+ channels = emptyList()
653+ ),
654+ lightningState = to.bitkit.repositories.LightningState (
655+ nodeLifecycleState = NodeLifecycleState .Running ,
656+ shouldBlockLightningReceive = false ,
657+ isGeoBlocked = false
658+ ),
659+ onClickEditInvoice = {},
660+ modifier = Modifier .sheetHeight(),
661+ initialTab = ReceiveTab .SAVINGS
662+ )
663+ }
664+ }
665+ }
666+
667+ @Suppress(" SpellCheckingInspection" )
668+ @Preview(showSystemUi = true , name = " Auto Mode" )
669+ @Composable
670+ private fun PreviewAutoMode () {
671+ // Mock channel for preview (AUTO tab requires non-empty channels list)
672+ val mockChannel = ChannelDetails (
673+ channelId = " 0" .repeat(64 ),
674+ counterpartyNodeId = " 0" .repeat(66 ),
675+ fundingTxo = null ,
676+ shortChannelId = null ,
677+ outboundScidAlias = null ,
678+ inboundScidAlias = null ,
679+ channelValueSats = 1000000uL ,
680+ unspendablePunishmentReserve = null ,
681+ userChannelId = " 0" .repeat(32 ),
682+ feerateSatPer1000Weight = 1000u ,
683+ outboundCapacityMsat = 500000000uL ,
684+ inboundCapacityMsat = 500000000uL ,
685+ confirmationsRequired = null ,
686+ confirmations = null ,
687+ isOutbound = true ,
688+ isChannelReady = true ,
689+ isUsable = true ,
690+ isAnnounced = false ,
691+ cltvExpiryDelta = null ,
692+ counterpartyUnspendablePunishmentReserve = 0uL ,
693+ counterpartyOutboundHtlcMinimumMsat = null ,
694+ counterpartyOutboundHtlcMaximumMsat = null ,
695+ counterpartyForwardingInfoFeeBaseMsat = null ,
696+ counterpartyForwardingInfoFeeProportionalMillionths = null ,
697+ counterpartyForwardingInfoCltvExpiryDelta = null ,
698+ nextOutboundHtlcLimitMsat = 0uL ,
699+ nextOutboundHtlcMinimumMsat = 0uL ,
700+ forceCloseSpendDelay = null ,
701+ inboundHtlcMinimumMsat = 0uL ,
702+ inboundHtlcMaximumMsat = null ,
703+ config = org.lightningdevkit.ldknode.ChannelConfig (
704+ forwardingFeeProportionalMillionths = 0u ,
705+ forwardingFeeBaseMsat = 0u ,
706+ cltvExpiryDelta = 0u ,
707+ maxDustHtlcExposure = org.lightningdevkit.ldknode.MaxDustHtlcExposure .FeeRateMultiplier (0uL ),
708+ forceCloseAvoidanceMaxFeeSatoshis = 0uL ,
709+ acceptUnderpayingHtlcs = false
710+ )
711+ )
712+
713+ AppThemeSurface {
714+ BottomSheetPreview {
715+ ReceiveQrScreen (
716+ cjitInvoice = remember { mutableStateOf(null ) },
717+ cjitActive = remember { mutableStateOf(false ) },
718+ walletState = MainUiState (
719+ nodeLifecycleState = NodeLifecycleState .Running ,
720+ onchainAddress = " bcrt1qfserxgtuesul4m9zva56wzk849yf9l8rk4qy0l" ,
721+ bolt11 = " lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79vhx9n2ps8q6tcdehhxapqd9h8vmmfvdjjqen0wgsyqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxq" ,
722+ bip21 = " bitcoin:bcrt1qfserxgtuesul4m9zva56wzk849yf9l8rk4qy0l?lightning=lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79..." ,
723+ channels = listOf (mockChannel)
724+ ),
725+ lightningState = to.bitkit.repositories.LightningState (
726+ nodeLifecycleState = NodeLifecycleState .Running ,
727+ shouldBlockLightningReceive = false ,
728+ isGeoBlocked = false
729+ ),
730+ onClickEditInvoice = {},
731+ modifier = Modifier .sheetHeight(),
732+ initialTab = ReceiveTab .AUTO
733+ )
734+ }
735+ }
736+ }
737+
738+ @Suppress(" SpellCheckingInspection" )
739+ @Preview(showSystemUi = true , name = " Spending Mode" )
639740@Composable
640- private fun Preview () {
741+ private fun PreviewSpendingMode () {
641742 AppThemeSurface {
642743 BottomSheetPreview {
643744 ReceiveQrScreen (
644745 cjitInvoice = remember { mutableStateOf(null ) },
645746 cjitActive = remember { mutableStateOf(false ) },
646747 walletState = MainUiState (
647748 nodeLifecycleState = NodeLifecycleState .Running ,
749+ bolt11 = " lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79vhx9n2ps8q6tcdehhxapqd9h8vmmfvdjjqen0wgsyqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxq"
648750 ),
649751 lightningState = to.bitkit.repositories.LightningState (
650752 nodeLifecycleState = NodeLifecycleState .Running ,
@@ -653,6 +755,7 @@ private fun Preview() {
653755 ),
654756 onClickEditInvoice = {},
655757 modifier = Modifier .sheetHeight(),
758+ initialTab = ReceiveTab .SPENDING
656759 )
657760 }
658761 }
0 commit comments