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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
* See LICENSE.md
*/
/**
* @author Marc Stibane
*/
import SwiftUI
import taler_swift
import SymLog
struct AboutView: View {
private let symLog = SymLogV(0)
let stack: CallStack
let navTitle: String
@EnvironmentObject private var controller: Controller
#if DEBUG
@AppStorage("developerMode") var developerMode: Bool = true
#else
@AppStorage("developerMode") var developerMode: Bool = false
#endif
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
@AppStorage("minimalistic") var minimalistic: Bool = false
@State private var rotationEnabled = false
@State private var showGitHash = false
@State private var listID = UUID()
var body: some View {
#if PRINT_CHANGES
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear
#endif
let walletCore = WalletCore.shared
Group {
List {
RotatingTaler(size: 100, progress: false,
rotationEnabled: $rotationEnabled)
.frame(maxWidth: .infinity, alignment: .center)
// .accessibilityLabel("Progress indicator")
.onTapGesture(count: 1) { rotationEnabled.toggle() }
SettingsItem(name: "Visit the taler.net website", id1: "web",
description: minimalistic ? nil : String(localized: "More info about GNU Taler in general...")) { }
.accessibilityAddTraits(.isLink)
.accessibilityRemoveTraits(.isStaticText)
.onTapGesture() {
UIApplication.shared.open(URL(string:TALER_NET)!, options: [:])
}
SettingsItem(name: "App Version", id1: "app") {
Text(verbatim: "\(Bundle.main.releaseVersionNumberPretty)")
}
Group {
if showGitHash {
SettingsItem(name: "Wallet-Core Git", id1: "wallet-coreG") {
if let gitHash = walletCore.versionInfo?.implementationGitHash {
let index = gitHash.index(gitHash.startIndex, offsetBy: 7)
Text(gitHash[..<index])
} else {
Text(verbatim: "unknown")
}
}
} else {
SettingsItem(name: "Wallet-Core Version", id1: "wallet-coreV") {
Text(verbatim: "\(walletCore.versionInfo?.implementationSemver ?? "unknown")")
}
}
}.onTapGesture(count: 1) { showGitHash.toggle() }
// SettingsItem(name: "Supported Exchange Versions", id1: "exchange") {
// Text(verbatim: "\(walletCore.versionInfo?.exchange ?? "unknown")")
// }
// SettingsItem(name: "Supported Merchant Versions", id1: "merchant") {
// Text(verbatim: "\(walletCore.versionInfo?.merchant ?? "unknown")")
// }
// SettingsItem(name: "Used Bank", id1: "bank") {
// Text(verbatim: "\(walletCore.versionInfo?.bank ?? "unknown")")
// }
}
.id(listID)
.listStyle(myListStyle.style).anyView
}
.navigationTitle(navTitle)
.onAppear() {
DebugViewC.shared.setViewID(VIEW_ABOUT, stack: stack.push())
}
.onDisappear() {
}
// .task {
// try? await Task.sleep(nanoseconds: 1_000_000_000 * UInt64(5))
// rotationEnabled.toggle()
// }
}
}
extension Bundle {
var bundleName: String? {
return infoDictionary?["CFBundleDisplayName"] as? String
}
var releaseVersionNumber: String? {
return infoDictionary?["CFBundleShortVersionString"] as? String
}
var buildVersionNumber: String {
let build = infoDictionary?["CFBundleVersion"]
let zero = "0"
if let build {
return build as? String ?? zero
}
return zero
}
var releaseVersionNumberPretty: String {
let release = releaseVersionNumber ?? "1.0.0"
return "v\(release) (\(buildVersionNumber))"
}
}
// MARK: -
#if DEBUG
struct AboutView_Previews: PreviewProvider {
static var previews: some View {
AboutView(stack: CallStack("Preview"), navTitle: "About")
}
}
#endif
|