Skip to content

Commit

Permalink
feat: 🎸 Add 72 fonts (#334)
Browse files Browse the repository at this point in the history
* chore: 🤖 Add missing semicolon in translation file

* chore: 🤖 Remove duplicated entries in translation file

* feat: 🎸 Add 72 fonts
  • Loading branch information
billzhou0223 authored Oct 1, 2021
1 parent 888f83d commit e9192ae
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Apps/Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
1F26DCFA261A5CD9006C43B1 /* FioriButtonContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F26DCF9261A5CD9006C43B1 /* FioriButtonContentView.swift */; };
1F3C92F125DF12C100A99A07 /* ListPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F3C92F025DF12C100A99A07 /* ListPicker.swift */; };
1F90888C261A59820015A84D /* FioriButtonExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F90888B261A59820015A84D /* FioriButtonExample.swift */; };
1FC30412270540FB004BEE00 /* 72-Fonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC30411270540FB004BEE00 /* 72-Fonts.swift */; };
1FC30414270541BF004BEE00 /* FioriThemeManagerContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC30413270541BF004BEE00 /* FioriThemeManagerContentView.swift */; };
1FF3662E264C662A00AB8BD8 /* DimensionSelector+Chart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FF3662D264C662A00AB8BD8 /* DimensionSelector+Chart.swift */; };
691DE21925F2A30B00094D4A /* KPIViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 691DE21825F2A30B00094D4A /* KPIViewExample.swift */; };
692F338B26556A6A009B98DA /* SideBarExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 692F338A26556A6A009B98DA /* SideBarExample.swift */; };
Expand Down Expand Up @@ -204,6 +206,8 @@
1F26DCF9261A5CD9006C43B1 /* FioriButtonContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriButtonContentView.swift; sourceTree = "<group>"; };
1F3C92F025DF12C100A99A07 /* ListPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPicker.swift; sourceTree = "<group>"; };
1F90888B261A59820015A84D /* FioriButtonExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FioriButtonExample.swift; sourceTree = "<group>"; };
1FC30411270540FB004BEE00 /* 72-Fonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "72-Fonts.swift"; sourceTree = "<group>"; };
1FC30413270541BF004BEE00 /* FioriThemeManagerContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriThemeManagerContentView.swift; sourceTree = "<group>"; };
1FF3662D264C662A00AB8BD8 /* DimensionSelector+Chart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DimensionSelector+Chart.swift"; sourceTree = "<group>"; };
691DE21825F2A30B00094D4A /* KPIViewExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KPIViewExample.swift; sourceTree = "<group>"; };
692F338A26556A6A009B98DA /* SideBarExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideBarExample.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -402,6 +406,15 @@
path = FioriButton;
sourceTree = "<group>";
};
1FC3040F2705409C004BEE00 /* FioriThemeManager */ = {
isa = PBXGroup;
children = (
1FC30411270540FB004BEE00 /* 72-Fonts.swift */,
1FC30413270541BF004BEE00 /* FioriThemeManagerContentView.swift */,
);
path = FioriThemeManager;
sourceTree = "<group>";
};
1FF3662C264C662A00AB8BD8 /* DimensionSelector */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -449,6 +462,7 @@
8A55795524C1286E0098003A /* Examples */ = {
isa = PBXGroup;
children = (
1FC3040F2705409C004BEE00 /* FioriThemeManager */,
8A55797824C1293C0098003A /* FioriCharts */,
8A55798824C1293C0098003A /* FioriIntegrationCards */,
8A5579C824C1293C0098003A /* FioriSwiftUICore */,
Expand Down Expand Up @@ -995,6 +1009,7 @@
9996CD00262EB4E8001B99AE /* EULAViewSample.swift in Sources */,
8A557A0824C1293C0098003A /* BundleTestCases.swift in Sources */,
1F3C92F125DF12C100A99A07 /* ListPicker.swift in Sources */,
1FC30414270541BF004BEE00 /* FioriThemeManagerContentView.swift in Sources */,
99942D59261698FC001912C5 /* InfoViewSample.swift in Sources */,
B80DA9BE260C1CC200C0B2E9 /* ListDataProtocol.swift in Sources */,
B84D24EE2652F343007F2373 /* ObjectHeaderViewScenarios.swift in Sources */,
Expand All @@ -1005,6 +1020,7 @@
99942D572616980A001912C5 /* OnboardingExamples.swift in Sources */,
8A557A2424C12F380098003A /* ChartDetailView.swift in Sources */,
8A5579D024C1293C0098003A /* SettingsLine.swift in Sources */,
1FC30412270540FB004BEE00 /* 72-Fonts.swift in Sources */,
8A557A2024C12C940098003A /* IntegrationCardsContentView.swift in Sources */,
B84D24ED2652F343007F2373 /* HeaderChartExample.swift in Sources */,
B846F94626815CC90085044B /* ContactItemExample.swift in Sources */,
Expand Down
6 changes: 5 additions & 1 deletion Apps/Examples/Examples/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import SwiftUI
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
true

Font.registerFioriFonts()

return true
}

// MARK: UISceneSession Lifecycle
Expand Down
4 changes: 4 additions & 0 deletions Apps/Examples/Examples/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ struct ContentView: View {
destination: CoreContentView()) {
Text("Core Elements")
}
NavigationLink(
destination: FioriThemeManagerContentView()) {
Text("Theme Manager")
}
}
.navigationBarTitle("Examples")
.navigationViewStyle(StackNavigationViewStyle())
Expand Down
88 changes: 88 additions & 0 deletions Apps/Examples/Examples/FioriThemeManager/72-Fonts.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import Foundation
import SwiftUI

