1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
* See LICENSE.md
*/
import SwiftUI
import taler_swift
import AVFoundation
struct QRCodeDetailView: View {
let talerURI: String
let incoming: Bool
let amount: Amount
@EnvironmentObject private var controller: Controller
@AppStorage("minimalistic") var minimalistic: Bool = false
var amountStr: String {
if let currencyInfo = controller.info(for: amount.currencyStr) {
return amount.string(currencyInfo)
}
return amount.readableDescription
}
var body: some View {
if talerURI.count > 10 {
Section {
let eitherMini = incoming ? String(localized: "Either (payer) Mini 1",
defaultValue: "Either",
comment: "Either (copy/share this link to the payer)")
: String(localized: "Either (payee) Mini 1",
defaultValue: "Either",
comment: "Either (copy/share this link to the payee)")
let eitherLong = incoming ? String(localized: "Either (payer) Long 1",
defaultValue: "Either provide this payment link")
: String(localized: "Either (payee) Long 1",
defaultValue: "Either provide this payment link")
Text(minimalistic ? eitherMini : eitherLong)
.multilineTextAlignment(.leading)
.talerFont(.title3)
// .padding(.vertical)
.listRowSeparator(.hidden)
CopyShare(textToCopy: talerURI)
.disabled(false)
// .padding(.bottom)
.listRowSeparator(.hidden)
let otherPartyMini = incoming ? String(localized: "Either (payer) Mini 2", defaultValue: "or scan this")
: String(localized: "Either (payee) Mini 2", defaultValue: "or scan this")
let otherPartyLong = incoming ? String(localized: "Either (payer) Long 2", defaultValue: "to the payer, or")
: String(localized: "Either (payee) Long 2", defaultValue: "to the payee, or")
Text(minimalistic ? otherPartyMini : otherPartyLong)
.multilineTextAlignment(.leading)
.talerFont(.title3)
.listRowSeparator(.hidden)
QRGeneratorView(text: talerURI)
.frame(maxWidth: .infinity, alignment: .center)
.accessibilityLabel("QR Code")
.listRowSeparator(.hidden)
let scanMini = incoming ? String(localized: "Either (payer) Mini 3",
defaultValue: "to pay \(amountStr).", comment: "e.g. '5,3 €'")
: String(localized: "Either (payee) Mini 3",
defaultValue: "to receive \(amountStr).", comment: "e.g. '$ 7.41'")
let scanLong = incoming ? String(localized: "Either (payer) Long 3",
defaultValue: "let the payer scan this QR code to pay \(amountStr).",
comment: "e.g. '5,3 €'")
: String(localized: "Either (payee) Long 3",
defaultValue: "let the payee scan this QR code to receive \(amountStr).",
comment: "e.g. '$ 7.41'")
Text(minimalistic ? scanMini : scanLong)
.multilineTextAlignment(.leading)
.talerFont(.title3)
}
}
}
}
// MARK: -
#if DEBUG
fileprivate struct ContentView: View {
@State var talerURI: String = "taler://pay-push/exchange.demo.taler.net/95ZG4D1AGFGZQ7CNQ1V49D3FT18HXKA6HQT4X3XME9YSJQVFQ520"
var body: some View {
let amount = Amount(currency: LONGCURRENCY, cent: 123)
List {
QRCodeDetailView(talerURI: talerURI, incoming: false, amount: amount)
}
}
}
struct QRCodeDetailView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
|