File tree Expand file tree Collapse file tree 4 files changed +41
-19
lines changed Expand file tree Collapse file tree 4 files changed +41
-19
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // SDFont.swift
3
+ //
4
+ //
5
+ // Created by Leif on 2/23/21.
6
+ //
7
+
8
+ import SwiftUI
9
+
10
+ import ScreenData
11
+
12
+ public struct SDFont {
13
+ public static var largeTitleFont : Font ?
14
+ public static var titleFont : Font ?
15
+ public static var headlingFont : Font ?
16
+ public static var bodyFont : Font ?
17
+ public static var footnoteFont : Font ?
18
+ public static var captionFont : Font ?
19
+
20
+ public static func font( for fontType: FontType ) -> Font {
21
+ switch fontType {
22
+ case . largeTitle:
23
+ return largeTitleFont ?? . largeTitle
24
+ case . title:
25
+ return titleFont ?? . title
26
+ case . headline:
27
+ return headlingFont ?? . headline
28
+ case . body:
29
+ return bodyFont ?? . body
30
+ case . footnote:
31
+ return footnoteFont ?? . footnote
32
+ case . caption:
33
+ return captionFont ?? . caption
34
+ }
35
+ }
36
+
37
+ }
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ public struct SDButton: View {
43
43
}
44
44
} ) {
45
45
Text ( button. title)
46
+ . font ( SDFont . font ( for: . body) )
46
47
. background ( with: button. style)
47
48
}
48
49
. sheet ( item: $modalScreen) { ( destination) in
Original file line number Diff line number Diff line change @@ -12,23 +12,6 @@ import ScreenDataNavigation
12
12
public struct SDLabel : View {
13
13
public var label : SomeLabel
14
14
15
- private var font : Font {
16
- switch label. font {
17
- case . largeTitle:
18
- return . largeTitle
19
- case . title:
20
- return . title
21
- case . headline:
22
- return . headline
23
- case . body:
24
- return . body
25
- case . footnote:
26
- return . footnote
27
- case . caption:
28
- return . caption
29
- }
30
- }
31
-
32
15
public init (
33
16
label: SomeLabel
34
17
) {
@@ -40,13 +23,13 @@ public struct SDLabel: View {
40
23
VStack {
41
24
// Title
42
25
Text ( label. title)
43
- . font ( font)
26
+ . font ( SDFont . font ( for : label . font ) )
44
27
. multilineTextAlignment ( label. destination. map { _ in . center } ?? . leading)
45
28
46
29
// Subtitle
47
30
label. subtitle. map {
48
31
Text ( $0)
49
- . font ( . headline)
32
+ . font ( SDFont . font ( for : . headline) )
50
33
. multilineTextAlignment ( . leading)
51
34
}
52
35
}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ public struct SDText: View {
17
17
18
18
public var body : some View {
19
19
Text ( text. title)
20
+ . font ( SDFont . font ( for: . body) )
20
21
. background ( with: text. style)
21
22
. multilineTextAlignment ( . leading)
22
23
}
You can’t perform that action at this time.
0 commit comments