struct FioriFonts: View {
let textStyles = Font.FioriTextStyle.allCases

@State var showSettings = false
@State var fontWeight = Font.Weight.regular
@State var isItalic = false
@State var isCondensed = false
@State var sizeCategory = ContentSizeCategory.large

var body: some View {
List {
ForEach(0 ..< textStyles.count) { index in
let textStyle = textStyles[index]
Text(String(describing: textStyle))
.font(fioriFont(textStyle))
}
}
.environment(\.sizeCategory, sizeCategory)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
showSettings.toggle()
} label: {
Image(systemName: "gearshape")
}
}
}
.sheet(isPresented: $showSettings) {
Settings(fontWeight: $fontWeight, isItalic: $isItalic, isCondensed: $isCondensed, sizeCategory: $sizeCategory)
}
}

func fioriFont(_ textStyle: Font.FioriTextStyle) -> Font {
var font: Font = self.isCondensed ? .fioriCondensed(forTextStyle: textStyle) : .fiori(forTextStyle: textStyle)

font = font.weight(self.fontWeight)

if self.isItalic {
font = font.italic()
}

return font
}
}

extension FioriFonts {
struct Settings: View {
@Binding var fontWeight: Font.Weight
@Binding var isItalic: Bool
@Binding var isCondensed: Bool
@Binding var sizeCategory: ContentSizeCategory

var body: some View {
NavigationView {
List {
Picker("Font Weight", selection: $fontWeight) {
ForEach(0 ..< Font.Weight.allCases.count) { index in
let weight = Font.Weight.allCases[index]
Text(String(describing: weight))
.tag(weight)
}
}

Toggle("Italic", isOn: $isItalic)

Toggle("Condensed", isOn: $isCondensed)

Picker("Dynamic Type", selection: $sizeCategory) {
ForEach(0 ..< ContentSizeCategory.allCases.count) { index in
let sizeCategory = ContentSizeCategory.allCases[index]
Text(String(describing: sizeCategory))
.tag(sizeCategory)
}
}
}
}
}
}
}

extension Font.Weight: CaseIterable {
public static var allCases: [Font.Weight] {
[.black, .bold, .heavy, .light, .medium, .regular, .semibold, .thin, .light, .ultraLight]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation
import SwiftUI

struct FioriThemeManagerContentView: View {
var body: some View {
List {
NavigationLink(
destination: FioriFonts()) {
Text("72 Fonts")
}
}
}
}
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ let package = Package(
),
.target(
name: "FioriThemeManager",
dependencies: []
dependencies: [],
resources: [
.process("72-Fonts/Resources")
]
),
.testTarget(
name: "FioriSwiftUITests",
Expand Down
Loading

0 comments on commit e9192ae

Please sign in to comment.