[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 11/19: Settings: Font: AtkinsonHyperlegible
From: |
gnunet |
Subject: |
[taler-taler-ios] 11/19: Settings: Font: AtkinsonHyperlegible |
Date: |
Sat, 02 Sep 2023 22:01:12 +0200 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit c521342d7615b1ae865b432faffa38effbe4f00c
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Aug 31 21:01:42 2023 +0200
Settings: Font: AtkinsonHyperlegible
---
TalerWallet1/Controllers/Controller.swift | 1 +
TalerWallet1/Helper/Font+Taler.swift | 106 +++++++++++++++++++++++++
TalerWallet1/Views/Settings/SettingsItem.swift | 41 ++++++++++
TalerWallet1/Views/Settings/SettingsView.swift | 2 +
4 files changed, 150 insertions(+)
diff --git a/TalerWallet1/Controllers/Controller.swift
b/TalerWallet1/Controllers/Controller.swift
index e02f0a3..90de1d4 100644
--- a/TalerWallet1/Controllers/Controller.swift
+++ b/TalerWallet1/Controllers/Controller.swift
@@ -33,6 +33,7 @@ class Controller: ObservableObject {
@Published var backendState: BackendState = .none // only used for
launch animation
@AppStorage("playSounds") var playSounds: Int = 0 // extension
mustn't define this, so it must be here
+ @AppStorage("talerFonts") var talerFonts: Int = 0 // extension
mustn't define this, so it must be here
let logger = Logger (subsystem: "net.taler.gnu", category: "Controller")
let player = AVQueuePlayer()
diff --git a/TalerWallet1/Helper/Font+Taler.swift
b/TalerWallet1/Helper/Font+Taler.swift
new file mode 100644
index 0000000..1f0317e
--- /dev/null
+++ b/TalerWallet1/Helper/Font+Taler.swift
@@ -0,0 +1,106 @@
+/*
+ * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * See LICENSE.md
+ */
+import SwiftUI
+
+// Use enums for multiple font types and functions for the set custom font.
+
+fileprivate let REGULAR = "AtkinsonHyperlegible-Regular"
+fileprivate let ITALIC = "AtkinsonHyperlegible-Italic"
+fileprivate let BOLD = "AtkinsonHyperlegible-Bold"
+fileprivate let BOLDITALIC = "AtkinsonHyperlegible-BoldItalic"
+
+extension Font {
+ enum TalerFont {
+ case regular
+ case italic
+ case bold
+ case boldItalic
+ case custom(String)
+
+ var value: String {
+ switch self {
+ case .regular: return REGULAR
+ case .italic: return ITALIC
+ case .bold: return BOLD
+ case .boldItalic: return BOLDITALIC
+
+ case .custom(let name):
+ return name
+ }
+ }
+ }
+
+ static func talerFont(_ type: TalerFont, size: CGFloat = 17) -> Font {
+ return .custom(type.value, size: size)
+ }
+
+ static var talerLargeTitle: Font {
+ Controller.shared.talerFonts == 0 ? .largeTitle :
+ .custom(REGULAR, size: 38, relativeTo: .largeTitle)
+ } // 34 -> 38
+ static var talerTitle: Font {
+ Controller.shared.talerFonts == 0 ? .title :
+ .custom(REGULAR, size: 31, relativeTo: .title)
+ } // 28 -> 31
+ static var talerTitle2: Font {
+ Controller.shared.talerFonts == 0 ? .title2 :
+ .custom(REGULAR, size: 25, relativeTo: .title2)
+ } // 22 -> 25
+ static var talerTitle3: Font {
+ Controller.shared.talerFonts == 0 ? .title3 :
+ .custom(REGULAR, size: 23, relativeTo: .title3)
+ } // 20 -> 23
+ static var talerHeadline: Font {
+ Controller.shared.talerFonts == 0 ? .headline :
+ .custom(BOLD, size: 19, relativeTo: .headline)
+ } // 17 bold -> 19 bold
+ static var talerBody: Font {
+ Controller.shared.talerFonts == 0 ? .body :
+ .custom(REGULAR, size: 19, relativeTo: .body)
+ } // 17 -> 19
+ static var talerCallout: Font {
+ Controller.shared.talerFonts == 0 ? .callout :
+ .custom(REGULAR, size: 18, relativeTo: .callout)
+ } // 16 -> 18
+ static var talerSubheadline: Font {
+ Controller.shared.talerFonts == 0 ? .subheadline :
+ .custom(REGULAR, size: 17, relativeTo: .subheadline)
+ } // 15 -> 17
+ static var talerFootnote: Font {
+ Controller.shared.talerFonts == 0 ? .footnote :
+ .custom(REGULAR, size: 15, relativeTo: .footnote)
+ } // 13 -> 15
+ static var talerCaption: Font {
+ Controller.shared.talerFonts == 0 ? .caption :
+ .custom(REGULAR, size: 13, relativeTo: .caption)
+ } // 12 -> 13
+ static var talerCaption2: Font {
+ Controller.shared.talerFonts == 0 ? .caption2 :
+ .custom(REGULAR, size: 12, relativeTo: .caption2)
+ } // 11 -> 12
+}
+
+struct ContentViewFonts: View {
+ var body: some View {
+ VStack {
+ Text("Text demo")
+ .font(.talerFont(.regular))
+ Text("Text demo")
+ .font(.talerFont(.italic))
+ Text("Text demo")
+ .font(.talerFont(.bold))
+ Text("Text demo")
+ .font(.talerFont(.boldItalic))
+
+ Text("Text demo")
+ .font(.talerBody)
+
+ }
+ }
+}
+
+#Preview("Font View") {
+ ContentViewFonts()
+}
diff --git a/TalerWallet1/Views/Settings/SettingsItem.swift
b/TalerWallet1/Views/Settings/SettingsItem.swift
index a34f2c4..bda253f 100644
--- a/TalerWallet1/Views/Settings/SettingsItem.swift
+++ b/TalerWallet1/Views/Settings/SettingsItem.swift
@@ -56,6 +56,47 @@ struct SettingsToggle: View {
}
}
// MARK: -
+struct SettingsFont: View {
+ var name: String
+ @Binding var value: Int
+ var action: (_ value: Int) -> Void = {value in }
+
+ func fontName(_ value: Int) -> (String, String, String) {
+ return (value == 0) ? ("textformat", String(localized:"System Font"),
String(localized: "Standard iOS Font"))
+ : (value == 1) ? ("textformat.alt", String(localized:"Taler
Font"), String(localized: "Atkinson-Hyperlegible"))
+ : ("placeholdertext.fill", String(localized:"New
Font"), String(localized:"New Font")) // Neumorphism
+ }
+ var body: some View {
+ VStack {
+ let fontName = fontName(value)
+ HStack {
+ Text(name)
+ .font(.talerTitle2)
+ Text(" ")
+ .font(.talerLargeTitle)
+ Spacer()
+ Image(systemName: fontName.0)
+ .font(.talerLargeTitle)
+ .accessibilityLabel(fontName.1)
+ .onTapGesture {
+ if value > 0 {
+ value = 0 // TODO: -1 for Neumorphism
+ } else {
+ value = value + 1
+ }
+ }
+ }
+// .onChange(of: value) { value in
+// action(value)
+// }
+
+ Text(fontName.2)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .font(.talerCaption)
+ }.padding([.bottom], 4)
+ }
+}
+// MARK: -
struct SettingsSpeaker: View {
var name: String
@Binding var value: Int
diff --git a/TalerWallet1/Views/Settings/SettingsView.swift
b/TalerWallet1/Views/Settings/SettingsView.swift
index 7f7dc51..4457dd7 100644
--- a/TalerWallet1/Views/Settings/SettingsView.swift
+++ b/TalerWallet1/Views/Settings/SettingsView.swift
@@ -27,6 +27,7 @@ struct SettingsView: View {
@AppStorage("developerMode") var developerMode: Bool = false
#endif
@AppStorage("playSounds") var playSounds: Int = 0
+ @AppStorage("talerFonts") var talerFonts: Int = 0
@AppStorage("developDelay") var developDelay: Bool = false
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
@@ -73,6 +74,7 @@ struct SettingsView: View {
let walletCore = WalletCore.shared
Group {
List {
+ SettingsFont(name: String(localized: "Font to use"), value:
$talerFonts)
SettingsSpeaker(name: String(localized: "Play Payment
Sounds"), value: $playSounds,
description: String(localized: "After a transaction
finished"))
HStack {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 04/19: Rename, (continued)
- [taler-taler-ios] 04/19: Rename, gnunet, 2023/09/02
- [taler-taler-ios] 02/19: Changed "Invoice" to "Request" (private mode - "Invoice" will be used in business mode post 1.0), roundedBorder for input fields, gnunet, 2023/09/02
- [taler-taler-ios] 08/19: IntegrationTest on test, gnunet, 2023/09/02
- [taler-taler-ios] 13/19: ScopedCurrencyInfo, SuperScriptDigit, gnunet, 2023/09/02
- [taler-taler-ios] 05/19: Comment, gnunet, 2023/09/02
- [taler-taler-ios] 18/19: Nunito Font, gnunet, 2023/09/02
- [taler-taler-ios] 16/19: Rename, fix, gnunet, 2023/09/02
- [taler-taler-ios] 14/19: CurrencyFormatter, gnunet, 2023/09/02
- [taler-taler-ios] 09/19: Accessibility String for Payment Sounds, gnunet, 2023/09/02
- [taler-taler-ios] 12/19: CachePath for data not to be backed up, gnunet, 2023/09/02
- [taler-taler-ios] 11/19: Settings: Font: AtkinsonHyperlegible,
gnunet <=
- [taler-taler-ios] 19/19: Font Settings, gnunet, 2023/09/02
- [taler-taler-ios] 10/19: Comment, gnunet, 2023/09/02
- [taler-taler-ios] 06/19: Rename, gnunet, 2023/09/02
- [taler-taler-ios] 15/19: group, gnunet, 2023/09/02
- [taler-taler-ios] 07/19: secret-token:secret, gnunet, 2023/09/02
- [taler-taler-ios] 17/19: GNU Taler, Taler Wallet, gnunet, 2023/09/02