react-native-navigation 7.33.3 → 7.34.0

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.
@@ -0,0 +1,36 @@
1
+ #import "AppDelegate.h"
2
+
3
+ #import <React/RCTBundleURLProvider.h>
4
+
5
+ @implementation AppDelegate
6
+
7
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
8
+ {
9
+ self.moduleName = @"app";
10
+ // You can add your custom initial props in the dictionary below.
11
+ // They will be passed down to the ViewController used by React Native.
12
+ self.initialProps = @{};
13
+
14
+ return [super application:application didFinishLaunchingWithOptions:launchOptions];
15
+ }
16
+
17
+ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
18
+ {
19
+ #if DEBUG
20
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
21
+ #else
22
+ return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
23
+ #endif
24
+ }
25
+
26
+ /// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
27
+ ///
28
+ /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
29
+ /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
30
+ /// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
31
+ - (BOOL)concurrentRootEnabled
32
+ {
33
+ return true;
34
+ }
35
+
36
+ @end
@@ -0,0 +1,35 @@
1
+ package com.app;
2
+
3
+ import com.reactnativenavigation.NavigationActivity;
4
+ import com.facebook.react.ReactActivityDelegate;
5
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
6
+ import com.facebook.react.defaults.DefaultReactActivityDelegate;
7
+
8
+ public class MainActivity extends NavigationActivity {
9
+
10
+ /**
11
+ * Returns the name of the main component registered from JavaScript. This is used to schedule
12
+ * rendering of the component.
13
+ */
14
+ @Override
15
+ protected String getMainComponentName() {
16
+ return "app";
17
+ }
18
+
19
+ /**
20
+ * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
21
+ * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
22
+ * (aka React 18) with two boolean flags.
23
+ */
24
+ @Override
25
+ protected ReactActivityDelegate createReactActivityDelegate() {
26
+ return new DefaultReactActivityDelegate(
27
+ this,
28
+ getMainComponentName(),
29
+ // If you opted-in for the New Architecture, we enable the Fabric Renderer.
30
+ DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
31
+ // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
32
+ DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
33
+ );
34
+ }
35
+ }
@@ -66,3 +66,21 @@ public class MainActivity extends NavigationActivity {
66
66
  }
67
67
  "
68
68
  `;
69
+
70
+
71
+ exports[`activityLinker should work for RN 0.71 1`] = `
72
+ "package com.app;
73
+
74
+ import com.reactnativenavigation.NavigationActivity;
75
+ import com.facebook.react.ReactActivityDelegate;
76
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
77
+ import com.facebook.react.defaults.DefaultReactActivityDelegate;
78
+
79
+ public class MainActivity extends NavigationActivity {
80
+
81
+
82
+
83
+
84
+ }
85
+ "
86
+ `;
@@ -239,3 +239,49 @@ static NSString *const kRNConcurrentRoot = @\\"concurrentRoot\\";
239
239
  @end
240
240
  "
241
241
  `;
