commit fff9652253a21eef6c13c6538bb1002c5f4062cc
parent beafcd8cd4af989004a19aaa7f6fe5845e1fcfe6
Author: Marc Stibane <marc@taler.net>
Date: Fri, 5 Jun 2026 23:21:59 +0200
Prefered Color Mode
Diffstat:
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift b/TalerWallet1/Controllers/TalerWallet1App.swift
@@ -21,6 +21,8 @@ struct TalerWallet1App: App {
private let symLog = SymLogV()
@Environment(\.scenePhase) private var phase
@AppStorage("pasteAutomatically") var pasteAutomatically: Bool = false
+ @AppStorage("preferredColorScheme") var preferredColorScheme: Int = 0
+
@StateObject private var viewState = ViewState.shared // popToRootView()
@StateObject private var viewState2 = ViewState2.shared // popToRootView()
@State private var pastedString: String? = nil
@@ -97,7 +99,11 @@ struct TalerWallet1App: App {
}
var body: some Scene {
+ let colorScheme = preferredColorScheme < 0 ? ColorScheme.dark
+ : preferredColorScheme > 0 ? ColorScheme.light
+ : nil // use the current scheme
let mainView = MainView(logger: logger, stack: CallStack("App"))
+ .preferredColorScheme(colorScheme)
.environmentObject(debugViewC) // change viewID / sheetID
.environmentObject(viewState) // popToRoot
.environmentObject(viewState2) // popToRoot
diff --git a/TalerWallet1/Views/Settings/MoreSettingsView.swift b/TalerWallet1/Views/Settings/MoreSettingsView.swift
@@ -30,6 +30,7 @@ struct MoreSettingsView: View {
@AppStorage("minimalistic") var minimalistic: Bool = false
@AppStorage("showQRauto16") var showQRauto16: Bool = true
@AppStorage("showQRauto17") var showQRauto17: Bool = false
+ @AppStorage("preferredColorScheme") var preferredColorScheme: Int = 0
@AppStorage("oimEuro") var oimEuro: Bool = false
@AppStorage("oimChart") var oimChart: Bool = false
@@ -60,6 +61,9 @@ struct MoreSettingsView: View {
description: showQRhint)
}
+ SettingsTriState(name: String(localized: "Prefered Color Mode"), value: $preferredColorScheme,
+ id1: "colorScheme",
+ description: String(localized: "Individual preference"))
if controller.hapticCapability.supportsHaptics {
SettingsToggle(name: String(localized: "Haptics"), value: $useHaptics,
id1: "haptics",
diff --git a/TalerWallet1/Views/Settings/SettingsItem.swift b/TalerWallet1/Views/Settings/SettingsItem.swift
@@ -221,13 +221,20 @@ struct SettingsTriState: View {
var description: String?
var action: (_ value: Int) -> Void = {value in }
- func imageName(_ value: Int) -> (String, String) {
+ func imageName1(_ value: Int) -> (String, String) {
return (value == 0) ? ("eye.slash", "Off")
: (value == 1) ? ("eye", "Type only")
: ("eye.fill", "Type and JSON")
}
+ func imageName2(_ value: Int) -> (String, String) {
+ return (value == 0) ? ("iphone", "System") // or apple.logo
+ : (value == 1) ? (LIGHT_OFF, "light") //
+ : (LIGHT_ON, "dark") //
+ }
+
var body: some View {
- let image = imageName(value)
+ let observe = "observe" == id1
+ let image = observe ? imageName1(value) : imageName2(value)
VStack {
HStack {
@@ -240,11 +247,15 @@ struct SettingsTriState: View {
if value > 0 {
value = -1
action(value)
- Controller.shared.playSound(1)
+ if observe {
+ Controller.shared.playSound(1)
+ }
} else {
value = value + 1
action(value)
- Controller.shared.playSound(value)
+ if observe {
+ Controller.shared.playSound(value)
+ }
}
} label: {
Image(systemName: image.0)