commit c4c0bcc8902bb56f58c1fb1e9ebfa3be35017c95 parent 2d7ffab1dde7f5c0255a0db2e7d4544e4cfd2b55 Author: Marc Stibane <marc@taler.net> Date: Thu, 15 Feb 2024 13:49:25 +0100 Contrast of secondary color Diffstat:
12 files changed, 38 insertions(+), 24 deletions(-)
diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 {