@@ -12,15 +12,17 @@ using namespace yoga;
12
12
13
13
extern const char RNCSafeAreaViewComponentName[] = " RNCSafeAreaView" ;
14
14
15
- inline Style::Length
16
- valueFromEdges (Style::Length edge, Style::Length axis, Style::Length defaultValue) {
17
- if (edge.unit () != Unit::Undefined) {
18
- return edge;
19
- }
20
- if (axis.unit () != Unit::Undefined) {
21
- return axis;
22
- }
23
- return defaultValue;
15
+ inline Style::Length valueFromEdges (
16
+ Style::Length edge,
17
+ Style::Length axis,
18
+ Style::Length defaultValue) {
19
+ if (edge.unit () != Unit::Undefined) {
20
+ return edge;
21
+ }
22
+ if (axis.unit () != Unit::Undefined) {
23
+ return axis;
24
+ }
25
+ return defaultValue;
24
26
}
25
27
26
28
inline float
@@ -49,39 +51,49 @@ void RNCSafeAreaViewShadowNode::adjustLayoutWithState() {
49
51
// / end.
50
52
Style::Length top, left, right, bottom;
51
53
if (props.mode == RNCSafeAreaViewMode::Padding) {
52
- auto defaultPadding = props.yogaStyle .padding (Edge::All);
53
- top = valueFromEdges (props.yogaStyle .padding (Edge::Top), props.yogaStyle .padding (Edge::Vertical), defaultPadding);
54
- left =
55
- valueFromEdges (props.yogaStyle .padding (Edge::Left), props.yogaStyle .padding (Edge::Horizontal), defaultPadding);
56
- bottom =
57
- valueFromEdges (props.yogaStyle .padding (Edge::Bottom), props.yogaStyle .padding (Edge::Vertical), defaultPadding);
54
+ auto defaultPadding = props.yogaStyle .padding (Edge::All);
55
+ top = valueFromEdges (
56
+ props.yogaStyle .padding (Edge::Top),
57
+ props.yogaStyle .padding (Edge::Vertical),
58
+ defaultPadding);
59
+ left = valueFromEdges (
60
+ props.yogaStyle .padding (Edge::Left),
61
+ props.yogaStyle .padding (Edge::Horizontal),
62
+ defaultPadding);
63
+ bottom = valueFromEdges (
64
+ props.yogaStyle .padding (Edge::Bottom),
65
+ props.yogaStyle .padding (Edge::Vertical),
66
+ defaultPadding);
58
67
right = valueFromEdges (
59
- props.yogaStyle .padding (Edge::Right), props.yogaStyle .padding (Edge::Horizontal), defaultPadding);
68
+ props.yogaStyle .padding (Edge::Right),
69
+ props.yogaStyle .padding (Edge::Horizontal),
70
+ defaultPadding);
60
71
} else {
61
- auto defaultMargin = props.yogaStyle .margin (Edge::All);
62
- top = valueFromEdges (props.yogaStyle .margin (Edge::Top), props.yogaStyle .margin (Edge::Vertical), defaultMargin);
63
- left =
64
- valueFromEdges (props.yogaStyle .margin (Edge::Left), props.yogaStyle .margin (Edge::Horizontal), defaultMargin);
65
- bottom =
66
- valueFromEdges (props.yogaStyle .margin (Edge::Bottom), props.yogaStyle .margin (Edge::Vertical), defaultMargin);
67
- right =
68
- valueFromEdges (props.yogaStyle .margin (Edge::Right), props.yogaStyle .margin (Edge::Horizontal), defaultMargin);
72
+ auto defaultMargin = props.yogaStyle .margin (Edge::All);
73
+ top = valueFromEdges (
74
+ props.yogaStyle .margin (Edge::Top),
75
+ props.yogaStyle .margin (Edge::Vertical),
76
+ defaultMargin);
77
+ left = valueFromEdges (
78
+ props.yogaStyle .margin (Edge::Left),
79
+ props.yogaStyle .margin (Edge::Horizontal),
80
+ defaultMargin);
81
+ bottom = valueFromEdges (
82
+ props.yogaStyle .margin (Edge::Bottom),
83
+ props.yogaStyle .margin (Edge::Vertical),
84
+ defaultMargin);
85
+ right = valueFromEdges (
86
+ props.yogaStyle .margin (Edge::Right),
87
+ props.yogaStyle .margin (Edge::Horizontal),
88
+ defaultMargin);
69
89
}
70
90
71
- top.points (getEdgeValue (
72
- edges.top ,
73
- stateData.insets .top ,
74
- top.value ().unwrapOrDefault (0 )
75
- )
76
- );
91
+ top.points (getEdgeValue (
92
+ edges.top , stateData.insets .top , top.value ().unwrapOrDefault (0 )));
77
93
left.points (getEdgeValue (
78
- edges.left ,
79
- stateData.insets .left ,
80
- left.value ().unwrapOrDefault (0 )));
94
+ edges.left , stateData.insets .left , left.value ().unwrapOrDefault (0 )));
81
95
right.points (getEdgeValue (
82
- edges.right ,
83
- stateData.insets .right ,
84
- right.value ().unwrapOrDefault (0 )));
96
+ edges.right , stateData.insets .right , right.value ().unwrapOrDefault (0 )));
85
97
bottom.points (getEdgeValue (
86
98
edges.bottom ,
87
99
stateData.insets .bottom ,
@@ -102,18 +114,14 @@ void RNCSafeAreaViewShadowNode::adjustLayoutWithState() {
102
114
103
115
auto currentStyle = yogaNode_.style ();
104
116
if (adjustedStyle.padding (Edge::Top) != currentStyle.padding (Edge::Top) ||
105
- adjustedStyle.padding (Edge::Left) !=
106
- currentStyle.padding (Edge::Left) ||
107
- adjustedStyle.padding (Edge::Right) !=
108
- currentStyle.padding (Edge::Right) ||
117
+ adjustedStyle.padding (Edge::Left) != currentStyle.padding (Edge::Left) ||
118
+ adjustedStyle.padding (Edge::Right) != currentStyle.padding (Edge::Right) ||
109
119
adjustedStyle.padding (Edge::Bottom) !=
110
120
currentStyle.padding (Edge::Bottom) ||
111
121
adjustedStyle.margin (Edge::Top) != currentStyle.margin (Edge::Top) ||
112
122
adjustedStyle.margin (Edge::Left) != currentStyle.margin (Edge::Left) ||
113
- adjustedStyle.margin (Edge::Right) !=
114
- currentStyle.margin (Edge::Right) ||
115
- adjustedStyle.margin (Edge::Bottom) !=
116
- currentStyle.margin (Edge::Bottom)) {
123
+ adjustedStyle.margin (Edge::Right) != currentStyle.margin (Edge::Right) ||
124
+ adjustedStyle.margin (Edge::Bottom) != currentStyle.margin (Edge::Bottom)) {
117
125
yogaNode_.setStyle (adjustedStyle);
118
126
yogaNode_.setDirty (true );
119
127
}
0 commit comments