commit 6306dfff9a60ddb0a55f98d6531be869e283fc7d
parent f61ff2dd9f3b42ccb9037aed97071f755a8cc41e
Author: Iván Ávalos <avalos@disroot.org>
Date: Wed, 10 Jul 2024 13:47:44 -0600
[wallet] Reposition QR codes
bug 0008957
Diffstat:
2 files changed, 77 insertions(+), 46 deletions(-)
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/manual/PaytoQrCard.kt b/wallet/src/main/java/net/taler/wallet/withdraw/manual/PaytoQrCard.kt
@@ -0,0 +1,56 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2024 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.wallet.withdraw.manual
+
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.res.stringResource
+import net.taler.wallet.R
+import net.taler.wallet.compose.ExpandableCard
+import net.taler.wallet.compose.QrCodeUriComposable
+import net.taler.wallet.withdraw.QrCodeSpec
+import net.taler.wallet.withdraw.QrCodeSpec.Type.EpcQr
+import net.taler.wallet.withdraw.QrCodeSpec.Type.SPC
+
+@Composable
+fun PaytoQrCard(
+ expanded: Boolean,
+ setExpanded: (expanded: Boolean) -> Unit,
+ qrCode: QrCodeSpec,
+) {
+ val label = when(qrCode.type) {
+ EpcQr -> stringResource(R.string.withdraw_manual_qr_epc)
+ SPC -> stringResource(R.string.withdraw_manual_qr_spc)
+ else -> return
+ }
+
+ ExpandableCard(
+ expanded = expanded,
+ setExpanded = setExpanded,
+ header = {
+ Text(label, style = MaterialTheme.typography.titleMedium)
+ },
+ content = {
+ QrCodeUriComposable(
+ talerUri = qrCode.qrContent,
+ clipBoardLabel = label,
+ showContents = false,
+ )
+ },
+ )
+}
+\ No newline at end of file
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/manual/ScreenTransfer.kt b/wallet/src/main/java/net/taler/wallet/withdraw/manual/ScreenTransfer.kt
@@ -17,7 +17,9 @@
package net.taler.wallet.withdraw.manual
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
@@ -50,8 +52,6 @@ import net.taler.common.Amount
import net.taler.common.CurrencySpecification
import net.taler.wallet.CURRENCY_BTC
import net.taler.wallet.R
-import net.taler.wallet.compose.ExpandableCard
-import net.taler.wallet.compose.QrCodeUriComposable
import net.taler.common.canAppHandleUri
import net.taler.wallet.compose.ShareButton
import net.taler.wallet.compose.copyToClipBoard
@@ -142,6 +142,24 @@ fun ScreenTransfer(
)
}
+ qrCodes.forEach { spec ->
+ PaytoQrCard(
+ expanded = qrExpandedStates[spec]!!,
+ setExpanded = { expanded ->
+ if (expanded) { // un-expand all others
+ qrExpandedStates.forEach { (k, _) ->
+ qrExpandedStates[k] = false
+ }
+ }
+ // expand only toggled one
+ qrExpandedStates[spec] = expanded
+ },
+ qrCode = spec,
+ )
+ }
+
+ Spacer(Modifier.height(24.dp))
+
val paytoUri = selectedTransfer.withdrawalAccount.paytoUri
if (bankAppClick != null && LocalContext.current.canAppHandleUri(paytoUri)) {
Button(
@@ -160,22 +178,6 @@ fun ScreenTransfer(
.padding(bottom = 16.dp),
)
}
-
- qrCodes.forEach { spec ->
- QrCard(
- expanded = qrExpandedStates[spec]!!,
- setExpanded = { expanded ->
- if (expanded) { // un-expand all others
- qrExpandedStates.forEach { (k, _) ->
- qrExpandedStates[k] = false
- }
- }
- // expand only toggled one
- qrExpandedStates[spec] = expanded
- },
- qrCode = spec,
- )
- }
}
}
}
@@ -306,34 +308,6 @@ fun TransferAccountChooser(
}
}
-@Composable
-fun QrCard(
- expanded: Boolean,
- setExpanded: (expanded: Boolean) -> Unit,
- qrCode: QrCodeSpec,
-) {
- val label = when(qrCode.type) {
- EpcQr -> stringResource(R.string.withdraw_manual_qr_epc)
- SPC -> stringResource(R.string.withdraw_manual_qr_spc)
- else -> return
- }
-
- ExpandableCard(
- expanded = expanded,
- setExpanded = setExpanded,
- header = {
- Text(label, style = MaterialTheme.typography.titleMedium)
- },
- content = {
- QrCodeUriComposable(
- talerUri = qrCode.qrContent,
- clipBoardLabel = label,
- showContents = false,
- )
- },
- )
-}
-
@Preview
@Composable
fun ScreenTransferPreview() {