feat: hide on-chain wallet from zap buttons too

Extend the showOnchainWallet preference to the zap flows, which also surface an
on-chain rail:

- the on-chain rail on each zap-amount chip in ZapAmountChoicePopup (folded into
  the shared railCapability so every caller — reaction row, ReusableZapButton —
  is covered)
- the "Send on-chain instead" hand-off button in the custom zap dialog

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UM57Rq5iUPL1SGhzhzTusa
This commit is contained in:
Claude
2026-07-05 20:25:51 +00:00
parent d69d99a8e1
commit e3fd1c53e4
2 changed files with 25 additions and 12 deletions
@@ -2067,11 +2067,16 @@ fun ZapAmountChoicePopup(
val cashuEntries by cashuState.tokenEntries.collectAsStateWithLifecycle()
val recipientInfo = author?.let { observeUserInfo(it, accountViewModel).value }
val nutzapInfo = author?.let { observeNoteEvent<NutzapInfoEvent>(it.nutzapInfoNote, accountViewModel).value }
// Honors the user's "show on-chain wallet" preference: off hides the on-chain
// rail from the zap chips too, matching the wallet screen, profile chips, and
// Send Payment screen.
val showOnchainWallet by accountViewModel.settings.uiSettingsFlow.showOnchainWallet
.collectAsStateWithLifecycle()
val railCapability =
remember(baseNote, onchainSupported, cashuMints, cashuEntries, recipientInfo, nutzapInfo) {
remember(baseNote, onchainSupported, showOnchainWallet, cashuMints, cashuEntries, recipientInfo, nutzapInfo) {
val rc = RailCapabilityResolver.peek(baseNote, cashuState)
if (onchainSupported) rc else rc.copy(hasOnchain = false)
if (onchainSupported && showOnchainWallet) rc else rc.copy(hasOnchain = false)
}
val amountChoices =
remember(zapAmountChoices) {
@@ -71,6 +71,7 @@ import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.core.net.toUri
import androidx.lifecycle.ViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.Account
@@ -180,6 +181,11 @@ fun ZapCustomDialog(
// payment method, no "go back to Lightning" is offered here.
var sendOnchain by remember { mutableStateOf(false) }
// Hides the "Send on-chain instead" hand-off when the user has turned the
// on-chain wallet off, matching every other on-chain surface.
val showOnchainWallet by accountViewModel.settings.uiSettingsFlow.showOnchainWallet
.collectAsStateWithLifecycle()
Dialog(
onDismissRequest = { onClose() },
properties =
@@ -353,16 +359,18 @@ fun ZapCustomDialog(
// Hand off to the on-chain dialog with the entered amount +
// message prefilled. Disabled while the amount is empty so the
// user can't open a sheet that immediately gates on its own
// empty field.
TextButton(
onClick = { sendOnchain = true },
enabled = postViewModel.canSend() && !baseNote.isDraft(),
modifier =
Modifier
.fillMaxWidth()
.padding(top = 4.dp),
) {
Text(text = stringRes(id = R.string.send_onchain_instead))
// empty field. Hidden entirely when the on-chain wallet is off.
if (showOnchainWallet) {
TextButton(
onClick = { sendOnchain = true },
enabled = postViewModel.canSend() && !baseNote.isDraft(),
modifier =
Modifier
.fillMaxWidth()
.padding(top = 4.dp),
) {
Text(text = stringRes(id = R.string.send_onchain_instead))
}
}
}
}