summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Stibane <marc@taler.net>2023-10-13 09:25:00 +0200
committerMarc Stibane <marc@taler.net>2023-10-13 09:49:38 +0200
commit2ba3266dcb73a9b34d1b2030d7b3d5052148c1c4 (patch)
treef265f0dfcc1a6e53434e43d50807be212439e845
parent6fd6cd4808b998051afd255375d82b11333f459e (diff)
downloadtaler-ios-2ba3266dcb73a9b34d1b2030d7b3d5052148c1c4.tar.gz
taler-ios-2ba3266dcb73a9b34d1b2030d7b3d5052148c1c4.tar.bz2
taler-ios-2ba3266dcb73a9b34d1b2030d7b3d5052148c1c4.zip
TabBar for Taler Wallet - GNU Taler stays on SideView
-rw-r--r--TalerWallet.xcodeproj/project.pbxproj3
-rw-r--r--TalerWallet1/Views/Balances/BalancesListView.swift10
-rw-r--r--TalerWallet1/Views/Exchange/ExchangeListView.swift11
-rw-r--r--TalerWallet1/Views/Main/MainView.swift77
-rw-r--r--TalerWallet1/Views/Settings/SettingsView.swift21
5 files changed, 111 insertions, 11 deletions
diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj
index 1a3aade..9261418 100644
--- a/TalerWallet.xcodeproj/project.pbxproj
+++ b/TalerWallet.xcodeproj/project.pbxproj
@@ -1441,6 +1441,7 @@
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = "-lc++";
SDKROOT = iphoneos;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = complete;
@@ -1482,6 +1483,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG TABBAR";
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = 1;
VALIDATE_WORKSPACE = YES;
@@ -1522,6 +1524,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = TABBAR;
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = 1;
VALIDATE_WORKSPACE = YES;
diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift
index d75f30d..1f6fe3a 100644
--- a/TalerWallet1/Views/Balances/BalancesListView.swift
+++ b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -12,7 +12,10 @@ struct BalancesListView: View {
private let symLog = SymLogV()
let stack: CallStack
let navTitle: String
+#if TABBAR // Taler Wallet
+#else // GNU Taler
let hamburgerAction: () -> Void
+#endif
@EnvironmentObject private var model: WalletModel
@State private var balances: [Balance] = []
@@ -84,11 +87,16 @@ struct BalancesListView: View {
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear
#endif
+#if TABBAR // Taler Wallet
+ let hamburger: HamburgerButton? = nil
+#else // GNU Taler
+ let hamburger: HamburgerButton = HamburgerButton(action: hamburgerAction)
+#endif
Content(symLog: symLog, stack: stack.push(), balances: $balances,
centsToTransfer: $centsToTransfer, summary: $summary,
reloadAction: reloadAction)
.navigationTitle(navTitle)
- .navigationBarItems(leading: HamburgerButton(action: hamburgerAction),
+ .navigationBarItems(leading: hamburger,
trailing: QRButton(action: checkCameraAvailable))
.overlay {
if balances.isEmpty {
diff --git a/TalerWallet1/Views/Exchange/ExchangeListView.swift b/TalerWallet1/Views/Exchange/ExchangeListView.swift
index 36bd726..9968448 100644
--- a/TalerWallet1/Views/Exchange/ExchangeListView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeListView.swift
@@ -11,7 +11,10 @@ struct ExchangeListView: View {
private let symLog = SymLogV(0)
let stack: CallStack
let navTitle: String
+#if TABBAR // Taler Wallet
+#else // GNU Taler
var hamburgerAction: () -> Void
+#endif
@EnvironmentObject private var model: WalletModel
@@ -48,7 +51,11 @@ struct ExchangeListView: View {
// withAnimation { showAlert = true }
showAlert = true
}
-
+#if TABBAR // Taler Wallet
+ let hamburger: HamburgerButton? = nil
+#else // GNU Taler
+ let hamburger: HamburgerButton = HamburgerButton(action: hamburgerAction)
+#endif
//Text("Exchanges...")
Content(symLog: symLog,
stack: stack.push(),
@@ -56,7 +63,7 @@ struct ExchangeListView: View {
centsToTransfer: $centsToTransfer,
reloadAction: reloadAction)
.navigationTitle(navTitle)
- .navigationBarItems(leading: HamburgerButton(action: hamburgerAction),
+ .navigationBarItems(leading: hamburger,
trailing: PlusButton(action: plusAction)
.accessibilityLabel("Add Exchange"))
.overlay {
diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift
index 69623ad..9fcc912 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -65,12 +65,41 @@ struct MainView: View {
}
} // body
}
+// MARK: - TabBar
+enum Tab {
+ case balances, exchanges, settings
+}
+
// MARK: - Content
extension MainView {
struct Content: View {
let symLog: SymLogV?
let stack: CallStack
@Binding var talerFont: Int
+ @AppStorage("iconOnly") var iconOnly: Bool = false
+ let balancesTitle = String(localized: "Balances")
+ let exchangesTitle = String(localized: "Exchanges")
+ let settingsTitle = String(localized: "Settings")
+#if TABBAR // Taler Wallet
+ @State private var selectedTab: Tab = .balances
+
+ private func tabSelection() -> Binding<Tab> {
+ Binding { //this is the get block
+ self.selectedTab
+ } set: { tappedTab in
+ if tappedTab == self.selectedTab {
+ //User tapped on the tab twice == Pop to root view
+// if homeNavigationStack.isEmpty {
+ //User already on home view, scroll to top
+// } else {
+// homeNavigationStack = []
+// }
+ }
+ //Set the tab to the tabbed tab
+ self.selectedTab = tappedTab
+ }
+ }
+#else // GNU Taler
@State var sidebarVisible: Bool = false
func hamburgerAction() {
withAnimation(.easeInOut(duration: 0.25)) {
@@ -78,10 +107,6 @@ extension MainView {
}
}
- let balancesTitle = String(localized: "Balances")
- let exchanges = String(localized: "Exchanges")
- let settingsTitle = String(localized: "Settings")
- let settings = String(localized: "Settings")
var views: [SidebarItem] {[
SidebarItem(name: balancesTitle,
sysImage: "creditcard.fill", // TODO: Wallet Icon
@@ -89,10 +114,10 @@ extension MainView {
navTitle: balancesTitle,
hamburgerAction: hamburgerAction)
)),
- SidebarItem(name: exchanges,
+ SidebarItem(name: exchangesTitle,
sysImage: "building.columns",
- view: AnyView(ExchangeListView(stack: stack.push(exchanges),
- navTitle: exchanges,
+ view: AnyView(ExchangeListView(stack: stack.push(exchangesTitle),
+ navTitle: exchangesTitle,
hamburgerAction: hamburgerAction)
)),
SidebarItem(name: settingsTitle, // TODO: "About"?
@@ -103,12 +128,48 @@ extension MainView {
))
]}
@State var currentView: Int = 0
+#endif
var body: some View {
#if DEBUG
let _ = Self._printChanges()
let _ = symLog?.vlog() // just to get the # to compare it with .onAppear & onDisappear
#endif
+ Group {
+#if TABBAR // Taler Wallet
+// let labelStyle = iconOnly ? IconOnlyLabelStyle() : TitleAndIconLabelStyle() // labelStyle doesn't work
+ TabView(selection: tabSelection()) {
+ NavigationView {
+ BalancesListView(stack: stack.push(balancesTitle),
+ navTitle: balancesTitle)
+ }
+ .tabItem {
+ Image(systemName: "creditcard") // system will automatically use filled variant
+ if !iconOnly { Text(balancesTitle) }
+ }
+ .tag(Tab.balances)
+
+ NavigationView {
+ ExchangeListView(stack: stack.push(exchangesTitle),
+ navTitle: exchangesTitle)
+ }
+ .tabItem {
+ Image(systemName: "building.columns")
+ if !iconOnly { Text(exchangesTitle) }
+ }
+ .tag(Tab.exchanges)
+
+ NavigationView {
+ SettingsView(stack: stack.push(), navTitle: settingsTitle)
+ }
+ .tabItem {
+ Image(systemName: "gear") // system will automatically use filled variant
+ if !iconOnly { Text(settingsTitle) }
+ }
+ .tag(Tab.settings)
+ }
+// .animation(.linear(duration: LAUNCHDURATION), value: selectedTab) doesn't work. Needs CustomTabView
+#else // GNU Taler
ZStack(alignment: .leading) {
NavigationView { // the one and only for all non-sheet views
VStack(alignment: .leading) { // only needed for backslide transition
@@ -136,6 +197,8 @@ extension MainView {
sidebarVisible: sidebarVisible,
hamburgerAction: hamburgerAction)
}
+#endif
+ }
}
} // Content
}
diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift
index 471641d..79512b4 100644
--- a/TalerWallet1/Views/Settings/SettingsView.swift
+++ b/TalerWallet1/Views/Settings/SettingsView.swift
@@ -33,8 +33,12 @@ struct SettingsView: View {
@AppStorage("talerFont") var talerFont: Int = 0
@AppStorage("developDelay") var developDelay: Bool = false
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
+ @AppStorage("iconOnly") var iconOnly: Bool = false
+#if TABBAR // Taler Wallet
+#else // GNU Taler
var hamburgerAction: () -> Void
+#endif
@EnvironmentObject private var model: WalletModel
@@ -81,6 +85,11 @@ struct SettingsView: View {
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear
#endif
+#if TABBAR // Taler Wallet
+ let hamburger: HamburgerButton? = nil
+#else // GNU Taler
+ let hamburger: HamburgerButton = HamburgerButton(action: hamburgerAction)
+#endif
let walletCore = WalletCore.shared
Group {
List {
@@ -92,6 +101,8 @@ struct SettingsView: View {
description: String(localized: "When a transaction finished"))
SettingsFont(title: String(localized: "Font:"), value: talerFont, action: redraw)
SettingsStyle(title: String(localized: "Liststyle:"), myListStyle: $myListStyle)
+ SettingsToggle(name: String(localized: "Icon Only"), value: $iconOnly,
+ description: String(localized: "Omit text where possible"))
if diagnosticModeEnabled {
SettingsToggle(name: String(localized: "Developer Mode"), value: $developerMode,
description: String(localized: "More information intended for debugging")) {
@@ -250,11 +261,15 @@ struct SettingsView: View {
.listStyle(myListStyle.style).anyView
}
.navigationTitle(navTitle)
- .navigationBarItems(leading: HamburgerButton(action: hamburgerAction))
+ .navigationBarItems(leading: hamburger)
.onAppear() {
showDevelopItems = developerMode
DebugViewC.shared.setViewID(VIEW_SETTINGS, stack: stack.push())
}
+ .onDisappear() {
+ checkDisabled = false // reset
+ withDrawDisabled = false
+ }
.alert("Reset Wallet",
isPresented: $showResetAlert,
actions: { dismissAlertButton
@@ -287,7 +302,11 @@ extension Bundle {
#if DEBUG
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
+#if TABBAR // Taler Wallet
+ SettingsView(stack: CallStack("Preview"), navTitle: "Settings")
+#else // GNU Taler
SettingsView(stack: CallStack("Preview"), navTitle: "Settings") { }
+#endif
}
}
#endif