gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 02/03: Contrast of secondary color


From: gnunet
Subject: [taler-taler-ios] 02/03: Contrast of secondary color
Date: Thu, 15 Feb 2024 13:51:05 +0100

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 c4c0bcc8902bb56f58c1fb1e9ebfa3be35017c95
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Feb 15 13:49:25 2024 +0100

    Contrast of secondary color
---
 TalerWallet1/Helper/WalletColors.swift                       | 8 ++++++++
 TalerWallet1/Views/Balances/BalanceRowView.swift             | 5 +----
 TalerWallet1/Views/Balances/BalancesSectionView.swift        | 5 +----
 TalerWallet1/Views/Banking/DepositAmountV.swift              | 5 ++++-
 TalerWallet1/Views/Banking/DepositIbanV.swift                | 5 ++++-
 TalerWallet1/Views/HelperViews/BarGraph.swift                | 5 +----
 TalerWallet1/Views/Peer2peer/P2PSubjectV.swift               | 4 +++-
 TalerWallet1/Views/Peer2peer/SendAmount.swift                | 5 ++++-
 TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift     | 4 +++-
 TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift | 4 +++-
 TalerWallet1/Views/Transactions/ThreeAmountsV.swift          | 5 +----
 TalerWallet1/Views/Transactions/TransactionSummaryV.swift    | 7 +++++--
 12 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/TalerWallet1/Helper/WalletColors.swift 
