react-native-screens 4.15.2 → 4.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,8 +33,8 @@ namespace react = facebook::react;
|
|
|
33
33
|
#if !RCT_NEW_ARCH_ENABLED
|
|
34
34
|
BOOL _tabItemNeedsAppearanceUpdate;
|
|
35
35
|
BOOL _tabScreenOrientationNeedsUpdate;
|
|
36
|
+
BOOL _tabBarItemNeedsUpdate;
|
|
36
37
|
#endif // !RCT_NEW_ARCH_ENABLED
|
|
37
|
-
UITabBarItem *_baseTabBarItem;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
@@ -61,6 +61,7 @@ namespace react = facebook::react;
|
|
|
61
61
|
#if !RCT_NEW_ARCH_ENABLED
|
|
62
62
|
_tabItemNeedsAppearanceUpdate = NO;
|
|
63
63
|
_tabScreenOrientationNeedsUpdate = NO;
|
|
64
|
+
_tabBarItemNeedsUpdate = NO;
|
|
64
65
|
#endif
|
|
65
66
|
|
|
66
67
|
// This is a temporary workaround to avoid UIScrollEdgeEffect glitch
|
|
@@ -138,22 +139,6 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
138
139
|
return static_cast<RNSTabBarController *>(_controller.tabBarController);
|
|
139
140
|
}
|
|
140
141
|
|
|
141
|
-
- (void)setSystemItemBasedOnRNSBottomTabsScreenSystemItem:(RNSBottomTabsScreenSystemItem)systemItem
|
|
142
|
-
{
|
|
143
|
-
_systemItem = systemItem;
|
|
144
|
-
if (_systemItem != RNSBottomTabsScreenSystemItemNone) {
|
|
145
|
-
if (_baseTabBarItem == nil) {
|
|
146
|
-
_baseTabBarItem = _controller.tabBarItem;
|
|
147
|
-
}
|
|
148
|
-
UITabBarSystemItem systemItem =
|
|
149
|
-
rnscreens::conversion::RNSBottomTabsScreenSystemItemToUITabBarSystemItem(_systemItem);
|
|
150
|
-
_controller.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:systemItem tag:0];
|
|
151
|
-
} else if (_baseTabBarItem != nil) {
|
|
152
|
-
_controller.tabBarItem = _baseTabBarItem;
|
|
153
|
-
_baseTabBarItem = nil;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
142
|
#pragma mark - RNSScrollViewBehaviorOverriding
|
|
158
143
|
|
|
159
144
|
- (BOOL)shouldOverrideScrollViewContentInsetAdjustmentBehavior
|
|
@@ -168,6 +153,25 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
168
153
|
}
|
|
169
154
|
}
|
|
170
155
|
|
|
156
|
+
#pragma mark - Prop update utils
|
|
157
|
+
|
|
158
|
+
- (void)updateTabBarItem
|
|
159
|
+
{
|
|
160
|
+
UITabBarItem *tabBarItem = nil;
|
|
161
|
+
if (_systemItem != RNSBottomTabsScreenSystemItemNone) {
|
|
162
|
+
UITabBarSystemItem systemItem =
|
|
163
|
+
rnscreens::conversion::RNSBottomTabsScreenSystemItemToUITabBarSystemItem(_systemItem);
|
|
164
|
+
tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:systemItem tag:0];
|
|
165
|
+
} else {
|
|
166
|
+
tabBarItem = [[UITabBarItem alloc] init];
|
|
167
|
+
tabBarItem.title = _title;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
tabBarItem.badgeValue = _badgeValue;
|
|
171
|
+
|
|
172
|
+
_controller.tabBarItem = tabBarItem;
|
|
173
|
+
}
|
|
174
|
+
|
|
171
175
|
#if RCT_NEW_ARCH_ENABLED
|
|
172
176
|
#pragma mark - RCTViewComponentViewProtocol
|
|
173
177
|
|
|
@@ -179,6 +183,7 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
179
183
|
|
|
180
184
|
bool tabItemNeedsAppearanceUpdate{false};
|
|
181
185
|
bool tabScreenOrientationNeedsUpdate{false};
|
|
186
|
+
bool tabBarItemNeedsUpdate{false};
|
|
182
187
|
|
|
183
188
|
if (newComponentProps.title != oldComponentProps.title) {
|
|
184
189
|
_title = RCTNSStringFromStringNilIfEmpty(newComponentProps.title);
|
|
@@ -203,10 +208,7 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
203
208
|
|
|
204
209
|
if (newComponentProps.badgeValue != oldComponentProps.badgeValue) {
|
|
205
210
|
_badgeValue = RCTNSStringFromStringNilIfEmpty(newComponentProps.badgeValue);
|
|
206
|
-
|
|
207
|
-
if (_baseTabBarItem != nil) {
|
|
208
|
-
_baseTabBarItem.badgeValue = _badgeValue;
|
|
209
|
-
}
|
|
211
|
+
tabBarItemNeedsUpdate = YES;
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
if (newComponentProps.standardAppearance != oldComponentProps.standardAppearance) {
|
|
@@ -232,28 +234,33 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
232
234
|
if (newComponentProps.iconType != oldComponentProps.iconType) {
|
|
233
235
|
_iconType = rnscreens::conversion::RNSBottomTabsIconTypeFromIcon(newComponentProps.iconType);
|
|
234
236
|
tabItemNeedsAppearanceUpdate = YES;
|
|
237
|
+
tabBarItemNeedsUpdate = YES;
|
|
235
238
|
}
|
|
236
239
|
|
|
237
240
|
if (newComponentProps.iconImageSource != oldComponentProps.iconImageSource) {
|
|
238
241
|
_iconImageSource =
|
|
239
242
|
rnscreens::conversion::RCTImageSourceFromImageSourceAndIconType(&newComponentProps.iconImageSource, _iconType);
|
|
240
243
|
tabItemNeedsAppearanceUpdate = YES;
|
|
244
|
+
tabBarItemNeedsUpdate = YES;
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
if (newComponentProps.iconSfSymbolName != oldComponentProps.iconSfSymbolName) {
|
|
244
248
|
_iconSfSymbolName = RCTNSStringFromStringNilIfEmpty(newComponentProps.iconSfSymbolName);
|
|
245
249
|
tabItemNeedsAppearanceUpdate = YES;
|
|
250
|
+
tabBarItemNeedsUpdate = YES;
|
|
246
251
|
}
|
|
247
252
|
|
|
248
253
|
if (newComponentProps.selectedIconImageSource != oldComponentProps.selectedIconImageSource) {
|
|
249
254
|
_selectedIconImageSource = rnscreens::conversion::RCTImageSourceFromImageSourceAndIconType(
|
|
250
255
|
&newComponentProps.selectedIconImageSource, _iconType);
|
|
251
256
|
tabItemNeedsAppearanceUpdate = YES;
|
|
257
|
+
tabBarItemNeedsUpdate = YES;
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
if (newComponentProps.selectedIconSfSymbolName != oldComponentProps.selectedIconSfSymbolName) {
|
|
255
261
|
_selectedIconSfSymbolName = RCTNSStringFromStringNilIfEmpty(newComponentProps.selectedIconSfSymbolName);
|
|
256
262
|
tabItemNeedsAppearanceUpdate = YES;
|
|
263
|
+
tabBarItemNeedsUpdate = YES;
|
|
257
264
|
}
|
|
258
265
|
|
|
259
266
|
if (newComponentProps.specialEffects.repeatedTabSelection.popToRoot !=
|
|
@@ -279,17 +286,24 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
279
286
|
}
|
|
280
287
|
}
|
|
281
288
|
|
|
282
|
-
if (newComponentProps.systemItem != oldComponentProps.systemItem) {
|
|
283
|
-
[self setSystemItemBasedOnRNSBottomTabsScreenSystemItem:
|
|
284
|
-
rnscreens::conversion::RNSBottomTabsScreenSystemItemFromReactRNSBottomTabsScreenSystemItem(
|
|
285
|
-
newComponentProps.systemItem)];
|
|
286
|
-
}
|
|
287
|
-
|
|
288
289
|
// This flag is set to YES when overrideScrollViewContentInsetAdjustmentBehavior prop
|
|
289
290
|
// is assigned for the first time. This allows us to identify any subsequent changes to this prop,
|
|
290
291
|
// enabling us to warn users that dynamic changes are not supported.
|
|
291
292
|
_isOverrideScrollViewContentInsetAdjustmentBehaviorSet = YES;
|
|
292
293
|
|
|
294
|
+
if (newComponentProps.systemItem != oldComponentProps.systemItem) {
|
|
295
|
+
_systemItem = rnscreens::conversion::RNSBottomTabsScreenSystemItemFromReactRNSBottomTabsScreenSystemItem(
|
|
296
|
+
newComponentProps.systemItem);
|
|
297
|
+
tabBarItemNeedsUpdate = YES;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (tabBarItemNeedsUpdate) {
|
|
301
|
+
[self updateTabBarItem];
|
|
302
|
+
|
|
303
|
+
// Force appearance update to make sure correct image for tab bar item is used
|
|
304
|
+
tabItemNeedsAppearanceUpdate = YES;
|
|
305
|
+
}
|
|
306
|
+
|
|
293
307
|
if (tabItemNeedsAppearanceUpdate) {
|
|
294
308
|
[_controller tabItemAppearanceHasChanged];
|
|
295
309
|
}
|
|
@@ -356,6 +370,14 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
356
370
|
// didSetProps will always be called because tabKey prop is required.
|
|
357
371
|
_isOverrideScrollViewContentInsetAdjustmentBehaviorSet = YES;
|
|
358
372
|
|
|
373
|
+
if (_tabBarItemNeedsUpdate) {
|
|
374
|
+
[self updateTabBarItem];
|
|
375
|
+
_tabBarItemNeedsUpdate = NO;
|
|
376
|
+
|
|
377
|
+
// Force appearance update to make sure correct image for tab bar item is used
|
|
378
|
+
_tabItemNeedsAppearanceUpdate = YES;
|
|
379
|
+
}
|
|
380
|
+
|
|
359
381
|
if (_tabItemNeedsAppearanceUpdate) {
|
|
360
382
|
[_controller tabItemAppearanceHasChanged];
|
|
361
383
|
_tabItemNeedsAppearanceUpdate = NO;
|
|
@@ -392,37 +414,42 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
392
414
|
- (void)setBadgeValue:(NSString *)badgeValue
|
|
393
415
|
{
|
|
394
416
|
_badgeValue = [NSString rnscreens_stringOrNilIfBlank:badgeValue];
|
|
395
|
-
|
|
417
|
+
_tabBarItemNeedsUpdate = YES;
|
|
396
418
|
}
|
|
397
419
|
|
|
398
420
|
- (void)setIconType:(RNSBottomTabsIconType)iconType
|
|
399
421
|
{
|
|
400
422
|
_iconType = iconType;
|
|
401
423
|
_tabItemNeedsAppearanceUpdate = YES;
|
|
424
|
+
_tabBarItemNeedsUpdate = YES;
|
|
402
425
|
}
|
|
403
426
|
|
|
404
427
|
- (void)setIconImageSource:(RCTImageSource *)iconImageSource
|
|
405
428
|
{
|
|
406
429
|
_iconImageSource = iconImageSource;
|
|
407
430
|
_tabItemNeedsAppearanceUpdate = YES;
|
|
431
|
+
_tabBarItemNeedsUpdate = YES;
|
|
408
432
|
}
|
|
409
433
|
|
|
410
434
|
- (void)setIconSfSymbolName:(NSString *)iconSfSymbolName
|
|
411
435
|
{
|
|
412
436
|
_iconSfSymbolName = [NSString rnscreens_stringOrNilIfEmpty:iconSfSymbolName];
|
|
413
437
|
_tabItemNeedsAppearanceUpdate = YES;
|
|
438
|
+
_tabBarItemNeedsUpdate = YES;
|
|
414
439
|
}
|
|
415
440
|
|
|
416
441
|
- (void)setSelectedIconImageSource:(RCTImageSource *)selectedIconImageSource
|
|
417
442
|
{
|
|
418
443
|
_selectedIconImageSource = selectedIconImageSource;
|
|
419
444
|
_tabItemNeedsAppearanceUpdate = YES;
|
|
445
|
+
_tabBarItemNeedsUpdate = YES;
|
|
420
446
|
}
|
|
421
447
|
|
|
422
448
|
- (void)setSelectedIconSfSymbolName:(NSString *)selectedIconSfSymbolName
|
|
423
449
|
{
|
|
424
450
|
_selectedIconSfSymbolName = [NSString rnscreens_stringOrNilIfEmpty:selectedIconSfSymbolName];
|
|
425
451
|
_tabItemNeedsAppearanceUpdate = YES;
|
|
452
|
+
_tabBarItemNeedsUpdate = YES;
|
|
426
453
|
}
|
|
427
454
|
|
|
428
455
|
- (void)setOverrideScrollViewContentInsetAdjustmentBehavior:(BOOL)overrideScrollViewContentInsetAdjustmentBehavior
|
|
@@ -464,7 +491,8 @@ RNS_IGNORE_SUPER_CALL_END
|
|
|
464
491
|
// It allows us to store UITabBarMinimizeBehavior in the component while accepting a custom enum as input from JS.
|
|
465
492
|
- (void)setSystemItem:(RNSBottomTabsScreenSystemItem)systemItem
|
|
466
493
|
{
|
|
467
|
-
|
|
494
|
+
_systemItem = systemItem;
|
|
495
|
+
_tabBarItemNeedsUpdate = YES;
|
|
468
496
|
}
|
|
469
497
|
|
|
470
498
|
- (void)setOrientation:(RNSOrientation)orientation
|
|
@@ -53,8 +53,13 @@
|
|
|
53
53
|
withImageLoader:(RCTImageLoader *_Nullable)imageLoader
|
|
54
54
|
{
|
|
55
55
|
if (screenView.iconType == RNSBottomTabsIconTypeSfSymbol) {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
if (screenView.iconSfSymbolName != nil) {
|
|
57
|
+
tabBarItem.image = [UIImage systemImageNamed:screenView.iconSfSymbolName];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (screenView.selectedIconSfSymbolName != nil) {
|
|
61
|
+
tabBarItem.selectedImage = [UIImage systemImageNamed:screenView.selectedIconSfSymbolName];
|
|
62
|
+
}
|
|
58
63
|
} else if (imageLoader != nil) {
|
|
59
64
|
bool isTemplate = screenView.iconType == RNSBottomTabsIconTypeTemplate;
|
|
60
65
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-screens",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.3",
|
|
4
4
|
"description": "Native navigation primitives for your React Native app.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"submodules": "git submodule update --init --recursive && (cd react-navigation && yarn && yarn build && cd ../)",
|