242
+
243
+ exports[`appDelegateLinker should work for RN 0.71 1`] = `
244
+ "#import \\"AppDelegate.h\\"
245
+ #import <ReactNativeNavigation/ReactNativeNavigation.h>
246
+
247
+ #import <React/RCTBundleURLProvider.h>
248
+
249
+ @implementation AppDelegate
250
+
251
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
252
+ {
253
+ RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
254
+ [ReactNativeNavigation bootstrapWithBridge:bridge];
255
+ // You can add your custom initial props in the dictionary below.
256
+ // They will be passed down to the ViewController used by React Native.
257
+ self.initialProps = @{};
258
+
259
+ return YES;
260
+ }
261
+
262
+ - (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge {
263
+ return [ReactNativeNavigation extraModulesForBridge:bridge];
264
+ }
265
+
266
+ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
267
+ {
268
+ #if DEBUG
269
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@\\"index\\"];
270
+ #else
271
+ return [[NSBundle mainBundle] URLForResource:@\\"main\\" withExtension:@\\"jsbundle\\"];
272
+ #endif
273
+ }
274
+
275
+ /// This method controls whether the \`concurrentRoot\`feature of React18 is turned on or off.
276
+ ///
277
+ /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
278
+ /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
279
+ /// @return: \`true\` if the \`concurrentRoot\` feature is enabled. Otherwise, it returns \`false\`.
280
+ - (BOOL)concurrentRootEnabled
281
+ {
282
+ return true;
283
+ }
284
+
285
+ @end
286
+ "
287
+ `;
@@ -105,7 +105,7 @@ class ActivityLinker {
105
105
  if (this._hasCreateReactActivityDelegate(activityContent)) {
106
106
  debugn(' Removing createReactActivityDelegate function');
107
107
  return activityContent.replace(
108
- /\/\*\*(\s+\*.+)+\s+@Override\s+protected ReactActivityDelegate createReactActivityDelegate\(\) {(\s*[\w*(,);])*\s*}/,
108
+ /\/\*\*\s*\n([^\*]|(\*(?!\/)))*\*\/\s*@Override\s*protected\s*ReactActivityDelegate\s*createReactActivityDelegate\s*\(\)\s*{\s*return((.|\r|\s)*?)}/,
109
109
  ''
110
110
  );
111
111
  } else {
@@ -115,7 +115,7 @@ class ActivityLinker {
115
115
  }
116
116
 
117
117
  _hasCreateReactActivityDelegate(activityContent) {
118
- return /\/\*\*(\s+\*.+)+\s+@Override\s+protected ReactActivityDelegate createReactActivityDelegate\(\) {(\s*[\w*(,);])*\s*}/.test(
118
+ return /\/\*\*\s*\n([^\*]|(\*(?!\/)))*\*\/\s*@Override\s*protected\s*ReactActivityDelegate\s*createReactActivityDelegate\s*\(\)\s*{\s*return((.|\r|\s)*?)}/.test(
119
119
  activityContent
120
120
  );
121
121
  }
@@ -100,12 +100,22 @@ class AppDelegateLinker {
100
100
  return content;
101
101
  }
102
102
 
103
- debugn(' Bootstrapping Navigation');
104
- return content.replace(
105
- /RCTBridge.*];/,
106
- 'RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];\n' +
107
- '[ReactNativeNavigation bootstrapWithBridge:bridge];'
108
- );
103
+ debugn(' Bootstrapping Navigation !!!!');
104
+ return content
105
+ .replace(
106
+ /RCTBridge.*];/,
107
+ 'RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];\n' +
108
+ '[ReactNativeNavigation bootstrapWithBridge:bridge];'
109
+ )
110
+ .replace(
111
+ /return \[super application:application didFinishLaunchingWithOptions:launchOptions\];/,
112
+ 'return YES;'
113
+ )
114
+ .replace(
115
+ /self.moduleName.*;/,
116
+ 'RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];\n' +
117
+ ' [ReactNativeNavigation bootstrapWithBridge:bridge];'
118
+ );
109
119
  }
110
120
 
