@@ -27,33 +27,49 @@ public struct SDStyleModifier: ViewModifier {
27
27
return CGFloat ( height)
28
28
}
29
29
30
+ @ViewBuilder
30
31
public func body( content: Content ) -> some View {
31
32
if style. isHidden {
32
- return AnyView (
33
- content
34
- . hidden ( )
35
- . frame ( width: 0 , height: 0 , alignment: . center)
36
- )
33
+ content
34
+ . hidden ( )
35
+ . frame ( width: 0 , height: 0 , alignment: . center)
36
+ } else if style. padding != 0 {
37
+ content
38
+ . padding ( CGFloat ( style. padding) )
39
+ . background (
40
+ style. backgroundColor. map {
41
+ SDColor ( color: $0)
42
+ } ?? SDColor ( color: SomeColor ( red: 0 , green: 0 , blue: 0 , alpha: 0 ) )
43
+ )
44
+ . cornerRadius ( CGFloat ( style. cornerRadius) )
45
+ . foregroundColor (
46
+ style. foregroundColor. map {
47
+ SDColor ( color: $0) . body as? Color
48
+ } ?? Color . primary
49
+ )
50
+ . frame (
51
+ width: width,
52
+ height: height,
53
+ alignment: . center
54
+ )
37
55
} else {
38
- return AnyView (
39
- content
40
- . padding ( CGFloat ( style. padding) )
41
- . background (
42
- style. backgroundColor. map {
43
- AnyView ( SDColor ( color: $0) )
44
- } ?? AnyView ( Color . clear)
45
- )
46
- . cornerRadius ( CGFloat ( style. cornerRadius) )
47
- . foregroundColor ( style. foregroundColor. map {
56
+ content
57
+ . background (
58
+ style. backgroundColor. map {
59
+ SDColor ( color: $0)
60
+ } ?? SDColor ( color: SomeColor ( red: 0 , green: 0 , blue: 0 , alpha: 0 ) )
61
+ )
62
+ . cornerRadius ( CGFloat ( style. cornerRadius) )
63
+ . foregroundColor (
64
+ style. foregroundColor. map {
48
65
SDColor ( color: $0) . body as? Color
49
- } ?? Color . primary)
50
- . frame (
51
- width : width ,
52
- height : height ,
53
- alignment : . center
54
- )
55
- )
66
+ } ?? Color . primary
67
+ )
68
+ . frame (
69
+ width : width ,
70
+ height : height ,
71
+ alignment : . center
72
+ )
56
73
}
57
-
58
74
}
59
75
}
0 commit comments