commit 4a37d8b3cd314cefe41dbddc5e54faffadece223
parent 4555450195b7dead8e91c5153a4d8d944eb1f5df
Author: Marc Stibane <marc@taler.net>
Date: Sun, 16 Feb 2025 16:11:59 +0100
start passing orientation
Diffstat:
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -14,6 +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
diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift
@@ -30,6 +30,7 @@ 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
@@ -60,6 +61,7 @@ struct MainView: View {
#endif
let mainContent = ZStack {
MainContent(logger: logger, stack: stack.push("Content"),
+ orientation: $orientation,
selectedBalance: $selectedBalance,
talerFontIndex: $talerFontIndex,
showActionSheet: $showActionSheet,
@@ -147,6 +149,9 @@ struct MainView: View {
} // iOS 15
}
}
+ .onRotate { newOrientation in
+ orientation = newOrientation
+ }
.onOpenURL { url in
symLog.log(".onOpenURL: \(url)")
// will be called on a taler:// scheme either
@@ -219,6 +224,7 @@ 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
@@ -358,6 +364,7 @@ extension MainView {
/// NavigationViews for Balances & Settings
let balancesStack = NavigationView {
BalancesListView(stack: stack.push(balancesTitle),
+ orientation: $orientation,
selectedBalance: $selectedBalance,
// shouldReloadPending: $shouldReloadPending,
reloadTransactions: $shouldReloadTransactions)
@@ -447,6 +454,8 @@ extension MainView {
// symLog.log(".task shouldReloadBalances \(shouldReloadBalances)")
await controller.loadBalances(stack.push("refreshing balances"), model)
} // task
+ .task(id: orientation) {
+ }
} // body
} // Content
}