Skip to content

Commit fadbc3b

Browse files
committed
Allow SwiftUI Colors and Fonts to be nullable
1 parent 1c0d4b8 commit fadbc3b

File tree

10 files changed

+30
-20
lines changed

10 files changed

+30
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [4.3.1] - 2021-11-09
8+
## Changed
9+
- Allow Color and Font for typography styles in SwiftUI to be nullable.
10+
711
## [4.3.0] - 2021-11-09
812
## Added
913
- Support for disabling font scaling either system-wide and/or per-font.

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/TypographyKit.xcscheme

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/TypographyKit.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
isa = PBXProject;
281281
attributes = {
282282
LastSwiftUpdateCheck = 0720;
283-
LastUpgradeCheck = 1220;
283+
LastUpgradeCheck = 1310;
284284
ORGANIZATIONNAME = CocoaPods;
285285
TargetAttributes = {
286286
607FACCF1AFB9204008FA782 = {
@@ -611,6 +611,7 @@
611611
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
612612
INFOPLIST_FILE = TypographyKit/Info.plist;
613613
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
614+
MARKETING_VERSION = 4.3.1;
614615
MODULE_NAME = ExampleApp;
615616
PRODUCT_BUNDLE_IDENTIFIER = "com.rwbutler.TypographyKit-Example";
616617
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -626,6 +627,7 @@
626627
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
627628
INFOPLIST_FILE = TypographyKit/Info.plist;
628629
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
630+
MARKETING_VERSION = 4.3.1;
629631
MODULE_NAME = ExampleApp;
630632
PRODUCT_BUNDLE_IDENTIFIER = "com.rwbutler.TypographyKit-Example";
631633
PRODUCT_NAME = "$(TARGET_NAME)";

Example/TypographyKit.xcodeproj/xcshareddata/xcschemes/TypographyKit-Example.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1220"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Example/TypographyKit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

TypographyKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'TypographyKit'
3-
s.version = '4.3.0'
3+
s.version = '4.3.1'
44
s.summary = 'Consistent & accessible visual styling on iOS with support for Dynamic Type'
55
s.swift_version = '5.0'
66
s.description = <<-DESC

TypographyKit/Classes/FontTextStyleParser.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ struct FontTextStyleParser {
3030
private extension FontTextStyleParser {
3131

3232
mutating func parse(_ key: String, _ value: [String: Any]) {
33-
//Already Parsed
34-
if typographyFontStyles[key] != nil { return }
35-
36-
//Already found to be invalid
37-
if invalidStyles[key] != nil { return }
38-
33+
// Already Parsed
34+
if typographyFontStyles[key] != nil {
35+
return
36+
}
37+
// Already found to be invalid
38+
if invalidStyles[key] != nil {
39+
return
40+
}
3941
backTrace.append(key)
4042
switch parseFontTextStyle(key, value) {
4143
case .success(let color):

TypographyKit/Classes/TypographyKitViewControllerDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
import Foundation
99

10-
@objc public protocol TypographyKitViewControllerDelegate: class {
10+
@objc public protocol TypographyKitViewControllerDelegate: AnyObject {
1111
@objc func viewControllerDidFinish()
1212
}

TypographyKit/Classes/ViewAdditions.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,26 @@ private struct TypographyStyle: ViewModifier {
1515

1616
@Environment(\.sizeCategory) var sizeCategory
1717

18-
var color: Color {
18+
var color: Color? {
1919
guard let textColor = Typography(for: style)?.textColor else {
20-
return Color.black
20+
return nil
2121
}
2222
return Color(textColor)
2323
}
2424

25-
var font: Font {
25+
var font: Font? {
2626
guard let font = Typography(for: style)?.font() else {
27-
return Font.body
27+
return nil
2828
}
2929
return Font.custom(font.fontName, size: font.pointSize)
3030
}
3131

3232
var style: UIFont.TextStyle
3333

3434
func body(content: Content) -> some View {
35-
return content.font(font).foregroundColor(color)
35+
return content
36+
.font(font)
37+
.foregroundColor(color)
3638
}
3739

3840
}

0 commit comments

Comments
 (0)