Skip to content

Commit f1033ad

Browse files
committed
feat: implement tab WIP
1 parent 7bcffcd commit f1033ad

File tree

2 files changed

+12
-55
lines changed

2 files changed

+12
-55
lines changed

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -88,35 +88,6 @@ fun getQrLogoResource(tab: ReceiveTab, hasCjit: Boolean): Int {
8888
}
8989
}
9090

91-
/**
92-
* Determines whether the Auto (unified) tab should be visible.
93-
*
94-
* Logic:
95-
* - Node must be running
96-
* - If geoblocked: only show if user has existing channels (grandfathered)
97-
* - If not geoblocked: always show
98-
*
99-
* @param channels List of Lightning channels
100-
* @param isGeoblocked Whether Lightning is geoblocked for this user
101-
* @param nodeRunning Whether the Lightning node is running
102-
* @return true if Auto tab should be visible
103-
*/
104-
fun shouldShowAutoTab(
105-
channels: List<ChannelDetails>,
106-
isGeoblocked: Boolean,
107-
nodeRunning: Boolean
108-
): Boolean {
109-
if (!nodeRunning) return false
110-
111-
return if (isGeoblocked) {
112-
// Geoblocked users can still use Auto if they have existing channels
113-
channels.isNotEmpty()
114-
} else {
115-
// Not geoblocked: always show Auto tab
116-
true
117-
}
118-
}
119-
12091
/**
12192
* Extension: Check if node lifecycle state is running.
12293
*/

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

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import androidx.compose.ui.res.stringResource
3939
import androidx.compose.ui.tooling.preview.Devices.NEXUS_5
4040
import androidx.compose.ui.tooling.preview.Preview
4141
import androidx.compose.ui.unit.dp
42-
import com.google.accompanist.pager.HorizontalPagerIndicator
4342
import kotlinx.coroutines.launch
4443
import to.bitkit.R
4544
import to.bitkit.ext.setClipboardText
@@ -83,13 +82,11 @@ fun ReceiveQrScreen(
8382
// Tab selection state
8483
var selectedTab by remember {
8584
mutableStateOf(
86-
if (shouldShowAutoTab(
87-
walletState.channels,
88-
lightningState.shouldBlockLightningReceive,
89-
walletState.nodeLifecycleState.isRunning()
90-
)
91-
) ReceiveTab.AUTO
92-
else ReceiveTab.SAVINGS
85+
if (walletState.channels.isNotEmpty()) {
86+
ReceiveTab.AUTO
87+
} else {
88+
ReceiveTab.SAVINGS
89+
}
9390
)
9491
}
9592

@@ -100,17 +97,10 @@ fun ReceiveQrScreen(
10097
val visibleTabs = remember(walletState, lightningState) {
10198
buildList {
10299
add(ReceiveTab.SAVINGS) // Always visible
103-
if (shouldShowAutoTab(
104-
walletState.channels,
105-
lightningState.shouldBlockLightningReceive,
106-
walletState.nodeLifecycleState.isRunning()
107-
)
108-
) {
100+
if (walletState.channels.isNotEmpty()) {
109101
add(ReceiveTab.AUTO)
110102
}
111-
if (walletState.nodeLifecycleState.isRunning()) {
112-
add(ReceiveTab.SPENDING)
113-
}
103+
add(ReceiveTab.SPENDING)
114104
}
115105
}
116106

@@ -200,9 +190,7 @@ fun ReceiveQrScreen(
200190

201191
Spacer(Modifier.height(16.dp))
202192

203-
// Node state indicator (simplified from lines 150-190)
204193
ReceiveNodeStateIndicator(
205-
nodeLifecycleState = walletState.nodeLifecycleState,
206194
selectedTab = selectedTab,
207195
cjitActive = cjitActive.value
208196
)
@@ -218,7 +206,7 @@ private fun ReceiveQrView(
218206
uri: String,
219207
qrLogoPainter: Painter,
220208
onClickEditInvoice: () -> Unit,
221-
modifier: Modifier = Modifier
209+
modifier: Modifier = Modifier,
222210
) {
223211
val context = androidx.compose.ui.platform.LocalContext.current
224212
val qrButtonTooltipState = rememberTooltipState()
@@ -314,7 +302,7 @@ private fun ReceiveDetailsView(
314302
bolt11: String,
315303
cjitInvoice: String?,
316304
bip21: String,
317-
modifier: Modifier = Modifier
305+
modifier: Modifier = Modifier,
318306
) {
319307
Card(
320308
colors = CardDefaults.cardColors(containerColor = Colors.White10),
@@ -333,6 +321,7 @@ private fun ReceiveDetailsView(
333321
)
334322
}
335323
}
324+
336325
ReceiveTab.AUTO -> {
337326
// Show both onchain AND lightning if available
338327
if (onchainAddress.isNotEmpty()) {
@@ -352,6 +341,7 @@ private fun ReceiveDetailsView(
352341
)
353342
}
354343
}
344+
355345
ReceiveTab.SPENDING -> {
356346
if (cjitInvoice != null || bolt11.isNotEmpty()) {
357347
CopyAddressCard(
@@ -369,14 +359,10 @@ private fun ReceiveDetailsView(
369359

370360
@Composable
371361
private fun ReceiveNodeStateIndicator(
372-
nodeLifecycleState: to.bitkit.models.NodeLifecycleState,
373362
selectedTab: ReceiveTab,
374-
cjitActive: Boolean
363+
cjitActive: Boolean,
375364
) {
376365
when {
377-
nodeLifecycleState.isStarting() -> {
378-
BodyM(text = androidx.compose.ui.res.stringResource(R.string.wallet__receive_ldk_init))
379-
}
380366
selectedTab == ReceiveTab.SPENDING && cjitActive -> {
381367
BodyS(
382368
text = "CJIT Active",

0 commit comments

Comments
 (0)