Skip to content

Commit ee322a3

Browse files
committed
Add semibold and set it to button
1 parent 72d885a commit ee322a3

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

Demo/Config.swift

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ struct DemoFontProvider: FontProvider {
1616
return font.scaledFont(forTextStyle: .body)
1717
}
1818

19+
var bodySemibold: UIFont {
20+
let font = UIFont.rounded(ofSize: 17, weight: .semibold)
21+
return font.scaledFont(forTextStyle: .body)
22+
}
23+
1924
var footnote: UIFont {
2025
let font = UIFont.rounded(ofSize: 13, weight: .medium)
2126
return font.scaledFont(forTextStyle: .footnote)

Pinwheel/Sources/Pinwheel/Components/Button.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public enum ButtonStyle {
1515
}
1616

1717
public class Button: UIButton {
18+
private static let buttonWidth = round(100.0 * sizeRatio)
1819
public static var sizeRatio: CGFloat {
1920
let screenHeight = UIScreen.main.bounds.height
2021

@@ -49,7 +50,7 @@ public class Button: UIButton {
4950
}
5051

5152
let font: UIFont
52-
public init(title: String? = nil, symbol: String? = nil, font: UIFont = .subtitle, style: ButtonStyle = .primary) {
53+
public init(title: String? = nil, symbol: String? = nil, font: UIFont = .bodySemibold, style: ButtonStyle = .primary) {
5354
self.title = title
5455
self.font = font
5556
self.style = style
@@ -73,6 +74,7 @@ public class Button: UIButton {
7374
super.didMoveToSuperview()
7475

7576
if let superview = superview, let _ = title {
77+
widthAnchor.constraint(greaterThanOrEqualToConstant: Button.buttonWidth).isActive = true
7678
widthAnchor.constraint(lessThanOrEqualTo: superview.widthAnchor, constant: -.spacingXL).isActive = true
7779
}
7880
}

Pinwheel/Sources/Pinwheel/DNA/Font/DefaultFontProvider.swift

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public struct DefaultFontProvider: FontProvider {
1616
return font.scaledFont(forTextStyle: .body)
1717
}
1818

19+
public var bodySemibold: UIFont {
20+
let font = UIFont.systemFont(ofSize: 17, weight: .semibold)
21+
return font.scaledFont(forTextStyle: .body)
22+
}
23+
1924
public var footnote: UIFont {
2025
let font = UIFont.systemFont(ofSize: 13, weight: .medium)
2126
return font.scaledFont(forTextStyle: .footnote)

Pinwheel/Sources/Pinwheel/DNA/Font/UIFont+Pinwheel.swift

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public extension UIFont {
1313
Config.fontProvider.body
1414
}
1515

16+
class var bodySemibold: UIFont {
17+
Config.fontProvider.bodySemibold
18+
}
19+
1620
class var footnote: UIFont {
1721
Config.fontProvider.footnote
1822
}

Pinwheel/Sources/Pinwheel/Public/FontProvider.swift

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public protocol FontProvider {
44
var title: UIFont { get }
55
var subtitle: UIFont { get }
66
var body: UIFont { get }
7+
var bodySemibold: UIFont { get }
78
var footnote: UIFont { get }
89
var caption: UIFont { get }
910

0 commit comments

Comments
 (0)