react-native-navigation 8.7.9 → 8.8.1-snapshot.2373

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.
@@ -111,15 +111,6 @@
111
111
  self.tabBar.scrollEdgeAppearance = [appearance copy];
112
112
  }
113
113
  #endif
114
-
115
- for (UIViewController *childViewController in self.tabBarController.childViewControllers) {
116
- childViewController.tabBarItem.standardAppearance = [appearance copy];
117
- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
118
- if (@available(iOS 15.0, *)) {
119
- childViewController.tabBarItem.scrollEdgeAppearance = [appearance copy];
120
- }
121
- #endif
122
- }
123
114
  }
124
115
 
125
116
  @end
@@ -1,4 +1,5 @@
1
1
  #import "RNNBottomTabsController.h"
2
+ #import "UITabBarController+RNNOptions.h"
2
3
  #import "UITabBarController+RNNUtils.h"
3
4
 
4
5
  @interface RNNBottomTabsController ()
@@ -100,6 +101,8 @@
100
101
  for (UIViewController *child in childViewControllers) {
101
102
  [_bottomTabPresenter applyOptions:child.resolveOptions child:child];
102
103
  }
104
+
105
+ [self syncTabBarItemTestIDs];
103
106
  }
104
107
 
105
108
  - (void)mergeChildOptions:(RNNNavigationOptions *)options child:(UIViewController *)child {
@@ -111,6 +114,8 @@
111
114
  [_dotIndicatorPresenter mergeOptions:options
112
115
  resolvedOptions:childViewController.resolveOptions
113
116
  child:childViewController];
117
+
118
+ [self syncTabBarItemTestIDs];
114
119
  }
115
120
 
