Skip to content

Commit

Permalink
default font for textStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
wut-prolific committed Apr 18, 2018
1 parent f78f364 commit 0d10d7a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 1 addition & 3 deletions Kumi/Core/Font/FontTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ public final class FontTheme {

public init?(json: JSON) {

guard let bodyNormalTextStyle = TextStyleSet(json: json["bodyNormal"]) else {
return nil
}
let bodyNormalTextStyle = TextStyleSet(json: json["bodyNormal"]) ?? .default

self.bodyNormalTextStyle = bodyNormalTextStyle

Expand Down
8 changes: 7 additions & 1 deletion Kumi/Core/Font/TextStyleSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import Foundation
import Marker

public extension TextStyle {
static public let `default` = TextStyle(font: Font.systemFont(ofSize: 18))
}

public struct TextStyleSet {

public var regular: TextStyle {
Expand All @@ -29,11 +33,13 @@ public struct TextStyleSet {

fileprivate var _emphasis: TextStyle?

public init(normal: TextStyle, strong: TextStyle?, emphasis: TextStyle?) {
public init(normal: TextStyle, strong: TextStyle? = nil, emphasis: TextStyle? = nil) {
self._regular = normal
self._strong = strong ?? normal
self._emphasis = emphasis ?? normal
}

public static let `default` = TextStyleSet(normal: .default)

}

2 changes: 1 addition & 1 deletion Kumi/Core/Kumi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public struct Kumi {

public static func setup(bundle: Bundle) {
let files = bundle.paths(forResourcesOfType: "json", inDirectory: nil)
let jsons = files.flatMap { JSONHelper.readJSON(path: $0) }.filter { !$0["kumi"].isEmpty }
let jsons = files.compactMap { JSONHelper.readJSON(path: $0) }.filter { !$0["kumi"].isEmpty }
for json in jsons {
switch json["kumi"]["type"].stringValue {
case "color":
Expand Down

0 comments on commit 0d10d7a

Please sign in to comment.