TalerTab.swift (2084B)
1 /* 2 * This file is part of GNU Taler, ©2022-26 Taler Systems S.A. 3 * See LICENSE.md 4 */ 5 /** 6 * @author Marc Stibane 7 * @author Iván Ávalos 8 */ 9 import SwiftUI 10 import os.log 11 import SymLog 12 import AVFoundation 13 import taler_swift 14 15 // MARK: - 16 extension Label where Title == Text, Icon == Image { 17 init(_ tab: TalerTab) { 18 if #available(iOS 26.0, *) { 19 switch tab { 20 case .actions: self.init(tab.title, image: TALER_LOGO) 21 default: self.init(tab.title, systemImage: tab.sysImg) 22 } 23 } else { 24 self.init(EMPTYSTRING, systemImage: tab.sysImg) 25 } 26 } 27 } 28 // MARK: - TabBar 29 enum TalerTab: Int, Hashable, CaseIterable { 30 case balances = 0 31 case actions 32 case settings 33 34 // var index: Int { self.rawValue } 35 36 var title: String { 37 switch self { 38 case .balances: String(localized: "TitleBalances", defaultValue: "Balances") 39 case .actions: String(localized: "TitleActions", defaultValue: "Actions") 40 case .settings: String(localized: "TitleSettings", defaultValue: "Settings") 41 } 42 } 43 44 var image: Image { 45 switch self { 46 case .balances: return Image(systemName: BALANCES) // "chart.bar.xaxis" 47 case .actions: return Image(TALER_LOGO) 48 case .settings: return Image(systemName: SETTINGS) // "gear" 49 } 50 } 51 52 // func tabImage(_ size: CGFloat) -> some View { 53 // self.image 54 // .resizable() 55 // .renderingMode(.template) 56 // .tint(.black) 57 // .aspectRatio(contentMode: .fit) 58 // .frame(width: size, height: size) 59 // } 60 61 var sysImg: String { 62 switch self { 63 case .balances: BALANCES // "chart.bar.xaxis" 64 case .actions: "bolt" 65 case .settings: SETTINGS // "gear" 66 } 67 } 68 69 var label: Label<Text, Image> { 70 Label(self) 71 } 72 }