116
121
  - (id<UITabBarControllerDelegate>)delegate {
@@ -123,6 +128,7 @@
123
128
 
124
129
  - (void)viewDidLayoutSubviews {
125
130
  [super viewDidLayoutSubviews];
131
+ [self syncTabBarItemTestIDs];
126
132
  [self.presenter viewDidLayoutSubviews];
127
133
  [_dotIndicatorPresenter bottomTabsDidLayoutSubviews:self];
128
134
  }
@@ -20,4 +20,6 @@
20
20
 
21
21
  - (void)hideTabBar:(BOOL)animated;
22
22
 
23
+ - (void)syncTabBarItemTestIDs;
24
+
23
25
  @end
@@ -1,9 +1,85 @@
1
1
  #import "RNNBottomTabsController.h"
2
2
  #import "UITabBar+utils.h"
3
3
  #import "UITabBarController+RNNOptions.h"
4
+ #import <objc/runtime.h>
5
+
6
+ static const NSTimeInterval RNNTabBarTestIDRetryDelay = 0.15;
7
+ static const NSUInteger RNNTabBarTestIDMaxRetryAttempts = 5;
8
+ static const void *RNNTabBarTestIDRetryScheduledKey = &RNNTabBarTestIDRetryScheduledKey;
9
+ static const void *RNNTabBarTestIDRetryAttemptsKey = &RNNTabBarTestIDRetryAttemptsKey;
10
+ static const void *RNNOriginalTabBarViewAccessibilityIdentifierKey =
11
+ &RNNOriginalTabBarViewAccessibilityIdentifierKey;
4
12
 
5
13
  @implementation UITabBarController (RNNOptions)
6
14
 
15
+ - (void)rnn_storeOriginalAccessibilityIdentifierIfNeededForTabView:(UIView *)tabView {
16
+ if (objc_getAssociatedObject(tabView, RNNOriginalTabBarViewAccessibilityIdentifierKey))
17
+ return;
18
+
19
+ id originalAccessibilityIdentifier = tabView.accessibilityIdentifier ?: [NSNull null];
20
+ objc_setAssociatedObject(tabView, RNNOriginalTabBarViewAccessibilityIdentifierKey,
21
+ originalAccessibilityIdentifier,
22
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
23
+ }
24
+
25
+ - (void)rnn_applyTestID:(NSString *)testID toTabView:(UIView *)tabView {
26
+ [self rnn_storeOriginalAccessibilityIdentifierIfNeededForTabView:tabView];
27
+ tabView.accessibilityIdentifier = testID;
28
+ }
29
+
30
+ - (void)rnn_restoreOriginalAccessibilityIdentifierForTabView:(UIView *)tabView {
31
+ id originalAccessibilityIdentifier =
32
+ objc_getAssociatedObject(tabView, RNNOriginalTabBarViewAccessibilityIdentifierKey);
33
+ if (!originalAccessibilityIdentifier)
34
+ return;
35
+
36
+ tabView.accessibilityIdentifier =
37
+ [originalAccessibilityIdentifier isKindOfClass:NSNull.class]
38
+ ? nil
39
+ : originalAccessibilityIdentifier;
40
+ objc_setAssociatedObject(tabView, RNNOriginalTabBarViewAccessibilityIdentifierKey, nil,
41
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
42
+ }
43
+
44
+ - (BOOL)rnn_isTabBarTestIDRetryScheduled {
45
+ return [objc_getAssociatedObject(self, RNNTabBarTestIDRetryScheduledKey) boolValue];
46
+ }
47
+
48
+ - (void)rnn_setTabBarTestIDRetryScheduled:(BOOL)scheduled {
49
+ objc_setAssociatedObject(self, RNNTabBarTestIDRetryScheduledKey, @(scheduled),
50
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
51
+ }
52
+
53
+ - (NSUInteger)rnn_tabBarTestIDRetryAttempts {
54
+ NSNumber *retryAttempts = objc_getAssociatedObject(self, RNNTabBarTestIDRetryAttemptsKey);
55
+ return retryAttempts.unsignedIntegerValue;
56
+ }
57
+
58
+ - (void)rnn_setTabBarTestIDRetryAttempts:(NSUInteger)retryAttempts {
59
+ objc_setAssociatedObject(self, RNNTabBarTestIDRetryAttemptsKey, @(retryAttempts),
60
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
61
+ }
62
+
63
+ - (BOOL)rnn_applyTabBarItemTestIDs {
64
+ NSArray<UITabBarItem *> *items = self.tabBar.items ?: @[];
65
+ BOOL appliedAllKnownTestIDs = YES;
66
+
67
+ for (NSUInteger tabIndex = 0; tabIndex < items.count; tabIndex++) {
68
+ UITabBarItem *item = items[tabIndex];
69
+ NSString *testID = item.accessibilityIdentifier;
70
+ UIView *tabView = [self.tabBar tabBarItemViewAtIndex:tabIndex];
71
+ if (testID.length > 0 && tabView) {
72
+ [self rnn_applyTestID:testID toTabView:tabView];
73
+ } else if (tabView) {
74
+ [self rnn_restoreOriginalAccessibilityIdentifierForTabView:tabView];
75
+ } else if (testID.length > 0) {
76
+ appliedAllKnownTestIDs = NO;
77
+ }
78
+ }
79
+
80
+ return appliedAllKnownTestIDs;
81
+ }
82
+
7
83
  - (void)setCurrentTabIndex:(NSUInteger)currentTabIndex {
8
84
  [self setSelectedIndex:currentTabIndex];
9
85
  }
@@ -16,6 +92,38 @@
16
92
  self.tabBar.accessibilityIdentifier = testID;
17
93
  }
18
94
 
95
+ - (void)syncTabBarItemTestIDs {
96
+ if ([self rnn_applyTabBarItemTestIDs]) {
97
+ [self rnn_setTabBarTestIDRetryScheduled:NO];
98
+ [self rnn_setTabBarTestIDRetryAttempts:0];
99
+ return;
100
+ }
101
+
102
+ if ([self rnn_isTabBarTestIDRetryScheduled])
103
+ return;
104
+
105
+ NSUInteger retryAttempts = [self rnn_tabBarTestIDRetryAttempts];
106
+ if (retryAttempts >= RNNTabBarTestIDMaxRetryAttempts) {
107
+ [self rnn_setTabBarTestIDRetryAttempts:0];
108
+ return;
109
+ }
110
+
111
+ [self rnn_setTabBarTestIDRetryScheduled:YES];
112
+ [self rnn_setTabBarTestIDRetryAttempts:retryAttempts + 1];
113
+
114
+ __weak UITabBarController *weakSelf = self;
115
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
116
+ (int64_t)(RNNTabBarTestIDRetryDelay * NSEC_PER_SEC)),
117
+ dispatch_get_main_queue(), ^{
118
+ UITabBarController *controller = weakSelf;
119
+ if (!controller)
120
+ return;
121
+
122
+ [controller rnn_setTabBarTestIDRetryScheduled:NO];
123
+ [controller syncTabBarItemTestIDs];
124
+ });
125
+ }
126
+
19
127
  - (void)setTabBarStyle:(UIBarStyle)barStyle {
20
128
  self.tabBar.barStyle = barStyle;
21
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "8.7.9",
3
+ "version": "8.8.1-snapshot.2373",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,