taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit bab4ef3ca5d526e9b0b30250a0a984adc1e1191f
parent 5d28cd458b0b1a7c320bb15474ee9e4b4b3d414f
Author: Marc Stibane <marc@taler.net>
Date:   Sun,  7 Jan 2024 15:04:00 +0100

remove SideBarView

Diffstat:
MTalerWallet.xcodeproj/project.pbxproj | 10++--------
MTalerWallet1/Views/Balances/BalanceRowView.swift | 11+----------
MTalerWallet1/Views/Balances/BalancesListView.swift | 12+-----------
MTalerWallet1/Views/Banking/ExchangeListView.swift | 13++-----------
MTalerWallet1/Views/HelperViews/LaunchAnimationView.swift | 2+-
MTalerWallet1/Views/Main/MainView.swift | 68--------------------------------------------------------------------
DTalerWallet1/Views/Main/SideBarView.swift | 109-------------------------------------------------------------------------------
MTalerWallet1/Views/Settings/SettingsView.swift | 15---------------
8 files changed, 7 insertions(+), 233 deletions(-)

diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj @@ -90,7 +90,6 @@ 4E3EAE622A990778009F1BE8 /* TransactionDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095312989CBFE0043A8A1 /* TransactionDetailView.swift */; }; 4E3EAE632A990778009F1BE8 /* WalletCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0951C2989CBCB0043A8A1 /* WalletCore.swift */; }; 4E3EAE642A990778009F1BE8 /* LaunchAnimationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095432989CBFE0043A8A1 /* LaunchAnimationView.swift */; }; - 4E3EAE652A990778009F1BE8 /* SideBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095422989CBFE0043A8A1 /* SideBarView.swift */; }; 4E3EAE682A990778009F1BE8 /* WalletModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095112989CBB00043A8A1 /* WalletModel.swift */; }; 4E3EAE692A990778009F1BE8 /* URLSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095332989CBFE0043A8A1 /* URLSheet.swift */; }; 4E3EAE6A2A990778009F1BE8 /* ThreeAmountsV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ED2F94A2A278F5100453B40 /* ThreeAmountsV.swift */; }; @@ -207,7 +206,6 @@ 4EB095612989CBFE0043A8A1 /* WithdrawURIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0953C2989CBFE0043A8A1 /* WithdrawURIView.swift */; }; 4EB095622989CBFE0043A8A1 /* Model+Withdraw.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0953D2989CBFE0043A8A1 /* Model+Withdraw.swift */; }; 4EB095652989CBFE0043A8A1 /* WithdrawTOSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095402989CBFE0043A8A1 /* WithdrawTOSView.swift */; }; - 4EB095662989CBFE0043A8A1 /* SideBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095422989CBFE0043A8A1 /* SideBarView.swift */; }; 4EB095672989CBFE0043A8A1 /* LaunchAnimationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095432989CBFE0043A8A1 /* LaunchAnimationView.swift */; }; 4EB095682989CBFE0043A8A1 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095442989CBFE0043A8A1 /* MainView.swift */; }; 4EB095692989CBFE0043A8A1 /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095452989CBFE0043A8A1 /* ErrorView.swift */; }; @@ -382,7 +380,6 @@ 4EB0953C2989CBFE0043A8A1 /* WithdrawURIView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithdrawURIView.swift; sourceTree = "<group>"; }; 4EB0953D2989CBFE0043A8A1 /* Model+Withdraw.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Model+Withdraw.swift"; sourceTree = "<group>"; }; 4EB095402989CBFE0043A8A1 /* WithdrawTOSView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithdrawTOSView.swift; sourceTree = "<group>"; }; - 4EB095422989CBFE0043A8A1 /* SideBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideBarView.swift; sourceTree = "<group>"; }; 4EB095432989CBFE0043A8A1 /* LaunchAnimationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LaunchAnimationView.swift; sourceTree = "<group>"; }; 4EB095442989CBFE0043A8A1 /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; }; 4EB095452989CBFE0043A8A1 /* ErrorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorView.swift; sourceTree = "<group>"; }; @@ -717,7 +714,6 @@ isa = PBXGroup; children = ( 4EB095442989CBFE0043A8A1 /* MainView.swift */, - 4EB095422989CBFE0043A8A1 /* SideBarView.swift */, 4EB095452989CBFE0043A8A1 /* ErrorView.swift */, 4EB095392989CBFE0043A8A1 /* WalletEmptyView.swift */, ); @@ -1112,7 +1108,6 @@ 4E3EAE622A990778009F1BE8 /* TransactionDetailView.swift in Sources */, 4E3EAE632A990778009F1BE8 /* WalletCore.swift in Sources */, 4E3EAE642A990778009F1BE8 /* LaunchAnimationView.swift in Sources */, - 4E3EAE652A990778009F1BE8 /* SideBarView.swift in Sources */, E37AA62A2AF197E5003850CF /* Model+Refund.swift in Sources */, 4E3EAE682A990778009F1BE8 /* WalletModel.swift in Sources */, 4E3EAE692A990778009F1BE8 /* URLSheet.swift in Sources */, @@ -1218,7 +1213,6 @@ 4EB095582989CBFE0043A8A1 /* TransactionDetailView.swift in Sources */, 4EB095202989CBCB0043A8A1 /* WalletCore.swift in Sources */, 4EB095672989CBFE0043A8A1 /* LaunchAnimationView.swift in Sources */, - 4EB095662989CBFE0043A8A1 /* SideBarView.swift in Sources */, E37AA62B2AF197E5003850CF /* Model+Refund.swift in Sources */, 4EB095162989CBB00043A8A1 /* WalletModel.swift in Sources */, 4EB0955A2989CBFE0043A8A1 /* URLSheet.swift in Sources */, @@ -1508,7 +1502,7 @@ SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG TABBAR"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG TALER_WALLET"; SWIFT_EMIT_LOC_STRINGS = YES; TARGETED_DEVICE_FAMILY = 1; VALIDATE_WORKSPACE = YES; @@ -1550,7 +1544,7 @@ SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = TABBAR; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = TALER_WALLET; SWIFT_EMIT_LOC_STRINGS = YES; TARGETED_DEVICE_FAMILY = 1; VALIDATE_WORKSPACE = YES; diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift @@ -48,21 +48,12 @@ struct BalanceButton: View { } else { vLayout } // view for iOS 15 } } -#if TABBAR // Taler Wallet NavigationLink { balanceDest } label: { balanceCell .accessibilityElement(children: .combine) .accessibilityHint("Will go to main transactions list.") - } -#else // GNU Taler - Button(action: rowAction) { - balanceCell - } .disabled(false) - .buttonStyle(TalerButtonStyle(type: iconOnly ? .plain : .balance, aligned: .trailing)) - .accessibilityElement(children: .combine) - .accessibilityHint("Will go to main transactions list.") // .accessibilityLabel(balanceTitleStr + " " + amountStr) // TODO: CurrencyFormatter! -#endif + } } } diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift @@ -14,10 +14,6 @@ struct BalancesListView: View { let navTitle: String @Binding var balances: [Balance] @Binding var shouldReloadBalances: Int -#if TABBAR // Taler Wallet -#else // GNU Taler - let hamburgerAction: () -> Void -#endif @EnvironmentObject private var model: WalletModel @@ -97,17 +93,11 @@ 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, amountToTransfer: $amountToTransfer, summary: $summary, reloadBalances: reloadBalances) .navigationTitle(navTitle) - .navigationBarItems(leading: hamburger, - trailing: QRButton(action: checkCameraAvailable)) + .navigationBarItems(trailing: QRButton(action: checkCameraAvailable)) .alert("Scanning QR-codes requires access to the camera", isPresented: $showCameraAlert, actions: { openSettingsButton diff --git a/TalerWallet1/Views/Banking/ExchangeListView.swift b/TalerWallet1/Views/Banking/ExchangeListView.swift @@ -12,10 +12,6 @@ struct ExchangeListView: View { let stack: CallStack @Binding var balances: [Balance] let navTitle: String -#if TABBAR // Taler Wallet -#else // GNU Taler - var hamburgerAction: () -> Void -#endif @EnvironmentObject private var model: WalletModel @State var showAlert: Bool = false @@ -35,11 +31,6 @@ struct ExchangeListView: View { } var body: some View { -#if TABBAR // Taler Wallet - let hamburger: HamburgerButton? = nil -#else // GNU Taler - let hamburger = HamburgerButton(action: hamburgerAction) -#endif let accessibilityLabelStr = String(localized: "Add Exchange", comment: "accessibilityLabel for the + button") let plusButton = PlusButton(accessibilityLabelStr: accessibilityLabelStr) { showAlert = true @@ -49,7 +40,7 @@ struct ExchangeListView: View { if #available(iOS 16.0, *) { ExchangeListCommonV(symLog: symLog, stack: stack.push(), balances: $balances) .navigationTitle(navTitle) - .navigationBarItems(leading: hamburger, trailing: plusButton) + .navigationBarItems(trailing: plusButton) .alert(addTitleStr, isPresented: $showAlert) { TextField("Exchange address", text: $newExchange) // .textFieldStyle(.roundedBorder) Yikes: when adding style the alert will stop showing the textfield! Don't do this. @@ -63,7 +54,7 @@ struct ExchangeListView: View { } else { // iOS 15 cannot have a textfield in an alert, so we must ExchangeListCommonV(symLog: symLog, stack: stack.push(), balances: $balances) .navigationTitle(navTitle) - .navigationBarItems(leading: hamburger, trailing: plusButton) + .navigationBarItems(trailing: plusButton) .textFieldAlert(isPresented: $showAlert, title: addTitleStr, doneText: addButtonStr, diff --git a/TalerWallet1/Views/HelperViews/LaunchAnimationView.swift b/TalerWallet1/Views/HelperViews/LaunchAnimationView.swift @@ -18,7 +18,7 @@ struct RotatingTaler: View { let size: CGFloat @Binding var rotationEnabled: Bool @State private var rotationDirection = false -#if TABBAR // Taler Wallet +#if TALER_WALLET let logo = "taler-logo-2023-blue" #else // GNU Taler let logo = "taler-logo-2023-red" diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -92,7 +92,6 @@ extension MainView { let balancesTitle = String(localized: "TitleBalances", defaultValue: "Balances") let exchangesTitle = String(localized: "TitleExchanges", defaultValue: "Banking") let settingsTitle = String(localized: "TitleSettings", defaultValue: "Settings") -#if TABBAR // Taler Wallet @State private var selectedTab: Tab = .balances @State private var showKycAlert: Bool = false @State private var kycURI: URL? @@ -129,39 +128,6 @@ extension MainView { self.selectedTab = tappedTab } } -#else // GNU Taler - @State var sidebarVisible: Bool = false - func hamburgerAction() { - withAnimation(.easeInOut(duration: 0.25)) { - sidebarVisible = !sidebarVisible - } - } - - var views: [SidebarItem] {[ - SidebarItem(name: balancesTitle, - sysImage: "chart.bar.xaxis", // creditcard.fill // TODO: Wallet Icon - view: AnyView(BalancesListView(stack: stack.push(balancesTitle), - navTitle: balancesTitle, - balances: $balances, - shouldReloadBalances: $shouldReloadBalances, - hamburgerAction: hamburgerAction) - )), - SidebarItem(name: exchangesTitle, - sysImage: "arrow.triangle.2.circlepath", - view: AnyView(ExchangeListView(stack: stack.push(exchangesTitle), -// balances: $balances, - navTitle: exchangesTitle, - hamburgerAction: hamburgerAction) - )), - SidebarItem(name: settingsTitle, // TODO: "About"? - sysImage: "gearshape.fill", - view: AnyView(SettingsView(stack: stack.push(settingsTitle), - navTitle: settingsTitle, - hamburgerAction: hamburgerAction) - )) - ]} - @State var currentView: Int = 0 -#endif var body: some View { #if PRINT_CHANGES @@ -179,7 +145,6 @@ extension MainView { let delay: UInt = 0 // no delay for release builds #endif Group { -#if TABBAR // Taler Wallet // let labelStyle = iconOnly ? IconOnlyLabelStyle() : TitleAndIconLabelStyle() // labelStyle doesn't work TabView(selection: tabSelection()) { NavigationView { @@ -220,35 +185,6 @@ extension MainView { .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 - views[currentView].view - .id(views[currentView].name) - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) - .transition(.backslide) - } .id(talerFont) - .navigationBarTitleDisplayMode(.automatic) - .background(NavigationBarBuilder { navigationController in - // navigationController.navigationBar.barTintColor = .red - navigationController.navigationBar.titleTextAttributes = - [.font: TalerFont.uiFont(talerFont, size: 24, relativeTo: .title2)] - navigationController.navigationBar.largeTitleTextAttributes = - [.font: TalerFont.uiFont(talerFont, size: 38, relativeTo: .largeTitle)] - }) - }.id(viewState.rootViewId) // any change to rootViewId triggers popToRootView behaviour - .navigationViewStyle(.stack) - .talerNavBar(talerFont: talerFont) - - // The side view is above (Z-Axis) the current view - SideBarView(stack: stack.push(), - views: views, - currentView: $currentView, - sidebarVisible: sidebarVisible, - hamburgerAction: hamburgerAction) - } -#endif } .onNotification(.KYCrequired) { notification in // show an alert with the KYC link (button) which opens in Safari if let transition = notification.userInfo?[TRANSACTIONTRANSITION] as? TransactionTransition { @@ -279,12 +215,8 @@ extension MainView { shouldReloadBalances += 1 } .onNotification(.TransactionDone) { -#if TABBAR // Taler Wallet shouldReloadBalances += 1 selectedTab = .balances -#else // GNU Taler - -#endif } .onChange(of: balances) { newArray in for balance in newArray { diff --git a/TalerWallet1/Views/Main/SideBarView.swift b/TalerWallet1/Views/Main/SideBarView.swift @@ -1,109 +0,0 @@ -/* - * This file is part of GNU Taler, ©2022-23 Taler Systems S.A. - * See LICENSE.md - */ -import SwiftUI -import SymLog - -fileprivate let sidebarWidth = 200.0 - -struct SidebarItem { - var name: String - var sysImage: String? - var view: AnyView -} - -struct SideBarView: View { - private let symLog = SymLogV(0) - let stack: CallStack - let views: [SidebarItem] - @Binding var currentView: Int - let sidebarVisible: Bool - let hamburgerAction: () -> Void - @State private var rotationEnabled = false - - var body: some View { - HStack { // sideView left, clear dismiss target right - EqualIconWidthDomain { - VStack(spacing: 10) { - let gnuTaler = String("GNU Taler") // this should NOT be translated - Link(gnuTaler, destination: URL(string:"https://taler.net")!) - .accessibilityFont(.largeTitle) - .padding(.top, 30) - RotatingTaler(size: 100, rotationEnabled: $rotationEnabled) - .onTapGesture { - rotationEnabled.toggle() - } - ForEach(0..<views.count, id: \.self) { i in - Button { - symLog.log("sidebar item \"\(views[i].name)\" selected") - hamburgerAction() // slide sidebar to the left - withAnimation(.easeInOut(duration: 0.3)) {currentView = i} // animate to the view the user selected - } label: { - if let sysImage = views[i].sysImage { - Label(views[i].name, systemImage: sysImage) - .frame(maxWidth: sidebarWidth, alignment: .leading) - } else { - Text(views[i].name) - .frame(maxWidth: sidebarWidth) - } - } - .padding() - .buttonStyle(.borderless) - .accessibilityFont(.title2) - .disabled(i == currentView) - .accessibilityHidden(i == currentView) // don't suggest the current item - } - Spacer() - } - .background(WalletColors().sideBackground) - .frame(width: sidebarWidth, alignment: .center) - // TODO: use leading instead of sidebarWidth for right-to-left - .offset(x: sidebarVisible ? 0 : -sidebarWidth) - // .onAppear can NOT be used here, because we don't show or dismiss this view, - // but only slide it left or right - so it is always there. - } - // this is just a target for a tap gesture outside the sidebar to dismiss it - Color.clear - .frame(maxWidth: sidebarVisible ? .infinity : 0, maxHeight: .infinity, alignment: .leading) - // TODO: right-to-left ? - .offset(x: sidebarVisible ? sidebarWidth : 0) - .contentShape(Rectangle()) - .onTapGesture { - hamburgerAction() // slide sidebar to the left - } - } - } -} -// MARK: - -#if DEBUG -fileprivate struct BindingViewContainer : View { - @State var currentView: Int = 0 - @State var sidebarVisible: Bool = true - var views: [SidebarItem] - - var body: some View { - ZStack(alignment: .leading) { - views[currentView].view - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) - SideBarView(stack: CallStack("Preview"), views: views, currentView: $currentView, - sidebarVisible: sidebarVisible, - hamburgerAction: { sidebarVisible = !sidebarVisible }) - } - } -} - -struct SideBarView_Previews: PreviewProvider { - static var views: [SidebarItem] {[ - SidebarItem(name: "Balances", - sysImage: "creditcard.fill", // TODO: Wallet Icon - view: AnyView(WalletEmptyView(stack: CallStack("Preview")))), - SidebarItem(name: "Settings", - sysImage: "gearshape.fill", - view: AnyView(WalletEmptyView(stack: CallStack("Preview")))) - ]} - static var previews: some View { - BindingViewContainer(views: views) - } -} -#endif diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift @@ -38,11 +38,6 @@ struct SettingsView: View { @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic @AppStorage("iconOnly") var iconOnly: Bool = false -#if TABBAR // Taler Wallet -#else // GNU Taler - var hamburgerAction: () -> Void -#endif - @State private var checkDisabled = false @State private var withDrawDisabled = false #if DEBUG @@ -87,11 +82,6 @@ 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 { @@ -280,7 +270,6 @@ struct SettingsView: View { .listStyle(myListStyle.style).anyView } .navigationTitle(navTitle) - .navigationBarItems(leading: hamburger) .onAppear() { showDevelopItems = developerMode hideDescriptions = iconOnly @@ -311,11 +300,7 @@ struct SettingsView: View { #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