commit 673d108a0805294e26478e994490bcd61fe36436 parent 3a68f88c19854f468e8ea3f92b327ed49c9f72ce Author: Marc Stibane <marc@taler.net> Date: Sun, 11 Feb 2024 12:49:50 +0100 talerFont Diffstat:
41 files changed, 149 insertions(+), 149 deletions(-)
diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift @@ -38,7 +38,7 @@ class Controller: ObservableObject { @AppStorage("useHaptics") var useHaptics: Bool = true // extension mustn't define this, so it must be here @AppStorage("playSoundsI") var playSoundsI: Int = 1 // extension mustn't define this, so it must be here @AppStorage("playSoundsB") var playSoundsB: Bool = true - @AppStorage("talerFont") var talerFont: Int = 0 // extension mustn't define this, so it must be here + @AppStorage("talerFontIndex") var talerFontIndex: Int = 0 // extension mustn't define this, so it must be here let hapticCapability = CHHapticEngine.capabilitiesForHardware() let logger = Logger(subsystem: "net.taler.gnu", category: "Controller") let player = AVQueuePlayer() diff --git a/TalerWallet1/Controllers/DebugViewC.swift b/TalerWallet1/Controllers/DebugViewC.swift @@ -125,7 +125,7 @@ struct DebugViewV: View { } Text(viewIDString) .foregroundColor(.red) - .font(.system(size: 11)) // no accessibilityFont + .font(.system(size: 11)) // no talerFont .monospacedDigit() .id("viewID") .accessibilityLabel(Text("View.ID.", comment: "AccessibilityLabel")) diff --git a/TalerWallet1/Helper/Font+Taler.swift b/TalerWallet1/Helper/Font+Taler.swift @@ -51,7 +51,7 @@ extension UIFont { /// provides a (custom) scalable UIFont based on the first parameter: 0 = system, 1 = Atkinson, 2 = Nunito, 3 = NunitoItalic -struct TalerFont { +struct TalerUIFont { @Environment(\.legibilityWeight) private var legibilityWeight: LegibilityWeight? private static func scalableSystemFont(for style: UIFont.TextStyle, legibilityBold: Bool = false, @@ -101,37 +101,37 @@ struct TalerFont { static func uiFont(_ selectedFont: Int, size: CGFloat, relativeTo style: UIFont.TextStyle, legibilityBold: Bool = false, bold: Bool = false, italic: Bool = false) -> UIFont { switch selectedFont { - case 1: return TalerFont.atkinson(size: size, relativeTo: style, + case 1: return TalerUIFont.atkinson(size: size, relativeTo: style, legibilityBold: legibilityBold, bold: bold, italic: italic) - case 2: return TalerFont.nunito(size: size, relativeTo: style, + case 2: return TalerUIFont.nunito(size: size, relativeTo: style, legibilityBold: legibilityBold, bold: bold, italic: italic) default: // return UIFont.preferredFont(forTextStyle: style) - return TalerFont.scalableSystemFont(for: style, legibilityBold: legibilityBold, bold: bold, italic: italic) + return TalerUIFont.scalableSystemFont(for: style, legibilityBold: legibilityBold, bold: bold, italic: italic) } } static func uiFont(_ styleSize: StyleSizeBold) -> UIFont { - return uiFont(Controller.shared.talerFont, size: styleSize.size, relativeTo: styleSize.style) + return uiFont(Controller.shared.talerFontIndex, size: styleSize.size, relativeTo: styleSize.style) } } -struct AccessibleFont { // old running +struct TalerFont { // old running var regular: Font var bold: Font - static var talerFont: Int { return 2 } + static var talerFontIndex: Int { return 2 } init(_ base: String, size: CGFloat, relativeTo: Font.TextStyle, isBold: Bool = false) { - if AccessibleFont.talerFont == 0 { + if TalerFont.talerFontIndex == 0 { self.regular = .system(relativeTo) self.bold = .system(relativeTo).bold() } else if isBold { // Nunito has Black Variants, but AtkinsonHyperlegible doesn't - self.regular = Font.custom(base + (AccessibleFont.talerFont == 2 ? BOLD : BOLDITALIC), size: size, relativeTo: relativeTo) - self.bold = Font.custom(base + (AccessibleFont.talerFont == 2 ? BLACK : BLACKITALIC), size: size, relativeTo: relativeTo) + self.regular = Font.custom(base + (TalerFont.talerFontIndex == 2 ? BOLD : BOLDITALIC), size: size, relativeTo: relativeTo) + self.bold = Font.custom(base + (TalerFont.talerFontIndex == 2 ? BLACK : BLACKITALIC), size: size, relativeTo: relativeTo) } else { - self.regular = Font.custom(base + (AccessibleFont.talerFont > 2 ? ITALIC : REGULAR), size: size, relativeTo: relativeTo) - self.bold = Font.custom(base + (AccessibleFont.talerFont > 2 ? BOLDITALIC : BOLD), size: size, relativeTo: relativeTo) + self.regular = Font.custom(base + (TalerFont.talerFontIndex > 2 ? ITALIC : REGULAR), size: size, relativeTo: relativeTo) + self.bold = Font.custom(base + (TalerFont.talerFontIndex > 2 ? BOLDITALIC : BOLD), size: size, relativeTo: relativeTo) } } @@ -167,19 +167,19 @@ struct StyleSizeBold { // static var caption2: AccessibleFont { AccessibleFont(fontName, size: 12, relativeTo: .caption2) } // 11 -> 12 } -extension AccessibleFont { // old running +extension TalerFont { // old running static var fontName: String { NUNITO } - static var largeTitle: AccessibleFont { AccessibleFont(fontName, size: 38, relativeTo: .largeTitle) } // 34 -> 38 - static var title: AccessibleFont { AccessibleFont(fontName, size: 31, relativeTo: .title) } // 28 -> 31 - static var title2: AccessibleFont { AccessibleFont(fontName, size: 25, relativeTo: .title2) } // 22 -> 25 - static var title3: AccessibleFont { AccessibleFont(fontName, size: 23, relativeTo: .title3) } // 20 -> 23 - static var headline: AccessibleFont { AccessibleFont(fontName, size: 19, relativeTo: .headline, isBold: true) } // 17 bold -> 19 bold - static var body: AccessibleFont { AccessibleFont(fontName, size: 19, relativeTo: .body) } // 17 -> 19 - static var callout: AccessibleFont { AccessibleFont(fontName, size: 18, relativeTo: .callout) } // 16 -> 18 - static var subheadline: AccessibleFont { AccessibleFont(fontName, size: 17, relativeTo: .subheadline) } // 15 -> 17 - static var footnote: AccessibleFont { AccessibleFont(fontName, size: 15, relativeTo: .footnote) } // 13 -> 15 - static var caption: AccessibleFont { AccessibleFont(fontName, size: 13, relativeTo: .caption) } // 12 -> 13 + static var largeTitle: TalerFont { TalerFont(fontName, size: 38, relativeTo: .largeTitle) } // 34 -> 38 + static var title: TalerFont { TalerFont(fontName, size: 31, relativeTo: .title) } // 28 -> 31 + static var title2: TalerFont { TalerFont(fontName, size: 25, relativeTo: .title2) } // 22 -> 25 + static var title3: TalerFont { TalerFont(fontName, size: 23, relativeTo: .title3) } // 20 -> 23 + static var headline: TalerFont { TalerFont(fontName, size: 19, relativeTo: .headline, isBold: true) } // 17 bold -> 19 bold + static var body: TalerFont { TalerFont(fontName, size: 19, relativeTo: .body) } // 17 -> 19 + static var callout: TalerFont { TalerFont(fontName, size: 18, relativeTo: .callout) } // 16 -> 18 + static var subheadline: TalerFont { TalerFont(fontName, size: 17, relativeTo: .subheadline) } // 15 -> 17 + static var footnote: TalerFont { TalerFont(fontName, size: 15, relativeTo: .footnote) } // 13 -> 15 + static var caption: TalerFont { TalerFont(fontName, size: 13, relativeTo: .caption) } // 12 -> 13 } struct StyleSizeBoldViewModifier: ViewModifier { @@ -188,25 +188,25 @@ struct StyleSizeBoldViewModifier: ViewModifier { let styleSize: StyleSizeBold - static var talerFont: Int { + static var talerFontIndex: Int { if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" { return 2 } else { - return Controller.shared.talerFont + return Controller.shared.talerFontIndex } } func body(content: Content) -> some View { // TODO: italic - let uiFont = TalerFont.uiFont(Self.talerFont, size: styleSize.size, relativeTo: styleSize.style, + let uiFont = TalerUIFont.uiFont(Self.talerFontIndex, size: styleSize.size, relativeTo: styleSize.style, legibilityBold: legibilityBold, bold: styleSize.bold) content.font(Font(uiFont)) } } -struct AccessibilityFontViewModifier2: ViewModifier { // old running +struct TalerFontViewModifier2: ViewModifier { // old running @Environment(\.legibilityWeight) private var legibilityWeight - var font: AccessibleFont + var font: TalerFont func body(content: Content) -> some View { content.font(font.value(legibilityWeight)) @@ -214,10 +214,10 @@ struct AccessibilityFontViewModifier2: ViewModifier { // old running } extension View { - func accessibilityFont(_ font: AccessibleFont) -> some View { - return self.modifier(AccessibilityFontViewModifier2(font: font)) + func talerFont(_ font: TalerFont) -> some View { + return self.modifier(TalerFontViewModifier2(font: font)) } - func accessibilityFont1(_ styleSize: StyleSizeBold) -> some View { + func talerFont1(_ styleSize: StyleSizeBold) -> some View { return self.modifier(StyleSizeBoldViewModifier(styleSize: styleSize)) } } @@ -241,33 +241,33 @@ struct NavigationBarBuilder: UIViewControllerRepresentable { /// This works only once. Each following call does nothing - including (re-)setting to nil @MainActor struct TalerNavBar: ViewModifier { - let talerFont: Int + let talerFontIndex: Int - static func setNavBarFonts(talerFont: Int) -> Void { + static func setNavBarFonts(talerFontIndex: Int) -> Void { let navBarAppearance = UINavigationBar.appearance() navBarAppearance.titleTextAttributes = nil navBarAppearance.largeTitleTextAttributes = nil - if talerFont != 0 { - navBarAppearance.titleTextAttributes = [.font: TalerFont.uiFont(talerFont, size: 24, relativeTo: .title2)] - navBarAppearance.largeTitleTextAttributes = [.font: TalerFont.uiFont(talerFont, size: 38, relativeTo: .largeTitle)] + if talerFontIndex != 0 { + navBarAppearance.titleTextAttributes = [.font: TalerUIFont.uiFont(talerFontIndex, size: 24, relativeTo: .title2)] + navBarAppearance.largeTitleTextAttributes = [.font: TalerUIFont.uiFont(talerFontIndex, size: 38, relativeTo: .largeTitle)] } } - init(_ talerFont: Int) { - self.talerFont = talerFont - TalerNavBar.setNavBarFonts(talerFont: talerFont) + init(_ talerFontIdx: Int) { + self.talerFontIndex = talerFontIdx + TalerNavBar.setNavBarFonts(talerFontIndex: talerFontIdx) } func body(content: Content) -> some View { - let _ = TalerNavBar.setNavBarFonts(talerFont: talerFont) + let _ = TalerNavBar.setNavBarFonts(talerFontIndex: talerFontIndex) content } } extension View { - @MainActor func talerNavBar(talerFont: Int) -> some View { - self.modifier(TalerNavBar(talerFont)) + @MainActor func talerNavBar(talerFontIndex: Int) -> some View { + self.modifier(TalerNavBar(talerFontIndex)) } } @@ -304,7 +304,7 @@ struct ContentViewFonts: View { Text("title a") Text("bold").bold() } - .accessibilityFont(.title) + .talerFont(.title) .padding() HStack { @@ -312,19 +312,19 @@ struct ContentViewFonts: View { Text("italic").italic() Text("bold").bold() } - .accessibilityFont(.title2) + .talerFont(.title2) .padding() Text("headline") - .accessibilityFont(.headline) + .talerFont(.headline) .padding(.top) Text("headline bold") .bold() - .accessibilityFont(.headline) + .talerFont(.headline) .padding(.bottom) Text("title2 bold italic") .bold() .italic() - .accessibilityFont(.title2) + .talerFont(.title2) .padding() } } diff --git a/TalerWallet1/Helper/TalerStrings.swift b/TalerWallet1/Helper/TalerStrings.swift @@ -62,7 +62,7 @@ extension String { } public func width(largeAmountFont: Bool, _ sizeCategory: ContentSizeCategory) -> CGFloat { - let uiFont = TalerFont.uiFont(largeAmountFont ? .title : .title2) + let uiFont = TalerUIFont.uiFont(largeAmountFont ? .title : .title2) return widthOfString(usingUIFont: uiFont, sizeCategory) } diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift @@ -28,7 +28,7 @@ struct BalanceCell: View { hLayout } else { let balanceText = Text("Balance:", comment: "Main view") - .accessibilityFont(.title2) + .talerFont(.title2) .foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary) let vLayout = VStack(alignment: .leading, spacing: 0) { balanceText diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -65,14 +65,14 @@ extension BalancesSectionView: View { if scopeInfo.type == .exchange { let baseURL = scopeInfo.url?.trimURL() ?? String(localized: "Unknown Payment Provider", comment: "exchange url") Text(baseURL) - .accessibilityFont(.headline) + .talerFont(.headline) .listRowSeparator(.hidden) } let showSpendingButton = "KUDOS" == currency && !balance.available.isZero if showSpendingButton { if !minimalistic && showSpendingHint { Text("You can spend these \(currencyInfo?.scope.currency ?? currency) in the Demo shop, or send them to another wallet.") - .accessibilityFont(.body) + .talerFont(.body) .multilineTextAlignment(.leading) .listRowSeparator(.hidden) } @@ -139,7 +139,7 @@ extension BalancesSectionView: View { let count = transactionCount > MAXRECENT ? MAXRECENT : transactionCount Text(count > 1 ? "Recent \(count) transactions" : "Recent transaction") - .accessibilityFont(.callout) + .talerFont(.callout) // .foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary) } } @@ -191,7 +191,7 @@ fileprivate struct BalancesPendingRowView: View { } if !hasIncoming && !hasOutgoing { // should never happen Text("Some pending transactions") - .accessibilityFont(.body) + .talerFont(.body) } } .accessibilityElement(children: .combine) diff --git a/TalerWallet1/Views/Banking/ExchangeListView.swift b/TalerWallet1/Views/Banking/ExchangeListView.swift @@ -110,7 +110,7 @@ extension ExchangeListCommonV: View { .overlay { if exchanges.isEmpty { Text("No Payment Services yet...") - .accessibilityFont(.body) + .talerFont(.body) } } .onNotification(.ExchangeAdded) { notification in diff --git a/TalerWallet1/Views/Banking/ExchangeRowView.swift b/TalerWallet1/Views/Banking/ExchangeRowView.swift @@ -76,10 +76,10 @@ struct ExchangeRowView: View { NavigationLink(destination: showToS) { VStack(alignment: .leading) { Text(baseURL.trimURL()) - .accessibilityFont(.headline) + .talerFont(.headline) if !minimalistic { Text("Terms of Service") // VIEW_WITHDRAW_TOS - .accessibilityFont(.body) + .talerFont(.body) } } } diff --git a/TalerWallet1/Views/Banking/ManualWithdraw.swift b/TalerWallet1/Views/Banking/ManualWithdraw.swift @@ -52,7 +52,7 @@ struct ManualWithdraw: View { ScrollView { VStack(alignment: .trailing) { Text("via \(exchange.exchangeBaseUrl.trimURL())") .multilineTextAlignment(.center) - .accessibilityFont(.body) + .talerFont(.body) if tosAccepted { CurrencyInputView(amount: $amountToTransfer, available: nil, diff --git a/TalerWallet1/Views/Banking/QuiteSomeCoins.swift b/TalerWallet1/Views/Banking/QuiteSomeCoins.swift @@ -70,7 +70,7 @@ struct QuiteSomeCoins: View { Text(someCoins.quiteSome ? "Note: It will take quite some time to withdraw this amount! Be more patient..." : "Note: It will take some time to withdraw this amount. Be patient...") .foregroundColor(someCoins.quiteSome ? .red : .primary) - .accessibilityFont(.body) + .talerFont(.body) .multilineTextAlignment(.leading) .padding(.vertical, 6) } // warnings @@ -80,7 +80,7 @@ struct QuiteSomeCoins: View { if let fee = someCoins.fee { Text(someCoins.feeLabel(currencyInfo)) .foregroundColor((someCoins.invalid || someCoins.tooMany || !fee.isZero) ? .red : .primary) - .accessibilityFont(.body) + .talerFont(.body) } } } diff --git a/TalerWallet1/Views/HelperViews/AgePicker.swift b/TalerWallet1/Views/HelperViews/AgePicker.swift @@ -32,7 +32,7 @@ struct AgePicker: View { HStack { Text("If this wallet belongs to a child or teenager, the generated electronic cash should be age-restricted:") .multilineTextAlignment(.leading) - .accessibilityFont(.footnote) + .talerFont(.footnote) Spacer() }.padding(.top) Picker("Select age", selection: $selectedAge) { @@ -42,7 +42,7 @@ struct AgePicker: View { : "\(index) years").tag(index) } } - .accessibilityFont(.body) + .talerFont(.body) } } } diff --git a/TalerWallet1/Views/HelperViews/AmountRowV.swift b/TalerWallet1/Views/HelperViews/AmountRowV.swift @@ -15,7 +15,7 @@ struct AmountRowV: View { var body: some View { let titleV = Text(title) .multilineTextAlignment(.leading) - .accessibilityFont(.body) + .talerFont(.body) let amountV = AmountV(amount: amount, large: large) .foregroundColor(color) let verticalV = VStack(alignment: .leading) { diff --git a/TalerWallet1/Views/HelperViews/AmountV.swift b/TalerWallet1/Views/HelperViews/AmountV.swift @@ -21,7 +21,7 @@ struct AmountV: View { var body: some View { Text(amountStr) .multilineTextAlignment(.center) - .accessibilityFont(large ? .title : .title2) + .talerFont(large ? .title : .title2) // .fontWeight(large ? .medium : .regular) // @available(iOS 16.0, *) .monospacedDigit() } diff --git a/TalerWallet1/Views/HelperViews/BarGraph.swift b/TalerWallet1/Views/HelperViews/BarGraph.swift @@ -23,7 +23,7 @@ struct BarGraphHeader: View { var body: some View { HStack (alignment: .center, spacing: 10) { Text(currencyName) - .accessibilityFont(.title2) + .talerFont(.title2) // .foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary) if let scopeInfo { BarGraph(transactions: $completedTransactions, diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift @@ -23,7 +23,7 @@ struct HamburgerButton : View { Image(systemName: "line.3.horizontal") // Image(systemName: "sidebar.squares.leading") } - .accessibilityFont(.title) + .talerFont(.title) .accessibilityLabel("Main Menu") } } @@ -35,7 +35,7 @@ struct QRButton : View { Button(action: action) { Image(systemName: "qrcode.viewfinder") } - .accessibilityFont(.title) + .talerFont(.title) .accessibilityLabel("Scan QR codes") } } @@ -48,7 +48,7 @@ struct PlusButton : View { Button(action: action) { Image(systemName: "plus") } - .accessibilityFont(.title) + .talerFont(.title) .accessibilityLabel(accessibilityLabelStr) } } @@ -60,7 +60,7 @@ struct ArrowUpButton : View { Button(action: action) { Image(systemName: "arrow.up.to.line") } - .accessibilityFont(.title2) + .talerFont(.title2) .accessibilityLabel("Scroll up") } } @@ -72,7 +72,7 @@ struct ArrowDownButton : View { Button(action: action) { Image(systemName: "arrow.down.to.line") } - .accessibilityFont(.title2) + .talerFont(.title2) .accessibilityLabel("Scroll down") } } @@ -85,7 +85,7 @@ struct ReloadButton : View { Button(action: action) { Image(systemName: "arrow.clockwise") } - .accessibilityFont(.title) + .talerFont(.title) .accessibilityLabel("Reload") .disabled(disabled) } @@ -170,7 +170,7 @@ struct TalerButtonStyle: ButtonStyle { let hasBadge = badge.count > 0 let buttonLabel = configuration.label .multilineTextAlignment(aligned) - .accessibilityFont(.title3) // narrow ? .title3 : .title2 + .talerFont(.title3) // narrow ? .title3 : .title2 .frame(maxWidth: narrow ? nil : .infinity, alignment: aligned2) .padding(.vertical, 10) .padding(.horizontal, hasBadge ? 0 : 6) @@ -184,7 +184,7 @@ struct TalerButtonStyle: ButtonStyle { buttonLabel } else { let badgeV = Image(systemName: badge) - .accessibilityFont(.caption) + .talerFont(.caption) HStack(alignment: .top, spacing: 0) { badgeV.foregroundColor(.clear) buttonLabel diff --git a/TalerWallet1/Views/HelperViews/CopyShare.swift b/TalerWallet1/Views/HelperViews/CopyShare.swift @@ -39,7 +39,7 @@ struct CopyButton: View { } } } - .accessibilityFont(.body) + .talerFont(.body) .disabled(!isEnabled) } } @@ -66,7 +66,7 @@ struct ShareButton: View { Text("Share") } } - .accessibilityFont(.body) + .talerFont(.body) .disabled(!isEnabled) } } diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift @@ -42,7 +42,7 @@ struct ShortcutButton: View { Button(action: { action(shortcut, currencyField)} ) { Text(title) .lineLimit(1) - .accessibilityFont(.callout) + .talerFont(.callout) } // .frame(maxWidth: .infinity) .disabled(isDisabled(shortie: shortie)) @@ -82,7 +82,7 @@ struct CurrencyInputView: View { VStack (alignment: .center) { // center shortcut buttons HStack { Text(title) - .accessibilityFont(.title3) + .talerFont(.title3) .accessibilityAddTraits(.isHeader) .accessibilityRemoveTraits(.isStaticText) Spacer() @@ -91,7 +91,7 @@ struct CurrencyInputView: View { .frame(maxWidth: .infinity, alignment: .trailing) .foregroundColor(WalletColors().fieldForeground) // text color .background(WalletColors().fieldBackground) - .accessibilityFont(.title2) + .talerFont(.title2) .textFieldStyle(.roundedBorder) .onTapGesture { if useShortcut != 0 { diff --git a/TalerWallet1/Views/HelperViews/LoadingView.swift b/TalerWallet1/Views/HelperViews/LoadingView.swift @@ -40,7 +40,7 @@ struct LoadingView: View { Spacer() } .frame(maxWidth: .infinity) - .accessibilityFont(.title) + .talerFont(.title) .navigationTitle("Loading…") .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) } diff --git a/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift b/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift @@ -30,7 +30,7 @@ struct QRCodeDetailView: View { comment: "Either (copy/share the payment link to the payee)") Text(either) .multilineTextAlignment(.leading) - .accessibilityFont(.title3) + .talerFont(.title3) // .padding(.vertical) .listRowSeparator(.hidden) @@ -43,7 +43,7 @@ struct QRCodeDetailView: View { : String(localized: "the payment link to the payee, or") Text(otherParty) .multilineTextAlignment(.leading) - .accessibilityFont(.title3) + .talerFont(.title3) .listRowSeparator(.hidden) HStack { @@ -60,7 +60,7 @@ struct QRCodeDetailView: View { comment: "e.g. '$ 7.41'") Text(hintStr) .fixedSize(horizontal: false, vertical: true) // wrap in scrollview - .accessibilityFont(.title3) + .talerFont(.title3) } } } diff --git a/TalerWallet1/Views/HelperViews/SelectDays.swift b/TalerWallet1/Views/HelperViews/SelectDays.swift @@ -39,7 +39,7 @@ struct SelectDays: View { .accessibilityLabel("Choose the expiration duration") .accessibilityAddTraits(.isHeader) .accessibilityRemoveTraits(.isStaticText) - .accessibilityFont(.title3) + .talerFont(.title3) HStack { Button(action: oneDayAction) { if developerMode { diff --git a/TalerWallet1/Views/HelperViews/TextFieldAlert.swift b/TalerWallet1/Views/HelperViews/TextFieldAlert.swift @@ -19,7 +19,7 @@ struct TextFieldAlert: ViewModifier { if isPresented { VStack { Text(title) - .accessibilityFont(.headline) + .talerFont(.headline) .accessibilityAddTraits(.isHeader) .accessibilityRemoveTraits(.isStaticText) .padding() @@ -39,7 +39,7 @@ struct TextFieldAlert: ViewModifier { action(text) withAnimation { isPresented.toggle() } } -// .accessibilityFont(.talerBody) TODO: check +// .talerFont(.talerBody) TODO: check Spacer() } } diff --git a/TalerWallet1/Views/HelperViews/ToSButtonView.swift b/TalerWallet1/Views/HelperViews/ToSButtonView.swift @@ -21,7 +21,7 @@ struct ToSButtonView: View { : p2p ? String(localized: "You must accept the Payment Service Provider's Terms of Service first before you can receive electronic cash in your wallet.", comment: "P2P Receive") : String(localized: "You must accept the Payment Service Provider's Terms of Service first before you can use it to withdraw electronic cash to your wallet.") Text(hint) - .accessibilityFont(.body) + .talerFont(.body) .multilineTextAlignment(.leading) .padding() NavigationLink(destination: LazyView { diff --git a/TalerWallet1/Views/HelperViews/TransactionButton.swift b/TalerWallet1/Views/HelperViews/TransactionButton.swift @@ -53,7 +53,7 @@ struct TransactionButton: View { Image(systemName: imageName) } } - .accessibilityFont(.title2) + .talerFont(.title2) .frame(maxWidth: .infinity) }) .buttonStyle(.bordered) diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -21,7 +21,7 @@ struct MainView: View { @Binding var soundPlayed: Bool @EnvironmentObject private var controller: Controller - @AppStorage("talerFont") var talerFont: Int = 0 // extension mustn't define this, so it must be here + @AppStorage("talerFontIndex") var talerFontIndex: Int = 0 // extension mustn't define this, so it must be here @AppStorage("playSoundsI") var playSoundsI: Int = 1 // extension mustn't define this, so it must be here @AppStorage("playSoundsB") var playSoundsB: Bool = true @@ -38,7 +38,7 @@ struct MainView: View { #endif Group { if controller.backendState == .ready { - Content(logger: logger, stack: stack.push("Content"), talerFont: $talerFont) + Content(logger: logger, stack: stack.push("Content"), talerFontIndex: $talerFontIndex) .onAppear() { #if DEBUG if playSoundsI != 0 && playSoundsB && !soundPlayed { @@ -84,7 +84,7 @@ extension MainView { let stack: CallStack @State private var shouldReloadBalances = 0 @State private var balances: [Balance] = [] - @Binding var talerFont: Int + @Binding var talerFontIndex: Int @AppStorage("minimalistic") var minimalistic: Bool = false @EnvironmentObject private var controller: Controller @EnvironmentObject private var model: WalletModel diff --git a/TalerWallet1/Views/Main/WalletEmptyView.swift b/TalerWallet1/Views/Main/WalletEmptyView.swift @@ -17,7 +17,7 @@ struct WalletEmptyView: View { List { Section { Text("There is no digital cash in your wallet.") - .accessibilityFont(.title3) + .talerFont(.title3) .listRowSeparator(.hidden) let title = String(localized: "LinkTitle_Test_Money", defaultValue: "Get some test money") Link(title, destination: URL(string: DEMOBANK)!) @@ -27,11 +27,11 @@ struct WalletEmptyView: View { } Section { Text("Just register a test account in the demo bank, then withdraw some electronic cash.") - .accessibilityFont(.body) + .talerFont(.body) } } .listStyle(myListStyle.style).anyView - .accessibilityFont(.title2) + .talerFont(.title2) .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) .onAppear() { DebugViewC.shared.setViewID(VIEW_EMPTY, stack: stack.push("onAppear")) // 10 diff --git a/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift @@ -62,12 +62,12 @@ struct P2PSubjectV: View { Spacer() Text(label) .foregroundColor(.red) - .accessibilityFont(.body) + .talerFont(.body) } } if !minimalistic { Text("Enter subject:") // Purpose - .accessibilityFont(.title3) + .talerFont(.title3) .accessibilityAddTraits(.isHeader) .accessibilityRemoveTraits(.isStaticText) .padding(.top) @@ -81,7 +81,7 @@ struct P2PSubjectV: View { .focused($isFocused) // .lineLimit(2...5) // lineLimit' is only available in iOS 16.0 or newer } } // Group for iOS16+ & iOS15 - .accessibilityFont(.title2) + .talerFont(.title2) .foregroundColor(WalletColors().fieldForeground) // text color .background(WalletColors().fieldBackground) .textFieldStyle(.roundedBorder) @@ -95,7 +95,7 @@ struct P2PSubjectV: View { HStack{ Spacer() Text(verbatim: "\(summary.count)/100") - .accessibilityFont(.body) + .talerFont(.body) .accessibilityValue("\(summary.count) characters of 100") } // maximum 100 characters diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift b/TalerWallet1/Views/Peer2peer/SendAmount.swift @@ -83,7 +83,7 @@ struct SendAmount: View { let disabled = insufficient || amountToTransfer.isZero ScrollView { VStack(alignment: .trailing) { Text("Available:\t\(available)") - .accessibilityFont(.title3) + .talerFont(.title3) .padding(.bottom, 2) CurrencyInputView(amount: $amountToTransfer, available: amountAvailable, @@ -92,7 +92,7 @@ struct SendAmount: View { shortcutAction: shortcutAction) Text(insufficient ? insufficientLabel : feeLabel) - .accessibilityFont(.body) + .talerFont(.body) .foregroundColor(.red) .padding(4) NavigationLink(destination: inputDestination) { Text("Next") } diff --git a/TalerWallet1/Views/Settings/SettingsItem.swift b/TalerWallet1/Views/Settings/SettingsItem.swift @@ -27,17 +27,17 @@ struct SettingsItem<Content: View>: View { .id(id1) .frame(maxWidth: .infinity, alignment: .leading) .foregroundColor(foreColor) - .accessibilityFont(.title2) + .talerFont(.title2) .padding([.bottom], 0.01) if let desc = description { Text(desc) .id(id1 == nil ? nil : id1! + "_T") .frame(maxWidth: .infinity, alignment: .leading) - .accessibilityFont(.caption) + .talerFont(.caption) } }.id(id1 == nil ? nil : id1! + "_V") content() - .accessibilityFont(.body) + .talerFont(.body) }.id(id1 == nil ? nil : id1! + "_H") .accessibilityElement(children: .combine) .padding([.bottom], 4) @@ -62,7 +62,7 @@ struct SettingsToggle: View { .id(id1) // .accessibilityLabel(name) .accessibility(sortPriority: 1) - .accessibilityFont(.title2) + .talerFont(.title2) .onChange(of: value) { value in action() } @@ -72,7 +72,7 @@ struct SettingsToggle: View { .id(id1 == nil ? nil : id1! + "_T") .frame(maxWidth: .infinity, alignment: .leading) .accessibility(sortPriority: 0) - .accessibilityFont(.caption) + .talerFont(.caption) } } .accessibilityElement(children: .combine) @@ -96,7 +96,7 @@ struct SettingsFont: View { Text(fonts[index]).tag(index) }) }) - .accessibilityFont(.title2) + .talerFont(.title2) .pickerStyle(.menu) .onAppear() { withAnimation { selectedFont = value } @@ -114,12 +114,12 @@ struct SettingsStyle: View { var body: some View { HStack { Text(title) - .accessibilityFont(.title2) + .talerFont(.title2) Spacer() Picker(selection: $myListStyle) { ForEach(MyListStyle.allCases, id: \.self) { Text($0.displayName.capitalized).tag($0) - .accessibilityFont(.title2) + .talerFont(.title2) } } label: {} .pickerStyle(.menu) @@ -148,10 +148,10 @@ struct SettingsSpeaker: View { VStack { HStack { Text(name) - .accessibilityFont(.title2) + .talerFont(.title2) Text(verbatim: " ") - .accessibilityFont(.largeTitle) - Spacer() + .talerFont(.largeTitle) + .frame(maxWidth: .infinity, alignment: .trailing) Button { if value > 0 { value = -1 @@ -162,14 +162,14 @@ struct SettingsSpeaker: View { } } label: { Image(systemName: image.0) - .accessibilityFont(.largeTitle) + .talerFont(.largeTitle) } } if let desc = description { Text(desc) .frame(maxWidth: .infinity, alignment: .leading) - .accessibilityFont(.caption) + .talerFont(.caption) } } .accessibilityElement(children: .combine) diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift @@ -33,7 +33,7 @@ struct SettingsView: View { @AppStorage("playSoundsB") var playSoundsB: Bool = true @AppStorage("shouldShowWarning") var shouldShowWarning: Bool = true // @AppStorage("increaseContrast") var increaseContrast: Bool = false - @AppStorage("talerFont") var talerFont: Int = 0 + @AppStorage("talerFontIndex") var talerFontIndex: Int = 0 @AppStorage("developDelay") var developDelay: Bool = false @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic @AppStorage("minimalistic") var minimalistic: Bool = false @@ -72,8 +72,8 @@ struct SettingsView: View { @State private var listID = UUID() func redraw(_ newFont: Int) -> Void { - if newFont != talerFont { - talerFont = newFont + if newFont != talerFontIndex { + talerFontIndex = newFont withAnimation { listID = UUID() } } } @@ -131,7 +131,7 @@ struct SettingsView: View { SettingsToggle(name: String(localized: "Show Warnings"), value: $shouldShowWarning, id1: "warnings", description: hideDescriptions ? nil : String(localized: "For Delete, Fail & Abort buttons")) .id("showWarnings") -// SettingsFont(title: String(localized: "Font:"), value: talerFont, action: redraw) +// SettingsFont(title: String(localized: "Font:"), value: talerFontIndex, action: redraw) // .id("font") SettingsStyle(title: String(localized: "Liststyle:"), myListStyle: $myListStyle) .id("liststyle") diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift @@ -46,7 +46,7 @@ struct P2pPayURIView: View { let accessibilityDate = TalerDater.accessibilityDate(date) ?? dateString let accessibilityLabel = String(localized: "Expires: \(accessibilityDate)") Text("Expires: \(dateString)") - .accessibilityFont(.body) + .talerFont(.body) .accessibilityLabel(accessibilityLabel) // .foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary) } diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift @@ -54,7 +54,7 @@ struct P2pReceiveURIView: View { let accessibilityDate = TalerDater.accessibilityDate(date) ?? dateString let accessibilityLabel = String(localized: "Expires: \(accessibilityDate)") Text("Expires: \(dateString)") - .accessibilityFont(.body) + .talerFont(.body) .accessibilityLabel(accessibilityLabel) // .foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary) } diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateView.swift b/TalerWallet1/Views/Sheets/Payment/PayTemplateView.swift @@ -74,7 +74,7 @@ struct PayTemplateView: View { // TODO: payment: popup with all possible exchanges, check fees } else if let balanceDetails = preparePayResult.balanceDetails { // Insufficient Text("You don't have enough \(currency)") - .accessibilityFont(.body) + .talerFont(.body) ThreeAmountsV(stack: stack.push(), topTitle: topTitle, topAbbrev: topAbbrev, @@ -90,7 +90,7 @@ struct PayTemplateView: View { } else { // TODO: Error - neither effective nor balanceDetails Text("Error") - .accessibilityFont(.body) + .talerFont(.body) } } .listStyle(myListStyle.style).anyView diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift @@ -51,7 +51,7 @@ struct PaymentView: View { // TODO: payment: popup with all possible exchanges, check fees } else if let balanceDetails = preparePayResult.balanceDetails { // Insufficient Text("You don't have enough \(currency)") - .accessibilityFont(.headline) + .talerFont(.headline) ThreeAmountsV(stack: stack.push(), topTitle: topTitle, topAbbrev: topAbbrev, @@ -67,7 +67,7 @@ struct PaymentView: View { } else { // TODO: Error - neither effective nor balanceDetails Text("Error") - .accessibilityFont(.body) + .talerFont(.body) } } .listStyle(myListStyle.style).anyView diff --git a/TalerWallet1/Views/Sheets/Sheet.swift b/TalerWallet1/Views/Sheets/Sheet.swift @@ -10,7 +10,7 @@ struct Sheet: View { private let symLog = SymLogV(0) @Environment(\.dismiss) var dismiss // call dismiss() to get rid of the sheet @EnvironmentObject private var debugViewC: DebugViewC - @AppStorage("talerFont") var talerFont: Int = 0 + @AppStorage("talerFontIndex") var talerFontIndex: Int = 0 var sheetView: AnyView @@ -33,12 +33,12 @@ struct Sheet: View { .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) } .navigationViewStyle(.stack) - .talerNavBar(talerFont: talerFont) + .talerNavBar(talerFontIndex: talerFontIndex) .overlay(alignment: .top) { // Show the viewID on top of the sheet's NavigationView Text(idString) .foregroundColor(.purple) - .font(.system(size: 11)) // no accessibilityFont + .font(.system(size: 11)) // no talerFont .monospacedDigit() .edgesIgnoringSafeArea(.top) .id("sheetID") diff --git a/TalerWallet1/Views/Sheets/URLSheet.swift b/TalerWallet1/Views/Sheets/URLSheet.swift @@ -41,7 +41,7 @@ struct URLSheet: View { default: // Error view VStack { Text("unknown command") - .accessibilityFont(.title) + .talerFont(.title) Text(controller.messageForSheet ?? urlToOpen.absoluteString) } .navigationTitle(navTitle) diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawTOSView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawTOSView.swift @@ -100,7 +100,7 @@ extension WithdrawTOSView { let term9 = term8.replacingOccurrences(of: " ****", with: "\n****") // special for "Terms of Service:" Section { Text(term9) - .accessibilityFont(.footnote) + .talerFont(.footnote) .foregroundColor(Color(UIColor.label)) } } // for @@ -127,7 +127,7 @@ extension WithdrawTOSView { Text(languageName ?? code) } } - .accessibilityFont(.title3) + .talerFont(.title3) .pickerStyle(.menu) .onAppear() { withAnimation { selectedLanguage = language } @@ -157,7 +157,7 @@ extension WithdrawTOSView { let term9 = term8.replacingOccurrences(of: " ****", with: "\n****") // special for "Terms of Service:" Section { Text(term9) - .accessibilityFont(.footnote) + .talerFont(.footnote) .foregroundColor(Color(UIColor.label)) } } // for diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift b/TalerWallet1/Views/Transactions/ManualDetailsV.swift @@ -24,7 +24,7 @@ struct AccountPicker: View { .tag(index) }) }) - .accessibilityFont(.title3) + .talerFont(.title3) .pickerStyle(.menu) .onAppear() { withAnimation { selectedAccount = value } @@ -165,7 +165,7 @@ struct ManualDetailsV: View { Spacer() } .listRowSeparator(.automatic) }.id(listID) - .accessibilityFont(.body) + .talerFont(.body) } else { // YIKES No exchangeCreditAccountDetails } diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift @@ -74,13 +74,13 @@ struct ThreeAmountsV: View { Section { if let summary { Text(summary) - .accessibilityFont(.title3) + .talerFont(.title3) .lineLimit(4) .padding(.bottom) } if let merchant { Text(merchant) - .accessibilityFont(.title3) + .talerFont(.title3) .lineLimit(4) .padding(.bottom) } @@ -110,12 +110,12 @@ struct ThreeAmountsV: View { VStack(alignment: .leading) { Text(minimalistic ? "Payment provider:" : "Using payment service provider:") .multilineTextAlignment(.leading) - .accessibilityFont(.body) + .talerFont(.body) HStack { Spacer() Text(baseURL.trimURL()) .multilineTextAlignment(.center) - .accessibilityFont(large ? .title3 : .body) + .talerFont(large ? .title3 : .body) // .fontWeight(large ? .medium : .regular) // @available(iOS 16.0, *) .foregroundColor(labelColor) } @@ -128,7 +128,7 @@ struct ThreeAmountsV: View { } header: { if !minimalistic { Text("Summary") - .accessibilityFont(.title3) + .talerFont(.title3) } } } diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift b/TalerWallet1/Views/Transactions/TransactionRowView.swift @@ -28,9 +28,9 @@ struct IconBadge: View { .foregroundColor(.clear) Image(systemName: imageName) .foregroundColor(foreColor) - }.accessibilityFont(.largeTitle) + }.talerFont(.largeTitle) Image(systemName: badgeName) - .accessibilityFont(.caption) + .talerFont(.caption) .foregroundColor((needsKYC || shouldConfirm) ? .red : .clear) }.accessibilityHidden(true) } @@ -84,13 +84,13 @@ struct TransactionRowView: View { let centerTop = Text(topString) .foregroundColor(textColor) .strikethrough(!doneOrPending, color: .red) - .accessibilityFont(.headline) + .talerFont(.headline) // .fontWeight(.medium) iOS 16 .padding(.bottom, -2.0) .accessibilityLabel(doneOrPending ? topString : topString + ", canceled") let centerBottom = Text(dateString) .foregroundColor(textColor) - .accessibilityFont(.callout) + .talerFont(.callout) let layout1 = HStack(spacing: 0) { HStack(spacing: -4) { diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift @@ -114,7 +114,7 @@ struct TransactionSummaryV: View { } } } // Suspend + Resume buttons Text(dateString) - .accessibilityFont(.body) + .talerFont(.body) .accessibilityLabel(accessibilityDate) .foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary) .listRowSeparator(.hidden) @@ -136,7 +136,7 @@ struct TransactionSummaryV: View { .multilineTextAlignment(.trailing) } } .listRowSeparator(.automatic) - .accessibilityFont(.title) + .talerFont(.title) TypeDetail(stack: stack.push(), transaction: $transaction, hasDone: doneAction != nil) @@ -253,7 +253,7 @@ struct TransactionSummaryV: View { case .dummy(_): let title = EMPTYSTRING Text(title) - .accessibilityFont(.body) + .talerFont(.body) HStack { Spacer() RotatingTaler(size: 100, rotationEnabled: $rotationEnabled) @@ -334,7 +334,7 @@ struct TransactionSummaryV: View { let accessibilityDate = TalerDater.accessibilityDate(date) ?? dateString let accessibilityLabel = String(localized: "Expires: \(accessibilityDate)") Text("Expires: \(dateString)") - .accessibilityFont(.body) + .talerFont(.body) .accessibilityLabel(accessibilityLabel) // .foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary) } @@ -345,13 +345,13 @@ struct TransactionSummaryV: View { if hasDone { Text("QR code and link can also be scanned or copied / shared from Transactions later.") .multilineTextAlignment(.leading) - .accessibilityFont(.subheadline) + .talerFont(.subheadline) .padding(.top) } } else { Text("This transaction is not yet ready...") .multilineTextAlignment(.leading) - .accessibilityFont(.subheadline) + .talerFont(.subheadline) } } let colon = ":" @@ -386,7 +386,7 @@ struct TransactionSummaryV: View { } else if keys.contains(EXCHANGEBASEURL) { if let baseURL = details[EXCHANGEBASEURL] { Text("from \(baseURL.trimURL())") - .accessibilityFont(.title2) + .talerFont(.title2) .padding(.bottom) } } diff --git a/TalerWallet1/Views/Transactions/TransactionsEmptyView.swift b/TalerWallet1/Views/Transactions/TransactionsEmptyView.swift @@ -20,7 +20,7 @@ struct TransactionsEmptyView: View { Section { Text("There are no transactions for \(currency).") } - .accessibilityFont(.title2) + .talerFont(.title2) } .listStyle(myListStyle.style).anyView // .padding(.vertical)