@@ -12,15 +12,17 @@ using namespace yoga;
1212
1313extern const char RNCSafeAreaViewComponentName[] = " RNCSafeAreaView" ;
1414
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;
2426}
2527
2628inline float
@@ -49,39 +51,49 @@ void RNCSafeAreaViewShadowNode::adjustLayoutWithState() {
4951 // / end.
5052 Style::Length top, left, right, bottom;
5153 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);
5867 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);
6071 } 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);
6989 }
7090
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 )));
7793 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 )));
8195 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 )));
8597 bottom.points (getEdgeValue (
8698 edges.bottom ,
8799 stateData.insets .bottom ,
@@ -102,18 +114,14 @@ void RNCSafeAreaViewShadowNode::adjustLayoutWithState() {
102114
103115 auto currentStyle = yogaNode_.style ();
104116 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) ||
109119 adjustedStyle.padding (Edge::Bottom) !=
110120 currentStyle.padding (Edge::Bottom) ||
111121 adjustedStyle.margin (Edge::Top) != currentStyle.margin (Edge::Top) ||
112122 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)) {
117125 yogaNode_.setStyle (adjustedStyle);
118126 yogaNode_.setDirty (true );
119127 }
0 commit comments