From e9285fdac0521b80cc9c9c4793ff0ed667295c26 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sat, 23 Dec 2023 12:37:10 -0500 Subject: [PATCH] Simplifying the reaction row zap click. --- .../amethyst/ui/note/ReactionsRow.kt | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index 6ceab65c64..349970ce6b 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -861,6 +861,10 @@ fun ZapReaction( animationSize: Dp = 14.dp, nav: (String) -> Unit ) { + val iconButtonModifier = remember { + Modifier.size(iconSize) + } + var wantsToZap by remember { mutableStateOf(false) } var wantsToChangeZapAmount by remember { mutableStateOf(false) } var wantsToSetCustomZap by remember { mutableStateOf(false) } @@ -878,43 +882,41 @@ fun ZapReaction( Row( verticalAlignment = CenterVertically, - modifier = Modifier - .size(iconSize) - .combinedClickable( - role = Role.Button, - interactionSource = remember { MutableInteractionSource() }, - indication = rememberRipple(bounded = false, radius = Size24dp), - onClick = { - zapClick( - baseNote, - accountViewModel, - context, - onZappingProgress = { progress: Float -> - scope.launch { - zappingProgress = progress - } - }, - onMultipleChoices = { - wantsToZap = true - }, - onError = { _, message -> - scope.launch { - zappingProgress = 0f - showErrorMessageDialog = message - } - }, - onPayViaIntent = { - wantsToPay = it + modifier = iconButtonModifier.combinedClickable( + role = Role.Button, + interactionSource = remember { MutableInteractionSource() }, + indication = rememberRipple(bounded = false, radius = Size24dp), + onClick = { + zapClick( + baseNote, + accountViewModel, + context, + onZappingProgress = { progress: Float -> + scope.launch { + zappingProgress = progress } - ) - }, - onLongClick = { - wantsToChangeZapAmount = true - }, - onDoubleClick = { - wantsToSetCustomZap = true - } - ) + }, + onMultipleChoices = { + wantsToZap = true + }, + onError = { _, message -> + scope.launch { + zappingProgress = 0f + showErrorMessageDialog = message + } + }, + onPayViaIntent = { + wantsToPay = it + } + ) + }, + onLongClick = { + wantsToChangeZapAmount = true + }, + onDoubleClick = { + wantsToSetCustomZap = true + } + ) ) { if (wantsToZap) { ZapAmountChoicePopup( @@ -1353,8 +1355,6 @@ fun ZapAmountChoicePopup( onPayViaIntent: (ImmutableList) -> Unit ) { val context = LocalContext.current - val accountState by accountViewModel.accountLiveData.observeAsState() - val account = accountState?.account ?: return val zapMessage = "" Popup( @@ -1363,7 +1363,7 @@ fun ZapAmountChoicePopup( onDismissRequest = { onDismiss() } ) { FlowRow(horizontalArrangement = Arrangement.Center) { - account.zapAmountChoices.forEach { amountInSats -> + accountViewModel.account.zapAmountChoices.forEach { amountInSats -> Button( modifier = Modifier.padding(horizontal = 3.dp), onClick = { @@ -1376,7 +1376,7 @@ fun ZapAmountChoicePopup( onError, onProgress, onPayViaIntent, - account.defaultZapType + accountViewModel.account.defaultZapType ) onDismiss() }, @@ -1401,7 +1401,7 @@ fun ZapAmountChoicePopup( onError, onProgress, onPayViaIntent, - account.defaultZapType + accountViewModel.account.defaultZapType ) onDismiss() },