[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 09/32: remove QR from Overview
From: |
gnunet |
Subject: |
[taler-taler-ios] 09/32: remove QR from Overview |
Date: |
Sun, 14 Jul 2024 00:19:18 +0200 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit 4ceabb65609b5e6a84704ab38ec5a3601249e32a
Author: Marc Stibane <marc@taler.net>
AuthorDate: Wed Jun 26 15:19:19 2024 +0200
remove QR from Overview
---
TalerWallet1/Views/Overview/OverviewListV.swift | 158 +++++-------------------
1 file changed, 33 insertions(+), 125 deletions(-)
diff --git a/TalerWallet1/Views/Overview/OverviewListV.swift
b/TalerWallet1/Views/Overview/OverviewListV.swift
index d5475a5..11c07bb 100644
--- a/TalerWallet1/Views/Overview/OverviewListV.swift
+++ b/TalerWallet1/Views/Overview/OverviewListV.swift
@@ -5,78 +5,23 @@
import SwiftUI
import taler_swift
import SymLog
-import AVFoundation
/// This view shows the list of balances / currencies, each in its own section
struct OverviewListV: View {
private let symLog = SymLogV(0)
let stack: CallStack
- let navTitle: String
@Binding var balances: [Balance]
// @Binding var shouldReloadPending: Int
@Binding var shouldReloadBalances: Int
+ let cameraAction: () -> Void
@EnvironmentObject private var model: WalletModel
@EnvironmentObject private var controller: Controller
+ @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
@State private var lastReloadedBalances = 0
@State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING)
// Update currency when used
@State private var summary: String = ""
- @State private var showQRScanner: Bool = false
- @State private var showCameraAlert: Bool = false
-
- private var openSettingsButton: some View {
- Button("Open Settings") {
- showCameraAlert = false
- UIApplication.shared.open(URL(string:
UIApplication.openSettingsURLString)!)
- }
- }
- let ClosingAnnouncement = AttributedString(localized: "Closing Camera")
- private var dismissAlertButton: some View {
- Button("Cancel", role: .cancel) {
- if #available(iOS 17.0, *) {
-
AccessibilityNotification.Announcement(ClosingAnnouncement).post()
- }
- showCameraAlert = false
- }
- }
- private func dismissingSheet() {
- if #available(iOS 17.0, *) {
- AccessibilityNotification.Announcement(ClosingAnnouncement).post()
- }
- }
-
- var defaultPriorityAnnouncement = AttributedString(localized: "Opening
Camera")
- var lowPriorityAnnouncement: AttributedString {
- var lowPriorityString = AttributedString ("Camera Loading")
- if #available(iOS 17.0, *) {
- lowPriorityString.accessibilitySpeechAnnouncementPriority = .low
- }
- return lowPriorityString
- }
- var highPriorityAnnouncement: AttributedString {
- var highPriorityString = AttributedString("Camera Active")
- if #available(iOS 17.0, *) {
- highPriorityString.accessibilitySpeechAnnouncementPriority = .high
- }
- return highPriorityString
- }
- private func checkCameraAvailable() -> Void {
- // Open Camera when QR-Button was tapped
- if #available(iOS 17.0, *) {
-
AccessibilityNotification.Announcement(defaultPriorityAnnouncement).post()
- }
- AVCaptureDevice.requestAccess(for: .video, completionHandler: {
(granted: Bool) -> Void in
- if granted {
- showQRScanner = true // present sheet
- if #available(iOS 17.0, *) {
-
AccessibilityNotification.Announcement(highPriorityAnnouncement).post()
- }
- } else {
- showCameraAlert = true
- }
- })
- }
/// runs on MainActor if called in some Task {}
@discardableResult
@@ -99,77 +44,40 @@ struct OverviewListV: View {
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with
.onAppear & onDisappear
#endif
- Content(symLog: symLog, stack: stack.push(), balances: $balances,
- amountToTransfer: $amountToTransfer, summary: $summary,
-// shouldReloadPending: $shouldReloadPending,
- shouldReloadBalances: $shouldReloadBalances,
- reloadBalances: reloadBalances)
- .navigationTitle(navTitle)
- .navigationBarItems(trailing: QRButton(action:
checkCameraAvailable))
- .alert("Scanning QR-codes requires access to the camera",
- isPresented: $showCameraAlert,
- actions: { openSettingsButton
- dismissAlertButton },
- message: { Text("Please allow camera access in
settings.") })
- .sheet(isPresented: $showQRScanner, onDismiss: dismissingSheet) {
- let sheet = AnyView(QRSheet(stack: stack.push(".sheet")))
- Sheet(sheetView: sheet)
- } // sheet
- .task(id: shouldReloadBalances) {
- symLog.log(".task shouldReloadBalances
\(shouldReloadBalances)")
- let invalidateCache = (lastReloadedBalances !=
shouldReloadBalances)
- lastReloadedBalances = shouldReloadBalances
- await reloadBalances(stack.push(".task"), invalidateCache)
- } // task
- }
-}
-// MARK: -
-extension OverviewListV {
- struct Content: View {
- let symLog: SymLogV?
- let stack: CallStack
- @Binding var balances: [Balance]
- @Binding var amountToTransfer: Amount
- @Binding var summary: String
-// @Binding var shouldReloadPending: Int
- @Binding var shouldReloadBalances: Int
- var reloadBalances: (_ stack: CallStack, _ invalidateCache: Bool)
async -> Int?
-
- @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
-
- var body: some View {
-#if PRINT_CHANGES
- let _ = Self._printChanges()
- let _ = symLog?.vlog() // just to get the # to compare it
with .onAppear & onDisappear
-#endif
- Group { // necessary for .backslide transition (bug in SwiftUI)
- let count = balances.count
- if balances.isEmpty {
- WalletEmptyView(stack: stack.push("isEmpty"))
- } else {
- List(balances, id: \.self) { balance in
- OverviewSectionV(stack:
stack.push("\(balance.scopeInfo.currency)"),
- balance: balance,
// this is the currency to be used
- sectionCount: count,
- amountToTransfer: $amountToTransfer,
// does still have the wrong currency
- summary: $summary,
- shouldReloadBalances: $shouldReloadBalances)
- }
- .onAppear() {
- DebugViewC.shared.setViewID(VIEW_BALANCES, stack:
stack.push("onAppear"))
- }
- .listStyle(myListStyle.style).anyView
+ Group { // necessary for .backslide transition (bug in SwiftUI)
+ let count = balances.count
+ if balances.isEmpty {
+ WalletEmptyView(stack: stack.push("isEmpty"))
+ } else {
+ List(balances, id: \.self) { balance in
+ OverviewSectionV(stack:
stack.push("\(balance.scopeInfo.currency)"),
+ balance: balance, //
this is the currency to be used
+ sectionCount: count,
+ amountToTransfer: $amountToTransfer, //
does still have the wrong currency
+ summary: $summary,
+ shouldReloadBalances: $shouldReloadBalances)
}
+ .onAppear() {
+ DebugViewC.shared.setViewID(VIEW_BALANCES, stack:
stack.push("onAppear"))
+ }
+ .listStyle(myListStyle.style).anyView
}
+ }
#if REFRESHABLE
- .refreshable { // already async
- symLog?.log("refreshing balances")
- let count = await reloadBalances(stack.push("refreshing
balances"), true)
- if let count, count > 0 {
- NotificationCenter.default.post(name: .BalanceReloaded,
object: nil)
- }
+ .refreshable { // already async
+ symLog?.log("refreshing balances")
+ let count = await reloadBalances(stack.push("refreshing
balances"), true)
+ if let count, count > 0 {
+ NotificationCenter.default.post(name: .BalanceReloaded,
object: nil)
}
+ }
#endif
- } // body
- } // Content
+ .navigationBarItems(trailing: QRButton(action: cameraAction))
+ .task(id: shouldReloadBalances) {
+ symLog.log(".task shouldReloadBalances \(shouldReloadBalances)")
+ let invalidateCache = (lastReloadedBalances !=
shouldReloadBalances)
+ lastReloadedBalances = shouldReloadBalances
+ await reloadBalances(stack.push(".task"), invalidateCache)
+ } // task
+ }
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 05/32: move QR scanner into MainView, (continued)
- [taler-taler-ios] 05/32: move QR scanner into MainView, gnunet, 2024/07/13
- [taler-taler-ios] 15/32: minimalistic: no currency name, gnunet, 2024/07/13
- [taler-taler-ios] 18/32: cleanup, gnunet, 2024/07/13
- [taler-taler-ios] 28/32: Icons in transactions, gnunet, 2024/07/13
- [taler-taler-ios] 30/32: IconBadge improvements, gnunet, 2024/07/13
- [taler-taler-ios] 31/32: Fix layout of tx list, gnunet, 2024/07/13
- [taler-taler-ios] 20/32: qrCodesForPayto WIP, gnunet, 2024/07/13
- [taler-taler-ios] 26/32: TwoRowButtons with icons, gnunet, 2024/07/13
- [taler-taler-ios] 25/32: Error+debugDescription, gnunet, 2024/07/13
- [taler-taler-ios] 27/32: Authorize instead of confirm, gnunet, 2024/07/13
- [taler-taler-ios] 09/32: remove QR from Overview,
gnunet <=
- [taler-taler-ios] 17/32: showUpDown if 25 entries, gnunet, 2024/07/13
- [taler-taler-ios] 13/32: comment out payto scheme, gnunet, 2024/07/13
- [taler-taler-ios] 10/32: QR button smaller, gnunet, 2024/07/13
- [taler-taler-ios] 12/32: disable hintNetworkAvailability, logging, gnunet, 2024/07/13
- [taler-taler-ios] 24/32: cleanup, gnunet, 2024/07/13
- [taler-taler-ios] 32/32: Spend button with icon, gnunet, 2024/07/13
- [taler-taler-ios] 16/32: hints for P2P expiration, gnunet, 2024/07/13
- [taler-taler-ios] 23/32: IconBadge, gnunet, 2024/07/13
- [taler-taler-ios] 11/32: L10N, gnunet, 2024/07/13
- [taler-taler-ios] 14/32: VIEW_OVERVIEW, gnunet, 2024/07/13