taler-ios

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

commit 24f4aceb707668285d76c6231542e2beda894867
parent a07f1090b780b6f9a6b1d883fdee8261802a92bf
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 17 Jun 2023 14:43:38 +0200

cleanup, back to Swift 5.8 (for now until Xcode 15 is usable)

Diffstat:
MTalerWallet1/Controllers/PublicConstants.swift | 14++++++++------
MTalerWallet1/Views/Balances/BalanceRowView.swift | 2+-
MTalerWallet1/Views/HelperViews/Buttons.swift | 32++++++++++++++++++++------------
MTalerWallet1/Views/HelperViews/ListStyle.swift | 52++++++++++++++++++----------------------------------
MTalerWallet1/Views/HelperViews/LoadingView.swift | 2+-
5 files changed, 48 insertions(+), 54 deletions(-)

diff --git a/TalerWallet1/Controllers/PublicConstants.swift b/TalerWallet1/Controllers/PublicConstants.swift @@ -4,12 +4,14 @@ */ import Foundation -public let DEMOBANK = "https://bAnK.dEmO.tAlEr.nEt" // should be weird to read, but still work -public let DEMOSHOP = "https://shop.demo.taler.net" -//public let DEMOEXCHANGE = "https://eXcHaNgE.dEmO.tAlEr.nEt" -public let DEMOEXCHANGE = "https://exchange.demo.taler.net" -public let DEMO_AGE_EXCHANGE = "https://exchange-age.taler.ar" -public let DEMO_EXP_EXCHANGE = "https://exchange-expensive.taler.ar" +public let HTTPS = "https://" +public let DEMOBANK = HTTPS + "bAnK.dEmO.tAlEr.nEt" // should be weird to read, but still work +public let DEMOSHOP = HTTPS + "shop.demo.taler.net" +public let DEMOBACKEND = HTTPS + "backend.demo.taler.net" +//public let DEMOEXCHANGE = HTTPS + "eXcHaNgE.dEmO.tAlEr.nEt" +public let DEMOEXCHANGE = HTTPS + "exchange.demo.taler.net" +public let DEMO_AGE_EXCHANGE = HTTPS + "exchange-age.taler.ar" +public let DEMO_EXP_EXCHANGE = HTTPS + "exchange-expensive.taler.ar" public let DEMOCURRENCY = "KUDOS" //public let LONGCURRENCY = "gold-pressed Latinum" // 20 characters, with dash and space public let LONGCURRENCY = "GOLDLATINUM" // 11 characters, no dash, no space diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift @@ -28,7 +28,7 @@ struct BalanceRowView: View { Text("Balance") .font(.footnote) .accessibility(sortPriority: 2) - Text("\(amount.valueStr)") // TODO: CurrencyFormatter + Text("\(amount.valueStr)") // TODO: CurrencyFormatter? .font(.title) .accessibility(sortPriority: 1) } diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift @@ -119,22 +119,30 @@ struct TalerButtonStyle: ButtonStyle { } func foreColor(type: TalerButtonStyleType, pressed: Bool) -> Color { - return if type == .plain { - WalletColors().fieldForeground - } else { +// return if type == .plain { +// WalletColors().fieldForeground +// } else { +// WalletColors().buttonForeColor(pressed: pressed, +// disabled: disabled(), +// prominent: type == .prominent) +// } + return type == .plain ? WalletColors().fieldForeground : WalletColors().buttonForeColor(pressed: pressed, - disabled: disabled(), - prominent: type == .prominent) - } + disabled: disabled(), + prominent: type == .prominent) } func backColor(type: TalerButtonStyleType, pressed: Bool) -> Color { - return if type == .plain { - Color.clear - } else { +// return if type == .plain { +// Color.clear +// } else { +// WalletColors().buttonBackColor(pressed: pressed, +// disabled: disabled(), +// prominent: type == .prominent) +// } + return type == .plain ? Color.clear : WalletColors().buttonBackColor(pressed: pressed, disabled: disabled(), prominent: type == .prominent) - } } struct BackgroundView: View { let color: Color @@ -207,7 +215,7 @@ struct Buttons_Previews: PreviewProvider { } #if DEBUG -struct ContentView: View { +fileprivate struct ContentView: View { @State var isOn = false //The better route is to have a separate variable to control the animations // This prevents unpleasant side-effects. @@ -235,7 +243,7 @@ struct ContentView: View { } } } -struct ContentView_Previews: PreviewProvider { +fileprivate struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } diff --git a/TalerWallet1/Views/HelperViews/ListStyle.swift b/TalerWallet1/Views/HelperViews/ListStyle.swift @@ -31,12 +31,12 @@ public extension View { // Here we make it CaseIterable for SwiftUI.ForEach // and the UI Display name public enum MyListStyle: String, CaseIterable, Hashable { - case automatic = "Automatic" - case grouped = "Grouped" - case inset = "Inset" - case insetGrouped = "InsetGrouped" - case plain = "Plain" - case sidebar = "Sidebar" + case automatic + case grouped + case inset + case insetGrouped + case plain + case sidebar // map to SwiftUI ListStyle var style: any SwiftUI.ListStyle { @@ -59,45 +59,29 @@ public enum MyListStyle: String, CaseIterable, Hashable { struct AnyViewDemo: View { @State private var selectedStyle = MyListStyle.automatic - let sections = ["Breakfast", "Lunch", "Dinner"] - let breakfast = ["pancakes", "bacon", "orange juice"] + let sections = ["Breakfast" : ["pancakes", "bacon", "orange juice"], + "Lunch" : ["sandwich", "chips", "lemonade"], + "Dinner" : ["spaghetti", "bread", "water"]] + + var body: some View { VStack { Picker("List Style", selection: $selectedStyle) { ForEach(MyListStyle.allCases, id: \.self) { - Text($0.displayName).tag($0) + Text($0.displayName.capitalized).tag($0) } } - List(sections, id: \.self) { section in - Section(section) { - if "Breakfast" == section { - ForEach(breakfast, id: \.self) { item in + let keys = Array(sections.keys) + List(keys.indices, id: \.self) { index in + let key = keys[index] + if let section = sections[key] { + Section(key) { + ForEach(section, id: \.self) { item in Text(item) } - } else { - Text("row") } } -// Section("Breakfast") { -// Text("pancakes") -// Text("bacon") -// Text("orange juice") -// } -// Section("Lunch") { -// Text("sandwich") -// Text("chips") -// Text("lemonade") -// } -// Section("Dinner") { -// Text("spaghetti") -// Text("bread") -// Text("water") -// } - } - .refreshable { - print("refreshing") - // this closure is already async, no need for a Task } .listStyle(selectedStyle.style) .anyView diff --git a/TalerWallet1/Views/HelperViews/LoadingView.swift b/TalerWallet1/Views/HelperViews/LoadingView.swift @@ -15,7 +15,7 @@ struct LoadingView: View { .navigationBarBackButtonHidden(backButtonHidden) .navigationTitle(navTitle) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) - .background(WalletColors().backgroundColor) +// .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) } } // MARK: -