mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 16:33:27 +00:00
feat: replace zap button long-press-to-edit with long-press-to-custom
The new Tune button inside the zap popup already opens the quick-zap
amounts editor, so the long-press shortcut from the zap button itself
(and from each chip inside the popup) is now redundant. Drop those
gestures and replace them with the custom-amount dialog that used to
live behind double-click:
- ZapReaction's button: long-press now opens ZapCustomDialog;
double-click is gone.
- Each chip in the popup: long-press now opens ZapCustomDialog
(via a new onCustomAmount callback threaded through the popup
overloads).
- NestActionBar's zap button wires onCustomAmount to its existing
wantsToSetCustomZap state.
- ReusableZapButton has no custom-zap dialog, so chip long-press
just dismisses the popup there.
This commit is contained in:
@@ -170,6 +170,9 @@ fun ReusableZapButton(
|
||||
onChangeAmount = {
|
||||
wantsToZap = null
|
||||
},
|
||||
onCustomAmount = {
|
||||
wantsToZap = null
|
||||
},
|
||||
onError = { _, message, user ->
|
||||
scope.launch {
|
||||
zappingProgress = 0f
|
||||
|
||||
@@ -1242,8 +1242,7 @@ fun ZapReaction(
|
||||
)
|
||||
}
|
||||
},
|
||||
onLongClick = { nav.nav(Route.UpdateZapAmount()) },
|
||||
onDoubleClick = { wantsToSetCustomZap = true },
|
||||
onLongClick = { wantsToSetCustomZap = true },
|
||||
),
|
||||
) {
|
||||
if (wantsToZap) {
|
||||
@@ -1262,6 +1261,12 @@ fun ZapReaction(
|
||||
nav.nav(Route.UpdateZapAmount())
|
||||
}
|
||||
},
|
||||
onCustomAmount = {
|
||||
scope.launch {
|
||||
wantsToZap = false
|
||||
wantsToSetCustomZap = true
|
||||
}
|
||||
},
|
||||
onError = { _, message, user ->
|
||||
scope.launch {
|
||||
zappingProgress = 0f
|
||||
@@ -1886,6 +1891,7 @@ fun ZapAmountChoicePopup(
|
||||
onZapStarts: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
onChangeAmount: () -> Unit,
|
||||
onCustomAmount: () -> Unit,
|
||||
onError: (title: String, text: String, user: User?) -> Unit,
|
||||
onProgress: (percent: Float) -> Unit,
|
||||
onPayViaIntent: (ImmutableList<ZapPaymentHandler.Payable>) -> Unit,
|
||||
@@ -1894,7 +1900,7 @@ fun ZapAmountChoicePopup(
|
||||
accountViewModel.account.settings.syncedSettings.zaps.zapAmountChoices
|
||||
.collectAsStateWithLifecycle()
|
||||
|
||||
ZapAmountChoicePopup(baseNote, zapAmountChoices, accountViewModel, popupYOffset, onZapStarts, onDismiss, onChangeAmount, onError, onProgress, onPayViaIntent)
|
||||
ZapAmountChoicePopup(baseNote, zapAmountChoices, accountViewModel, popupYOffset, onZapStarts, onDismiss, onChangeAmount, onCustomAmount, onError, onProgress, onPayViaIntent)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -1906,12 +1912,13 @@ fun ZapAmountChoicePopup(
|
||||
onZapStarts: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
onChangeAmount: () -> Unit,
|
||||
onCustomAmount: () -> Unit,
|
||||
onError: (title: String, text: String, user: User?) -> Unit,
|
||||
onProgress: (percent: Float) -> Unit,
|
||||
onPayViaIntent: (ImmutableList<ZapPaymentHandler.Payable>) -> Unit,
|
||||
) {
|
||||
val visibilityState = rememberVisibilityState(onDismiss)
|
||||
ZapAmountChoicePopup(baseNote, zapAmountChoices, accountViewModel, popupYOffset, visibilityState, onZapStarts, onChangeAmount, onError, onProgress, onPayViaIntent)
|
||||
ZapAmountChoicePopup(baseNote, zapAmountChoices, accountViewModel, popupYOffset, visibilityState, onZapStarts, onChangeAmount, onCustomAmount, onError, onProgress, onPayViaIntent)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class, ExperimentalLayoutApi::class)
|
||||
@@ -1924,6 +1931,7 @@ fun ZapAmountChoicePopup(
|
||||
visibilityState: MutableTransitionState<Boolean>,
|
||||
onZapStarts: () -> Unit,
|
||||
onChangeAmount: () -> Unit,
|
||||
onCustomAmount: () -> Unit,
|
||||
onError: (title: String, text: String, user: User?) -> Unit,
|
||||
onProgress: (percent: Float) -> Unit,
|
||||
onPayViaIntent: (ImmutableList<ZapPaymentHandler.Payable>) -> Unit,
|
||||
@@ -1960,6 +1968,10 @@ fun ZapAmountChoicePopup(
|
||||
visibilityState.targetState = false
|
||||
},
|
||||
onChangeAmount = onChangeAmount,
|
||||
onCustomAmount = {
|
||||
visibilityState.targetState = false
|
||||
onCustomAmount()
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1971,6 +1983,7 @@ fun ZapAmountChoicePopupContent(
|
||||
zapAmountChoices: ImmutableList<Long>,
|
||||
onZap: (Long) -> Unit,
|
||||
onChangeAmount: () -> Unit,
|
||||
onCustomAmount: () -> Unit,
|
||||
) {
|
||||
Box(HalfPadding, contentAlignment = Center) {
|
||||
ElevatedCard(
|
||||
@@ -1988,7 +2001,7 @@ fun ZapAmountChoicePopupContent(
|
||||
ZapAmountChip(
|
||||
amountInSats = amountInSats,
|
||||
onClick = { onZap(amountInSats) },
|
||||
onLongClick = onChangeAmount,
|
||||
onLongClick = onCustomAmount,
|
||||
)
|
||||
}
|
||||
ClickableBox(
|
||||
@@ -2055,6 +2068,7 @@ fun ZapAmountChoicePopupPreview() {
|
||||
zapAmountChoices = persistentListOf(50L, 100L, 500L, 1_000L, 5_000L, 10_000L, 100_000L),
|
||||
onZap = {},
|
||||
onChangeAmount = {},
|
||||
onCustomAmount = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -437,10 +437,9 @@ private fun EndCluster(
|
||||
* applies the user's configured zap amount choices the same way the
|
||||
* normal note ⚡ button does (single-tap fires the default amount;
|
||||
* multi-choice opens [ZapAmountChoicePopup]; an unconfigured account
|
||||
* opens [ZapCustomDialog]). Long-press routes to the
|
||||
* [Route.UpdateZapAmount] settings screen via the activity's
|
||||
* [BouncingIntentNav] (no-op when the route can't be expressed as a
|
||||
* `nostr:` URI — same fallback as the chat panel uses).
|
||||
* opens [ZapCustomDialog]). Inside the multi-choice popup the Tune
|
||||
* button jumps to the [Route.UpdateZapAmount] settings screen and
|
||||
* long-press on a chip opens [ZapCustomDialog].
|
||||
*/
|
||||
@OptIn(ExperimentalUuidApi::class)
|
||||
@Composable
|
||||
@@ -537,6 +536,12 @@ private fun NestZapButton(
|
||||
nav.nav(Route.UpdateZapAmount())
|
||||
}
|
||||
},
|
||||
onCustomAmount = {
|
||||
scope.launch {
|
||||
wantsToZap = false
|
||||
wantsToSetCustomZap = true
|
||||
}
|
||||
},
|
||||
onError = { _, message, user ->
|
||||
scope.launch {
|
||||
zappingProgress = 0f
|
||||
|
||||
Reference in New Issue
Block a user