b/TalerWallet1/Helper/WalletColors.swift
index 11e192e..bb6b9ac 100644
--- a/TalerWallet1/Helper/WalletColors.swift
+++ b/TalerWallet1/Helper/WalletColors.swift
@@ -7,6 +7,7 @@ import SwiftUI
 fileprivate let grouped = true
 
 public struct WalletColors {
+    @AppStorage("minimalistic") var minimalistic: Bool = false
 
     let tint = Color(.tintColor)
     let gray1 = Color(.systemGray)          // uncompleted
@@ -36,6 +37,13 @@ public struct WalletColors {
            : pressed ? gray4 : gray5
     }
 
+    func secondary(_ scheme: ColorScheme, _ contrast: ColorSchemeContrast) -> 
Color {
+        return contrast == .increased ? .primary            // WCAG AAA for 
any scheme
+                       : minimalistic ? .secondary          // not enough 
contrast
+                    : scheme == .dark ? .secondary          // WCAG AA for 
dark scheme
+                                      : Color(.darkGray)    // WCAG AA for 
light scheme
+    }
+
     var backgroundColor: Color {
         grouped ? Color(.systemGroupedBackground)
                 : Color(.systemBackground)
diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift 
b/TalerWallet1/Views/Balances/BalanceRowView.swift
index 1af8d10..ac15ea2 100644
--- a/TalerWallet1/Views/Balances/BalanceRowView.swift
+++ b/TalerWallet1/Views/Balances/BalanceRowView.swift
@@ -28,10 +28,7 @@ struct BalanceCell: View {
             } else {
                 let balanceText = Text("Balance:", comment: "Main view")
                     .talerFont(.title2)
-                    .foregroundColor(colorSchemeContrast == .increased ? 
.primary
-                                                        : minimalistic ? 
.secondary
-                                                : colorScheme == .dark ? 
.secondary
-                                                                       : 
Color(.darkGray))
+                    .foregroundColor(WalletColors().secondary(colorScheme, 
colorSchemeContrast))
                 let vLayout = VStack(alignment: .leading, spacing: 0) {
                     balanceText
                     hLayout
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift 
b/TalerWallet1/Views/Balances/BalancesSectionView.swift
index 94c4b47..7a87a57 100644
--- a/TalerWallet1/Views/Balances/BalancesSectionView.swift
+++ b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -142,10 +142,7 @@ extension BalancesSectionView: View {
                     Text(count > 1 ? "Recent \(count) transactions"
                                    : "Recent transaction")
                         .talerFont(.title3)
-                        .foregroundColor(colorSchemeContrast == .increased ? 
.primary
-                                                            : minimalistic ? 
.secondary
-                                                    : colorScheme == .dark ? 
.secondary
-                                                                           : 
Color(.darkGray))
+                        .foregroundColor(WalletColors().secondary(colorScheme, 
colorSchemeContrast))
                 }
             }
         } // recent transactions
diff --git a/TalerWallet1/Views/Banking/DepositAmountV.swift 
b/TalerWallet1/Views/Banking/DepositAmountV.swift
index 36488d1..0635481 100644
--- a/TalerWallet1/Views/Banking/DepositAmountV.swift
+++ b/TalerWallet1/Views/Banking/DepositAmountV.swift
@@ -21,6 +21,8 @@ struct DepositAmountV: View {
 
     @EnvironmentObject private var controller: Controller
     @EnvironmentObject private var model: WalletModel
+    @Environment(\.colorScheme) private var colorScheme
+    @Environment(\.colorSchemeContrast) private var colorSchemeContrast
     @AppStorage("minimalistic") var minimalistic: Bool = false
 
     @State var prepareDepositResult: PrepareDepositResult? = nil
@@ -112,7 +114,8 @@ struct DepositAmountV: View {
                                   : feeLabel)
                     .talerFont(.body)
                     .foregroundColor(insufficient ? .red
-                                                  : (feeAmount?.isZero ?? 
true) ? .secondary : .red)
+                                                  : (feeAmount?.isZero ?? 
true) ? WalletColors().secondary(colorScheme, colorSchemeContrast)
+                                                                               
 : .red)
                     .padding(4)
                 Button(buttonTitle(amountToTransfer, currencyInfo)) {
                     if let paytoUri {
diff --git a/TalerWallet1/Views/Banking/DepositIbanV.swift 
b/TalerWallet1/Views/Banking/DepositIbanV.swift
index c2c8b23..ef1e169 100644
--- a/TalerWallet1/Views/Banking/DepositIbanV.swift
+++ b/TalerWallet1/Views/Banking/DepositIbanV.swift
@@ -19,6 +19,8 @@ struct DepositIbanV: View {
 
     @EnvironmentObject private var controller: Controller
     @EnvironmentObject private var model: WalletModel
+    @Environment(\.colorScheme) private var colorScheme
+    @Environment(\.colorSchemeContrast) private var colorSchemeContrast
     @AppStorage("minimalistic") var minimalistic: Bool = false
     @AppStorage("depositIBAN") var depositIBAN: String = EMPTYSTRING
     @AppStorage("accountHolder") var accountHolder: String = EMPTYSTRING
@@ -63,7 +65,8 @@ struct DepositIbanV: View {
                 if label.count > 0 {
                     Text(label)
                         .frame(maxWidth: .infinity, alignment: .trailing)
-                        .foregroundColor(feeIsNotZero ? .red : .secondary)
+                        .foregroundColor(feeIsNotZero ? .red 
+                                                      : 
WalletColors().secondary(colorScheme, colorSchemeContrast))
                         .talerFont(.body)
                 }
             }
diff --git a/TalerWallet1/Views/HelperViews/BarGraph.swift 
b/TalerWallet1/Views/HelperViews/BarGraph.swift
index 60573eb..3f64829 100644
--- a/TalerWallet1/Views/HelperViews/BarGraph.swift
+++ b/TalerWallet1/Views/HelperViews/BarGraph.swift
@@ -26,10 +26,7 @@ struct BarGraphHeader: View {
         HStack (alignment: .center, spacing: 10) {
             Text(currencyName)
                 .talerFont(.title2)
-                .foregroundColor(colorSchemeContrast == .increased ? .primary
-                                                    : minimalistic ? .secondary
-                                            : colorScheme == .dark ? .secondary
-                                                                   : 
Color(.darkGray))
+                .foregroundColor(WalletColors().secondary(colorScheme, 
colorSchemeContrast))
             if let scopeInfo {
                 BarGraph(transactions: $completedTransactions,
                          maxBars: MAXBARS, barHeight: barHeight)
diff --git a/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift 
b/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift
index 9dc7993..05892b0 100644
--- a/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift
+++ b/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift
@@ -27,6 +27,8 @@ struct P2PSubjectV: View {
     @Binding var expireDays: UInt
 
     @EnvironmentObject private var model: WalletModel
+    @Environment(\.colorScheme) private var colorScheme
+    @Environment(\.colorSchemeContrast) private var colorSchemeContrast
     @AppStorage("minimalistic") var minimalistic: Bool = false
 
     @State private var myFeeLabel: String = EMPTYSTRING
@@ -62,7 +64,7 @@ struct P2PSubjectV: View {
                 if label.count > 0 {
                     Text(label)
                         .frame(maxWidth: .infinity, alignment: .trailing)
-                        .foregroundColor(feeIsNotZero ? .red : .secondary)
+                        .foregroundColor(feeIsNotZero ? .red : 
WalletColors().secondary(colorScheme, colorSchemeContrast))
                         .talerFont(.body)
                 }
             }
diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift 
b/TalerWallet1/Views/Peer2peer/SendAmount.swift
index aca2b6d..7b534b3 100644
--- a/TalerWallet1/Views/Peer2peer/SendAmount.swift
+++ b/TalerWallet1/Views/Peer2peer/SendAmount.swift
@@ -18,6 +18,8 @@ struct SendAmount: View {
 
     @EnvironmentObject private var controller: Controller
     @EnvironmentObject private var model: WalletModel
+    @Environment(\.colorScheme) private var colorScheme
+    @Environment(\.colorSchemeContrast) private var colorSchemeContrast
     @AppStorage("minimalistic") var minimalistic: Bool = false
 
     @State var peerPushCheck: CheckPeerPushDebitResponse? = nil
@@ -109,7 +111,8 @@ struct SendAmount: View {
                               : feeLabel)
                 .talerFont(.body)
                 .foregroundColor(insufficient ? .red
-                                 : (feeAmount?.isZero ?? true) ? .secondary : 
.red)
+                : (feeAmount?.isZero ?? true) ? 
WalletColors().secondary(colorScheme, colorSchemeContrast)
+                                              : .red)
                 .padding(4)
             NavigationLink(destination: inputDestination) { Text("Next") }
                 .buttonStyle(TalerButtonStyle(type: .prominent))
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift 
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift
index a639acf..9dbbd04 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift
@@ -17,6 +17,8 @@ struct P2pPayURIView: View {
     let url: URL
 
     @EnvironmentObject private var model: WalletModel
+    @Environment(\.colorScheme) private var colorScheme
+    @Environment(\.colorSchemeContrast) private var colorSchemeContrast
     @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
 
     @State private var peerPullDebitResponse: PreparePeerPullDebitResponse?
@@ -48,7 +50,7 @@ struct P2pPayURIView: View {
                     Text("Expires: \(dateString)")
                         .talerFont(.body)
                         .accessibilityLabel(accessibilityLabel)
-//                        .foregroundColor(colorSchemeContrast == .increased ? 
.primary : .secondary)
+                        .foregroundColor(WalletColors().secondary(colorScheme, 
colorSchemeContrast))
                 }
                 .listStyle(myListStyle.style).anyView
                 .navigationTitle(navTitle)
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift 
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
index dbf58a1..ee7bb6c 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
@@ -17,6 +17,8 @@ struct P2pReceiveURIView: View {
     let url: URL
     
     @EnvironmentObject private var model: WalletModel
+    @Environment(\.colorScheme) private var colorScheme
+    @Environment(\.colorSchemeContrast) private var colorSchemeContrast
     @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
 
     @State private var peerPushCreditResponse: PreparePeerPushCreditResponse? 
= nil
@@ -56,7 +58,7 @@ struct P2pReceiveURIView: View {
                     Text("Expires: \(dateString)")
                         .talerFont(.body)
                         .accessibilityLabel(accessibilityLabel)
-//                        .foregroundColor(colorSchemeContrast == .increased ? 
.primary : .secondary)
+                        .foregroundColor(WalletColors().secondary(colorScheme, 
colorSchemeContrast))
                 }
                 .listStyle(myListStyle.style).anyView
                 .navigationTitle(navTitle)
diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift 
b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
index 4188a44..c7fbbf1 100644
--- a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
+++ b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
@@ -129,10 +129,7 @@ struct ThreeAmountsV: View {
             if !minimalistic {
                 Text("Summary")
                     .talerFont(.title3)
-                    .foregroundColor(colorSchemeContrast == .increased ? 
.primary
-                                                        : minimalistic ? 
.secondary
-                                                : colorScheme == .dark ? 
.secondary
-                                                                       : 
Color(.darkGray))
+                    .foregroundColor(WalletColors().secondary(colorScheme, 
colorSchemeContrast))
             }
         }
     }
diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift 
b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
index be71909..050bf40 100644
--- a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
+++ b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
@@ -34,6 +34,7 @@ struct TransactionSummaryV: View {
     let suspendAction: ((_ transactionId: String) async throws -> Void)?
     let resumeAction: ((_ transactionId: String) async throws -> Void)?
 
+    @Environment(\.colorScheme) private var colorScheme
     @Environment(\.colorSchemeContrast) private var colorSchemeContrast
     @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
 #if DEBUG
@@ -116,7 +117,7 @@ struct TransactionSummaryV: View {
                 Text(dateString)
                     .talerFont(.body)
                     .accessibilityLabel(accessibilityDate)
-                    .foregroundColor(colorSchemeContrast == .increased ? 
.primary : .secondary)
+                    .foregroundColor(WalletColors().secondary(colorScheme, 
colorSchemeContrast))
                     .listRowSeparator(.hidden)
                 VStack(alignment: .trailing) {
                     let majorState = common.txState.major.localizedState
@@ -243,6 +244,8 @@ struct TransactionSummaryV: View {
         let stack: CallStack
         @Binding var transaction: Transaction
         let hasDone: Bool
+        @Environment(\.colorScheme) private var colorScheme
+        @Environment(\.colorSchemeContrast) private var colorSchemeContrast
         @State private var rotationEnabled = true
 
         var body: some View {
@@ -335,7 +338,7 @@ struct TransactionSummaryV: View {
                             Text("Expires: \(dateString)")
                                 .talerFont(.body)
                                 .accessibilityLabel(accessibilityLabel)
-                            //                        
.foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary)
+                                
.foregroundColor(WalletColors().secondary(colorScheme, colorSchemeContrast))
                         }
                         // TODO: isSendCoins should show QR only while not yet 
expired  - either set timer or wallet-core should do so and send a 
state-changed notification
                         if pending {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]