commit a4a42120f2145fad3314a55714a68d622eaca479
parent e4ccd38fe236d6daffaf21ebed2b79c1e8c283e7
Author: Marc Stibane <marc@taler.net>
Date: Fri, 6 Mar 2026 01:05:18 +0100
fix button colors & logo in dark mode
Diffstat:
6 files changed, 106 insertions(+), 5 deletions(-)
diff --git a/TalerWallet1/Helper/WalletColors.swift b/TalerWallet1/Helper/WalletColors.swift
@@ -33,9 +33,12 @@ public struct WalletColors {
func buttonForeColor(pressed: Bool,
disabled: Bool,
+ scheme: ColorScheme,
+ contrast: ColorSchemeContrast,
prominent: Bool = false) -> Color {
disabled ? gray2
: !prominent ? talerColor
+ : scheme == .dark ? primary(contrast)
: pressed ? gray6 : Color.white
}
@@ -47,7 +50,12 @@ public struct WalletColors {
: pressed ? gray4 : gray5
}
- func secondary(_ scheme: ColorScheme, _ contrast: ColorSchemeContrast) -> Color {
+ func primary(_ contrast: ColorSchemeContrast = .standard) -> Color {
+ return contrast == .increased ? .primary
+ : Color("Primary")
+ }
+
+ func secondary(_ scheme: ColorScheme, _ contrast: ColorSchemeContrast = .standard) -> Color {
return contrast == .increased ? .primary // WCAG AAA for any scheme
: minimalistic ? .secondary // not enough contrast
: scheme == .dark ? .secondary // WCAG AA for dark scheme
diff --git a/TalerWallet1/Resources/Assets.xcassets/Primary.colorset/Contents.json b/TalerWallet1/Resources/Assets.xcassets/Primary.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "colors" : [
+ {
+ "color" : {
+ "color-space" : "display-p3",
+ "components" : {
+ "alpha" : "1.000",
+ "blue" : "0",
+ "green" : "0",
+ "red" : "0"
+ }
+ },
+ "idiom" : "universal"
+ },
+ {
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "display-p3",
+ "components" : {
+ "alpha" : "1.000",
+ "blue" : "120",
+ "green" : "42",
+ "red" : "00"
+ }
+ },
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/TalerWallet1/Resources/Assets.xcassets/taler-logo-full.imageset/Contents.json b/TalerWallet1/Resources/Assets.xcassets/taler-logo-full.imageset/Contents.json
@@ -3,6 +3,16 @@
{
"filename" : "taler-logo-full.svg",
"idiom" : "universal"
+ },
+ {
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "filename" : "taler-logo-full-dark.svg",
+ "idiom" : "universal"
}
],
"info" : {
diff --git a/TalerWallet1/Resources/Assets.xcassets/taler-logo-full.imageset/taler-logo-full-dark.svg b/TalerWallet1/Resources/Assets.xcassets/taler-logo-full.imageset/taler-logo-full-dark.svg
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ width="196.2"
+ height="87.3"
+ viewBox="-25 -30 250 150"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <g
+ fill="#fff"
+ fill-rule="evenodd"
+ stroke-width="0.3"
+ id="g3"
+ transform="translate(-1,-1.1)">
+ <path
+ d="m 86.7,1.1 c 15.6,0 29,9.4 36,23.2 h -5.9 A 35.1,35.1 0 0 0 86.7,6.5 C 67,6.5 51,23.6 51,44.7 c 0,10.4 3.8,19.7 10,26.6 a 31.4,31.4 0 0 1 -4.2,3 A 45.2,45.2 0 0 1 46,44.7 C 46,20.7 64.2,1.1 86.7,1.1 Z m 35.8,64.3 a 40.4,40.4 0 0 1 -39,22.8 c 3,-1.5 6,-3.5 8.6,-5.7 a 35.6,35.6 0 0 0 24.6,-17.1 z"
+ id="path1" />
+ <path
+ d="m 64.2,1.1 3.1,0.1 C 64.3,2.8 61.4,4.7 58.8,7 A 37.5,37.5 0 0 0 28.6,44.7 c 0,14.3 7.3,26.7 18,33.3 a 29.6,29.6 0 0 1 -8.5,0.2 c -9,-8 -14.6,-20 -14.6,-33.5 0,-24 18.2,-43.6 40.7,-43.6 z m 5.4,81.4 A 35.6,35.6 0 0 0 94.2,65.4 h 5.9 a 40.4,40.4 0 0 1 -39,22.8 c 3,-1.5 5.9,-3.5 8.5,-5.7 z M 94.4,24.3 A 37,37 0 0 0 81.8,11.5 29.6,29.6 0 0 1 90.3,11.3 c 4,3.6 7.4,8 9.9,13 z"
+ id="path2" />
+ <path
+ d="m 41.8,1.1 c 1,0 2,0 3.1,0.2 -3,1.5 -5.9,3.4 -8.5,5.6 A 37.5,37.5 0 0 0 6.1,44.7 c 0,21.1 16,38.3 35.7,38.3 12.6,0 23.6,-7 30,-17.6 h 5.8 a 40.4,40.4 0 0 1 -35.8,23 C 19.3,88.4 1,68.8 1,44.7 1,20.7 19.2,1.1 41.7,1.1 Z m 30.1,23.2 a 38.1,38.1 0 0 0 -4.5,-6.1 c 1.3,-1.2 2.7,-2.2 4.3,-3 2.3,2.7 4.4,5.8 6,9.1 z"
+ id="path3" />
+ </g>
+ <g
+ fill="#fff"
+ fill-rule="evenodd">
+ <path
+ d="m 75.1,33.3 h 9.2 v -5 H 60.9 v 5 H 70 v 26 h 5.1 z m 16.5,18.5 h 13.7 l 3,7.4 h 5.3 L 100.9,28 H 96.2 L 83.5,59.2 h 5.2 z m 11.8,-4.9 h -9.9 l 5,-12.4 z m 19.4,-18.6 h -4.6 v 31 h 20.6 v -5 h -16 z m 42.7,0 H 144 v 31 h 21.6 v -5 H 149 V 46 h 14.5 V 41.1 H 149 v -8 h 16.4 z m 24.7,10.1 c 0,1.6 -0.5,2.8 -1.6,3.8 -1.1,1 -2.6,1.4 -4.4,1.4 h -7.4 V 33.2 h 7.4 c 1.9,0 3.4,0.4 4.4,1.3 1,0.9 1.6,2.2 1.6,3.9 z m 6,20.8 -7.7,-11.7 c 1,-0.3 1.9,-0.7 2.7,-1.3 a 8.8,8.8 0 0 0 3.6,-4.6 c 0.4,-1 0.5,-2.2 0.5,-3.5 0,-1.5 -0.2,-2.9 -0.7,-4.1 a 8.4,8.4 0 0 0 -2.1,-3.1 c -1,-0.8 -2,-1.5 -3.4,-2 -1.3,-0.4 -2.8,-0.6 -4.5,-0.6 h -12.9 v 31 h 5 v -11 h 6.5 l 7,10.8 z"
+ id="path4" />
+ </g>
+</svg>
diff --git a/TalerWallet1/Resources/Assets.xcassets/taler-logo-full.imageset/taler-logo-white.svg b/TalerWallet1/Resources/Assets.xcassets/taler-logo-full.imageset/taler-logo-on-white.svg
diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift
@@ -317,24 +317,36 @@ struct TalerButtonStyle: ButtonStyle {
var aligned: TextAlignment = .center
var badge: String = EMPTYSTRING
- public func makeBody(configuration: ButtonStyle.Configuration) -> some View {
+ @Environment(\.colorScheme) private var colorScheme
+ @Environment(\.colorSchemeContrast) private var colorSchemeContrast
+
+ public func makeBody(configuration: ButtonStyleConfiguration) -> some View {
// configuration.role = type == .prominent ? .primary : .normal Only on macOS
- MyBigButton(foreColor: foreColor(type: type, pressed: configuration.isPressed, disabled: disabled),
+ MyBigButton(foreColor: foreColor(type: type, pressed: configuration.isPressed,
+ scheme: colorScheme, contrast: colorSchemeContrast, disabled: disabled),
backColor: backColor(type: type, pressed: configuration.isPressed, disabled: disabled),
dimmed: dimmed,
configuration: configuration,
disabled: disabled,
narrow: narrow,
aligned: aligned,
- badge: badge)
+ badge: badge,
+ scheme: colorScheme,
+ contrast: colorSchemeContrast)
}
- func foreColor(type: TalerButtonStyleType, pressed: Bool, disabled: Bool) -> Color {
+ func foreColor(type: TalerButtonStyleType,
+ pressed: Bool,
+ scheme: ColorScheme,
+ contrast: ColorSchemeContrast,
+ disabled: Bool) -> Color {
if type == .plain {
return WalletColors().fieldForeground // primary text color
}
return WalletColors().buttonForeColor(pressed: pressed,
disabled: disabled,
+ scheme: scheme,
+ contrast: contrast,
prominent: type == .prominent)
}
func backColor(type: TalerButtonStyleType, pressed: Bool, disabled: Bool) -> Color {
@@ -369,6 +381,8 @@ struct TalerButtonStyle: ButtonStyle {
let narrow: Bool
let aligned: TextAlignment
var badge: String
+ var scheme: ColorScheme
+ var contrast: ColorSchemeContrast
var body: some View {
let aligned2: Alignment = (aligned == .center) ? Alignment.center