111
121
  _doesBootstrapNavigation(content) {
@@ -3,7 +3,7 @@ var path = require('./path');
3
3
  var fs = require('fs');
4
4
  var { warnn, errorn, logn, infon, debugn } = require('./log');
5
5
  var { insertString } = require('./stringUtils');
6
- var DEFAULT_KOTLIN_VERSION = '1.4.31';
6
+ var DEFAULT_KOTLIN_VERSION = '1.5.31';
7
7
  // This should be the minSdkVersion required for RNN.
8
8
  var DEFAULT_MIN_SDK_VERSION = 21;
9
9
 
@@ -80,7 +80,7 @@ class GradleLinker {
80
80
  return insertString(
81
81
  contents,
82
82
  match.index,
83
- `classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${DEFAULT_KOTLIN_VERSION}"\n `
83
+ `classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$RNNKotlinVersion"\n `
84
84
  );
85
85
  } else {
86
86
  throw new Error(' Could not add kotlin plugin dependency');
package/jest.config.js CHANGED
@@ -8,6 +8,7 @@ module.exports = {
8
8
  },
9
9
  roots: [
10
10
  '<rootDir>/lib/src/',
11
+ '<rootDir>/lib/Mock/',
11
12
  '<rootDir>/playground/src/',
12
13
  '<rootDir>/integration/',
13
14
  '<rootDir>/scripts/',
@@ -23,8 +24,8 @@ module.exports = {
23
24
  '<rootDir>/playground/img/layouts@2x.png',
24
25
  },
25
26
  collectCoverageFrom: [
26
- 'lib/src/**/*.ts',
27
- 'lib/src/**/*.tsx',
27
+ 'lib/src/**/*.(ts|tsx)',
28
+ 'lib/Mock/**/*.(ts|tsx)',
28
29
  'integration/**/*.js',
29
30
  '!lib/dist/index.js',
30
31
  '!lib/dist/Navigation.js',
@@ -4,9 +4,10 @@ import { switchTabByIndex } from '../actions/layoutActions';
4
4
  import ParentNode from './ParentNode';
5
5
 
6
6
  export default class BottomTabsNode extends ParentNode {
7
- selectedIndex: number = 0;
7
+ selectedIndex: number;
8
8
  constructor(layout: any, parentNode?: ParentNode) {
9
9
  super(layout, 'BottomTabs', parentNode);
10
+ this.selectedIndex = layout.data?.options?.bottomTabs?.currentTabIndex || 0;
10
11
  }
11
12
 
12
13
  mergeOptions(options: Options) {
@@ -5,9 +5,10 @@ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
5
5
  const layoutActions_1 = require("../actions/layoutActions");
6
6
  const ParentNode_1 = (0, tslib_1.__importDefault)(require("./ParentNode"));
7
7
  class BottomTabsNode extends ParentNode_1.default {
8
- selectedIndex = 0;
8
+ selectedIndex;
9
9
  constructor(layout, parentNode) {
10
10
  super(layout, 'BottomTabs', parentNode);
11
+ this.selectedIndex = layout.data?.options?.bottomTabs?.currentTabIndex || 0;
11
12
  }
12
13
  mergeOptions(options) {
13
14
  super.mergeOptions(options);
@@ -46,7 +46,7 @@ class ComponentWrapper {
46
46
  componentEventsObserver.unmounted(this.state.componentId);
47
47
  }
48
48
  render() {
49
- return (React.createElement(GeneratedComponentClass, { ...this.state.allProps, componentId: this.state.componentId }));
49
+ return (React.createElement(GeneratedComponentClass, { ...this.state.allProps, componentId: this.state.componentId, componentName: componentName }));
50
50
  }
51
51
  _assertComponentId() {
52
52
  if (!this.props.componentId) {
@@ -1,3 +1,4 @@
1
1
  export interface NavigationComponentProps {
2
2
  componentId: string;
3
+ componentName: string;
3
4
  }
@@ -18,7 +18,7 @@
18
18
 
19
19
  - (UIImage *)createEnabledIcon:(RNNButtonOptions *)buttonOptions {
20
20
  UIColor *backgroundColor = [buttonOptions.iconBackground.color withDefault:UIColor.clearColor];
21
- UIColor *tintColor = [buttonOptions.color withDefault:nil];
21
+ UIColor *tintColor = buttonOptions.resolveColor;
22
22
 
23
23
  return [self createIcon:buttonOptions tintColor:tintColor backgroundColor:backgroundColor];
24
24
  }
@@ -22,10 +22,11 @@
22
22
  @property(nonatomic, strong) Bool *selectTabOnPress;
23
23
  @property(nonatomic, strong) RNNComponentOptions *component;
24
24
  @property(nonatomic, strong) RNNIconBackgroundOptions *iconBackground;
25
+ @property(nonatomic, strong) Bool *disableIconTint;
25
26
 
26
27
  - (RNNButtonOptions *)withDefault:(RNNButtonOptions *)defaultOptions;
27
28
 
28
- - (Color *)resolveColor;
29
+ - (UIColor *)resolveColor;
29
30
 
30
31
  - (RNNButtonOptions *)withDefaultColor:(Color *)color disabledColor:(Color *)disabledColor;
31
32
 
@@ -1,4 +1,5 @@
1
1
  #import "RNNButtonOptions.h"
2
+ #import "NullColor.h"
2
3
 
3
4
  @implementation RNNButtonOptions
4
5
 
@@ -23,6 +24,7 @@
23
24
  self.iconBackground = [[RNNIconBackgroundOptions alloc] initWithDict:dict[@"iconBackground"]
24
25
  enabled:self.enabled];
25
26
  self.systemItem = [TextParser parse:dict key:@"systemItem"];
27
+ self.disableIconTint = [BoolParser parse:dict key:@"disableIconTint"];
26
28
 
27
29
  return self;
28
30
  }
@@ -46,6 +48,7 @@
46
48
  newOptions.selectTabOnPress = self.selectTabOnPress.copy;
47
49
  newOptions.iconBackground = self.iconBackground.copy;
48
50
  newOptions.systemItem = self.systemItem.copy;
51
+ newOptions.disableIconTint = self.disableIconTint.copy;
49
52
  return newOptions;
50
53
  }
51
54
 
@@ -83,6 +86,8 @@
83
86
  self.selectTabOnPress = options.selectTabOnPress;
84
87
  if (options.systemItem.hasValue)
85
88
  self.systemItem = options.systemItem;
89
+ if (options.disableIconTint.hasValue)
90
+ self.disableIconTint = options.disableIconTint;
86
91
  }
87
92
 
88
93
  - (BOOL)shouldCreateCustomView {
@@ -93,11 +98,13 @@
93
98
  return [self.enabled withDefault:YES];
94
99
  }
95
100
 
96
- - (Color *)resolveColor {
101
+ - (UIColor *)resolveColor {
102
+ if ([_disableIconTint withDefault:NO])
103
+ return NullColor.new.get;
97
104
  if (![_enabled withDefault:YES] && _disabledColor.hasValue)
98
- return _disabledColor;
105
+ return _disabledColor.get;
99
106
  else
100
- return _color;
107
+ return [_color withDefault:nil];
101
108
  }
102
109
 
103
110
  - (RNNButtonOptions *)withDefault:(RNNButtonOptions *)defaultOptions {
@@ -139,17 +139,16 @@
139
139
  [self applyDisabledTitleTextAttributes:buttonOptions];
140
140
  }
141
141
 
142
- - (void)applyColor:(Color *)color {
143
- if (color.hasValue) {
142
+ - (void)applyColor:(UIColor *)color {
143
+ if (color) {
144
144
  NSMutableDictionary *titleTextAttributes = [NSMutableDictionary
145
145
  dictionaryWithDictionary:[self titleTextAttributesForState:UIControlStateNormal]];
146
- [titleTextAttributes setValue:color.get forKey:NSForegroundColorAttributeName];
146
+ [titleTextAttributes setValue:color forKey:NSForegroundColorAttributeName];
147
147
  [self setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
148
148
  [self setTitleTextAttributes:titleTextAttributes forState:UIControlStateHighlighted];
149
+ self.tintColor = color;
149
150
  } else
150
151
  self.image = [self.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
151
-
152
- self.tintColor = color.get;
153
152
  }
154
153
 
155
154
  - (void)mergeBackgroundColor:(Color *)color {
@@ -159,7 +158,7 @@
159
158
 
160
159
  - (void)mergeColor:(Color *)color {
161
160
  _buttonOptions.color = color;
162
- [self applyColor:color];
161
+ [self applyColor:color.get];
163
162
  [self redrawIcon];
164
163
  }
165
164
 
@@ -79,7 +79,11 @@ export class ComponentWrapper {
79
79
 
80
80
  render() {
81
81
  return (
82
- <GeneratedComponentClass {...this.state.allProps} componentId={this.state.componentId} />
82
+ <GeneratedComponentClass
83
+ {...this.state.allProps}
84
+ componentId={this.state.componentId}
85
+ componentName={componentName}
86
+ />
83
87
  );
84
88
  }
85
89
 
@@ -1,3 +1,4 @@
1
1
  export interface NavigationComponentProps {
2
2
  componentId: string;
3
+ componentName: string;
3
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.33.3",
3
+ "version": "7.34.0",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,