@@ -4,12 +4,26 @@ public struct StyleProps: Decodable {
4
4
// ViewStyle
5
5
public var backgroundColor : Color ?
6
6
// - Frame
7
- public var width : CGFloat ?
8
- public var height : CGFloat ?
7
+ public var width : Size ?
8
+ public var minWidth : Size ?
9
+ public var maxWidth : Size ?
10
+ public var height : Size ?
11
+ public var minHeight : Size ?
12
+ public var maxHeight : Size ?
13
+ // - Position
14
+ public var position : String ? // "absolute" or "relative"
15
+ public var top : CGFloat ?
16
+ public var left : CGFloat ?
17
+ public var bottom : CGFloat ?
18
+ public var right : CGFloat ?
9
19
// - Padding
10
20
public var padding : CGFloat ?
11
21
public var paddingHorizontal : CGFloat ?
12
22
public var paddingVertical : CGFloat ?
23
+ public var paddingLeft : CGFloat ?
24
+ public var paddingRight : CGFloat ?
25
+ public var paddingTop : CGFloat ?
26
+ public var paddingBottom : CGFloat ?
13
27
// - Border
14
28
public var borderColor : Color ?
15
29
public var borderWidth : CGFloat ?
@@ -21,33 +35,51 @@ public struct StyleProps: Decodable {
21
35
public var fontWeight : Font . Weight ?
22
36
public var fontSize : CGFloat ?
23
37
public var font : Font ?
38
+ public var fontFamily : String ?
24
39
25
40
enum CodingKeys : String , CodingKey {
26
- case color, backgroundColor, foregroundColor, width, height, padding, paddingHorizontal, paddingVertical, borderColor, borderWidth, borderRadius, cornerRadius, fontWeight, fontSize, font
41
+ case color, backgroundColor, foregroundColor, width, minWidth , maxWidth , height, minHeight , maxHeight , position , top , left , bottom , right , padding, paddingHorizontal, paddingVertical, paddingLeft , paddingRight , paddingTop , paddingBottom , borderColor, borderWidth, borderRadius, cornerRadius, fontWeight, fontSize, font, fontFamily
27
42
}
28
43
29
44
public init ( from decoder: Decoder ) throws {
30
45
let container = try decoder. container ( keyedBy: CodingKeys . self)
31
46
32
47
// ViewStyle
33
48
backgroundColor = try container. decodeColorIfPresent ( forKey: . backgroundColor)
49
+ // - Frame
50
+ width = try container. decodeIfPresent ( Size . self, forKey: . width)
51
+ minWidth = try container. decodeIfPresent ( Size . self, forKey: . minWidth)
52
+ maxWidth = try container. decodeIfPresent ( Size . self, forKey: . maxWidth)
53
+ height = try container. decodeIfPresent ( Size . self, forKey: . height)
54
+ minHeight = try container. decodeIfPresent ( Size . self, forKey: . minHeight)
55
+ maxHeight = try container. decodeIfPresent ( Size . self, forKey: . maxHeight)
56
+ // - Position
57
+ position = try container. decodeIfPresent ( String . self, forKey: . position)
58
+ top = try container. decodeIfPresent ( CGFloat . self, forKey: . top)
59
+ left = try container. decodeIfPresent ( CGFloat . self, forKey: . left)
60
+ bottom = try container. decodeIfPresent ( CGFloat . self, forKey: . bottom)
61
+ right = try container. decodeIfPresent ( CGFloat . self, forKey: . right)
62
+ // - Padding
63
+ padding = try container. decodeIfPresent ( CGFloat . self, forKey: . padding)
64
+ paddingHorizontal = try container. decodeIfPresent ( CGFloat . self, forKey: . paddingHorizontal)
65
+ paddingVertical = try container. decodeIfPresent ( CGFloat . self, forKey: . paddingVertical)
66
+ paddingLeft = try container. decodeIfPresent ( CGFloat . self, forKey: . paddingLeft)
67
+ paddingRight = try container. decodeIfPresent ( CGFloat . self, forKey: . paddingRight)
68
+ paddingTop = try container. decodeIfPresent ( CGFloat . self, forKey: . paddingTop)
69
+ paddingBottom = try container. decodeIfPresent ( CGFloat . self, forKey: . paddingBottom)
70
+ // - Border
34
71
borderColor = try container. decodeColorIfPresent ( forKey: . borderColor)
35
72
borderWidth = try container. decodeIfPresent ( CGFloat . self, forKey: . borderWidth)
36
73
borderRadius = try container. decodeIfPresent ( CGFloat . self, forKey: . borderRadius) // alias for cornerRadius
37
74
cornerRadius = try container. decodeIfPresent ( CGFloat . self, forKey: . cornerRadius)
38
75
39
- width = try container. decodeIfPresent ( CGFloat . self, forKey: . width)
40
- height = try container. decodeIfPresent ( CGFloat . self, forKey: . height)
41
- padding = try container. decodeIfPresent ( CGFloat . self, forKey: . padding)
42
- paddingHorizontal = try container. decodeIfPresent ( CGFloat . self, forKey: . paddingHorizontal)
43
- paddingVertical = try container. decodeIfPresent ( CGFloat . self, forKey: . paddingVertical)
44
-
45
76
// TextStyle
46
77
color = try container. decodeColorIfPresent ( forKey: . color) // alias for foregroundColor
47
78
foregroundColor = try container. decodeColorIfPresent ( forKey: . foregroundColor)
48
79
fontWeight = try container. decodeFontWeightIfPresent ( forKey: . fontWeight)
49
80
fontSize = try container. decodeIfPresent ( CGFloat . self, forKey: . fontSize)
50
81
font = try container. decodeFontIfPresent ( forKey: . font)
82
+ fontFamily = try container. decodeIfPresent ( String . self, forKey: . fontFamily)
51
83
}
52
84
}
53
85
0 commit comments