commit db4f358cfa0bb3d12707392d63d3accb48b509b4
parent f088dfa969c8d868efccb451d36fc9e4b9de2165
Author: Marc Stibane <marc@taler.net>
Date: Sun, 16 Mar 2025 19:30:57 +0100
Controller.setOIMmode
Diffstat:
4 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift
@@ -53,9 +53,12 @@ class Controller: ObservableObject {
@Published var backendState: BackendState = .none // only used for launch animation
@Published var currencyTicker: Int = 0 // updates whenever a new currency is added
+
@Published var isConnected: Bool = true
+ @Published var oimModeEnabled: Bool = false
@Published var oimModeActive: Bool = false
- @Published var diagnosticModeActive: Bool = false
+ @Published var oimSheetActive: Bool = false
+ @Published var diagnosticModeEnabled: Bool = false
@AppStorage("useHaptics") var useHaptics: Bool = true // extension mustn't define this, so it must be here
@AppStorage("playSoundsI") var playSoundsI: Int = 1 // extension mustn't define this, so it must be here
@AppStorage("playSoundsB") var playSoundsB: Bool = false
@@ -73,13 +76,21 @@ class Controller: ObservableObject {
private var oimModeObservation: NSKeyValueObservation?
private var diagnosticModeObservation: NSKeyValueObservation?
+ func setOIMmode(for newOrientation: UIDeviceOrientation, _ sheetActive: Bool) {
+ let isLandscapeRight = newOrientation == .landscapeRight
+ oimSheetActive = sheetActive && oimModeEnabled && isLandscapeRight
+ oimModeActive = sheetActive ? false
+ : oimModeEnabled ? isLandscapeRight
+ : false
+ }
+
func startObserving() {
let defaults = UserDefaults.standard
self.oimModeObservation = defaults.observe(\.oimModeEnabled, options: [.new, .old, .prior, .initial]) { [weak self](_, _) in
- self?.oimModeActive = UserDefaults.standard.oimModeEnabled
+ self?.oimModeEnabled = UserDefaults.standard.oimModeEnabled
}
self.diagnosticModeObservation = defaults.observe(\.diagnosticModeEnabled, options: [.new, .old,.prior,.initial]) { [weak self](_, _) in
- self?.diagnosticModeActive = UserDefaults.standard.diagnosticModeEnabled
+ self?.diagnosticModeEnabled = UserDefaults.standard.diagnosticModeEnabled
}
}
diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -14,9 +14,7 @@ import AVFoundation
struct BalancesListView: View {
private let symLog = SymLogV(0)
let stack: CallStack
- @Binding var orientation: UIDeviceOrientation
@Binding var selectedBalance: Balance?
-// @Binding var shouldReloadPending: Int
@Binding var reloadTransactions: Int
@EnvironmentObject private var model: WalletModel
diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift
@@ -30,7 +30,6 @@ struct MainView: View {
@AppStorage("playSoundsI") var playSoundsI: Int = 1 // extension mustn't define this, so it must be here
@AppStorage("playSoundsB") var playSoundsB: Bool = false
- @State private var orientation = UIDevice.current.orientation
@State private var selectedBalance: Balance? = nil
@State private var urlToOpen: URL? = nil
@State private var showUrlSheet = false
@@ -61,7 +60,6 @@ struct MainView: View {
#endif
let mainContent = ZStack {
MainContent(logger: logger, stack: stack.push("Content"),
- orientation: $orientation,
selectedBalance: $selectedBalance,
talerFontIndex: $talerFontIndex,
showActionSheet: $showActionSheet,
@@ -153,7 +151,8 @@ struct MainView: View {
}
}
.onRotate { newOrientation in
- orientation = newOrientation
+ let isSheetActive = showActionSheet || showScanner || showUrlSheet
+ controller.setOIMmode(for: newOrientation, isSheetActive)
}
.onOpenURL { url in
symLog.log(".onOpenURL: \(url)")
@@ -227,7 +226,6 @@ extension MainView {
struct MainContent: View {
let logger: Logger
let stack: CallStack
- @Binding var orientation: UIDeviceOrientation
@Binding var selectedBalance: Balance?
@Binding var talerFontIndex: Int
@Binding var showActionSheet: Bool
@@ -353,7 +351,6 @@ extension MainView {
/// NavigationViews for Balances & Settings
let balancesStack = NavigationView {
BalancesListView(stack: stack.push(balancesTitle),
- orientation: $orientation,
selectedBalance: $selectedBalance,
// shouldReloadPending: $shouldReloadPending,
reloadTransactions: $shouldReloadTransactions)
diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift
@@ -147,7 +147,7 @@ struct SettingsView: View {
consoleManager.isVisible = localConsoleO != 0 || localConsoleL
consoleManager.clear()
}
- if controller.oimModeActive {
+ if controller.oimModeEnabled {
SettingsToggle(name: String(localized: "Two rows"), value: $oimTwoRows, id1: "oimTwoRows",
description: minimalistic ? nil : String(localized: "OIM denomination layout"))
SettingsToggle(name: String(localized: "Sierra Leone"), value: $sierraLeone, id1: "sierraLeone",