3
3
#import < React/RCTAssert.h>
4
4
#include < math.h>
5
5
6
+ #import " RNCSafeAreaViewEdges.h"
6
7
#import " RNCSafeAreaViewLocalData.h"
7
8
#import " RNCSafeAreaViewMode.h"
8
- #import " RNCSafeAreaViewEdges.h"
9
9
10
10
// From RCTShadowView.m
11
11
typedef NS_ENUM (unsigned int , meta_prop_t ) {
@@ -39,7 +39,11 @@ - (instancetype)init
39
39
return self;
40
40
}
41
41
42
- - (void )extractEdges : (YGValue[])_metaProps top : (CGFloat *)top right : (CGFloat *)right bottom : (CGFloat *)bottom left : (CGFloat *)left
42
+ - (void )extractEdges : (YGValue[])_metaProps
43
+ top : (CGFloat *)top
44
+ right : (CGFloat *)right
45
+ bottom : (CGFloat *)bottom
46
+ left : (CGFloat *)left
43
47
{
44
48
if (_metaProps[META_PROP_ALL].unit == YGUnitPoint) {
45
49
*top = _metaProps[META_PROP_ALL].value ;
@@ -61,7 +65,7 @@ - (void)extractEdges:(YGValue[])_metaProps top:(CGFloat *)top right:(CGFloat *)r
61
65
if (_metaProps[META_PROP_TOP].unit == YGUnitPoint) {
62
66
*top = _metaProps[META_PROP_TOP].value ;
63
67
}
64
-
68
+
65
69
if (_metaProps[META_PROP_RIGHT].unit == YGUnitPoint) {
66
70
*right = _metaProps[META_PROP_RIGHT].value ;
67
71
}
@@ -75,7 +79,8 @@ - (void)extractEdges:(YGValue[])_metaProps top:(CGFloat *)top right:(CGFloat *)r
75
79
}
76
80
}
77
81
78
- - (void )resetInsetsForMode : (RNCSafeAreaViewMode)mode {
82
+ - (void )resetInsetsForMode : (RNCSafeAreaViewMode)mode
83
+ {
79
84
if (mode == RNCSafeAreaViewModePadding) {
80
85
super.paddingTop = _paddingMetaProps[META_PROP_TOP];
81
86
super.paddingRight = _paddingMetaProps[META_PROP_RIGHT];
@@ -136,38 +141,37 @@ - (void)didSetProps:(NSArray<NSString *> *)changedProps
136
141
- (void )setLocalData : (RNCSafeAreaViewLocalData *)localData
137
142
{
138
143
RCTAssert (
139
- [localData isKindOfClass: [RNCSafeAreaViewLocalData class ]],
140
- @" Local data object for `RCTRNCSafeAreaShadowView` must be `RCTRNCSafeAreaViewLocalData` instance."
141
- );
144
+ [localData isKindOfClass: [RNCSafeAreaViewLocalData class ]],
145
+ @" Local data object for `RCTRNCSafeAreaShadowView` must be `RCTRNCSafeAreaViewLocalData` instance." );
142
146
143
147
if (_localData != nil && _localData.mode != localData.mode ) {
144
148
[self resetInsetsForMode: _localData.mode];
145
149
}
146
-
150
+
147
151
_localData = localData;
148
152
_needsUpdate = false ;
149
153
[self updateInsets ];
150
-
154
+
151
155
if (_localData.mode == RNCSafeAreaViewModePadding) {
152
- [super didSetProps: @[@" paddingTop" , @" paddingRight" , @" paddingBottom" , @" paddingLeft" ]];
156
+ [super didSetProps: @[ @" paddingTop" , @" paddingRight" , @" paddingBottom" , @" paddingLeft" ]];
153
157
} else {
154
- [super didSetProps: @[@" marginTop" , @" marginRight" , @" marginBottom" , @" marginLeft" ]];
158
+ [super didSetProps: @[ @" marginTop" , @" marginRight" , @" marginBottom" , @" marginLeft" ]];
155
159
}
156
160
}
157
161
158
162
#define SHADOW_VIEW_MARGIN_PADDING_PROP (edge, metaProp ) \
159
- - (void )setPadding ##edge: (YGValue)value \
160
- { \
161
- [super setPadding##edge:value]; \
162
- _needsUpdate = true ; \
163
- _paddingMetaProps[META_PROP_##metaProp] = value; \
164
- } \
165
- - (void )setMargin ##edge: (YGValue)value \
166
- { \
167
- [super setMargin##edge:value]; \
168
- _needsUpdate = true ; \
169
- _marginMetaProps[META_PROP_##metaProp] = value; \
170
- }
163
+ - (void )setPadding##edge : (YGValue)value \
164
+ { \
165
+ [super setPadding##edge:value]; \
166
+ _needsUpdate = true ; \
167
+ _paddingMetaProps[META_PROP_##metaProp] = value; \
168
+ } \
169
+ - (void )setMargin##edge : (YGValue)value \
170
+ { \
171
+ [super setMargin##edge:value]; \
172
+ _needsUpdate = true ; \
173
+ _marginMetaProps[META_PROP_##metaProp] = value; \
174
+ }
171
175
172
176
SHADOW_VIEW_MARGIN_PADDING_PROP (, ALL);
173
177
SHADOW_VIEW_MARGIN_PADDING_PROP (Vertical, VERTICAL);
0 commit comments