react-native-navigation 7.28.1 → 7.30.0-alpha
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.
- package/autolink/fixtures/rn68/AppDelegate.mm.template +108 -0
- package/autolink/fixtures/rn68/MainActivity.java.template +40 -0
- package/autolink/fixtures/rn69/AppDelegate.mm.template +133 -0
- package/autolink/fixtures/rn69/MainActivity.java.template +48 -0
- package/autolink/postlink/__snapshots__/activityLinker.test.js.snap +68 -0
- package/autolink/postlink/__snapshots__/appDelegateLinker.test.js.snap +241 -0
- package/autolink/postlink/activityLinker.js +14 -11
- package/autolink/postlink/appDelegateLinker.js +4 -0
- package/autolink/postlink/path.js +0 -2
- package/jest.config.js +1 -0
- package/lib/Mock/Components/ComponentScreen.tsx +2 -1
- package/lib/Mock/Components/NavigationButton.tsx +8 -4
- package/lib/Mock/Layouts/BottomTabsNode.ts +3 -3
- package/lib/Mock/actions/layoutActions.ts +10 -0
- package/lib/dist/Mock/Components/ComponentScreen.js +2 -1
- package/lib/dist/Mock/Components/NavigationButton.js +8 -4
- package/lib/dist/Mock/Layouts/BottomTabsNode.js +3 -3
- package/lib/dist/Mock/Layouts/LayoutNodeFactory.d.ts +1 -1
- package/lib/dist/Mock/actions/layoutActions.d.ts +2 -0
- package/lib/dist/Mock/actions/layoutActions.js +12 -0
- package/lib/ios/RNNDynamicIconCreator.m +2 -2
- package/package.json +2 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#import "AppDelegate.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTBridge.h>
|
|
4
|
+
#import <React/RCTBundleURLProvider.h>
|
|
5
|
+
#import <React/RCTRootView.h>
|
|
6
|
+
|
|
7
|
+
#import <React/RCTAppSetupUtils.h>
|
|
8
|
+
|
|
9
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
10
|
+
#import <React/CoreModulesPlugins.h>
|
|
11
|
+
#import <React/RCTCxxBridgeDelegate.h>
|
|
12
|
+
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
|
|
13
|
+
#import <React/RCTSurfacePresenter.h>
|
|
14
|
+
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
|
15
|
+
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
16
|
+
|
|
17
|
+
#import <react/config/ReactNativeConfig.h>
|
|
18
|
+
|
|
19
|
+
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
|
|
20
|
+
RCTTurboModuleManager *_turboModuleManager;
|
|
21
|
+
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
|
|
22
|
+
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
|
|
23
|
+
facebook::react::ContextContainer::Shared _contextContainer;
|
|
24
|
+
}
|
|
25
|
+
@end
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
@implementation AppDelegate
|
|
29
|
+
|
|
30
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
31
|
+
{
|
|
32
|
+
RCTAppSetupPrepareApp(application);
|
|
33
|
+
|
|
34
|
+
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
|
35
|
+
|
|
36
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
37
|
+
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
|
|
38
|
+
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
|
|
39
|
+
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
|
|
40
|
+
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
|
|
41
|
+
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"app", nil);
|
|
45
|
+
|
|
46
|
+
if (@available(iOS 13.0, *)) {
|
|
47
|
+
rootView.backgroundColor = [UIColor systemBackgroundColor];
|
|
48
|
+
} else {
|
|
49
|
+
rootView.backgroundColor = [UIColor whiteColor];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
53
|
+
UIViewController *rootViewController = [UIViewController new];
|
|
54
|
+
rootViewController.view = rootView;
|
|
55
|
+
self.window.rootViewController = rootViewController;
|
|
56
|
+
[self.window makeKeyAndVisible];
|
|
57
|
+
return YES;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
61
|
+
{
|
|
62
|
+
#if DEBUG
|
|
63
|
+
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
|
|
64
|
+
#else
|
|
65
|
+
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
66
|
+
#endif
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
70
|
+
|
|
71
|
+
#pragma mark - RCTCxxBridgeDelegate
|
|
72
|
+
|
|
73
|
+
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
|
74
|
+
{
|
|
75
|
+
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
|
|
76
|
+
delegate:self
|
|
77
|
+
jsInvoker:bridge.jsCallInvoker];
|
|
78
|
+
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#pragma mark RCTTurboModuleManagerDelegate
|
|
82
|
+
|
|
83
|
+
- (Class)getModuleClassFromName:(const char *)name
|
|
84
|
+
{
|
|
85
|
+
return RCTCoreModulesClassProvider(name);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
89
|
+
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
|
|
90
|
+
{
|
|
91
|
+
return nullptr;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
95
|
+
initParams:
|
|
96
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
97
|
+
{
|
|
98
|
+
return nullptr;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
|
102
|
+
{
|
|
103
|
+
return RCTAppSetupDefaultModuleFromClass(moduleClass);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#endif
|
|
107
|
+
|
|
108
|
+
@end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.app;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactActivity;
|
|
4
|
+
import com.facebook.react.ReactActivityDelegate;
|
|
5
|
+
import com.facebook.react.ReactRootView;
|
|
6
|
+
|
|
7
|
+
public class MainActivity extends ReactActivity {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
|
11
|
+
* rendering of the component.
|
|
12
|
+
*/
|
|
13
|
+
@Override
|
|
14
|
+
protected String getMainComponentName() {
|
|
15
|
+
return "app";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
|
|
20
|
+
* you can specify the rendered you wish to use (Fabric or the older renderer).
|
|
21
|
+
*/
|
|
22
|
+
@Override
|
|
23
|
+
protected ReactActivityDelegate createReactActivityDelegate() {
|
|
24
|
+
return new MainActivityDelegate(this, getMainComponentName());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public static class MainActivityDelegate extends ReactActivityDelegate {
|
|
28
|
+
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
|
|
29
|
+
super(activity, mainComponentName);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Override
|
|
33
|
+
protected ReactRootView createRootView() {
|
|
34
|
+
ReactRootView reactRootView = new ReactRootView(getContext());
|
|
35
|
+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
|
|
36
|
+
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
|
|
37
|
+
return reactRootView;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#import "AppDelegate.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTBridge.h>
|
|
4
|
+
#import <React/RCTBundleURLProvider.h>
|
|
5
|
+
#import <React/RCTRootView.h>
|
|
6
|
+
|
|
7
|
+
#import <React/RCTAppSetupUtils.h>
|
|
8
|
+
|
|
9
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
10
|
+
#import <React/CoreModulesPlugins.h>
|
|
11
|
+
#import <React/RCTCxxBridgeDelegate.h>
|
|
12
|
+
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
|
|
13
|
+
#import <React/RCTSurfacePresenter.h>
|
|
14
|
+
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
|
15
|
+
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
16
|
+
|
|
17
|
+
#import <react/config/ReactNativeConfig.h>
|
|
18
|
+
|
|
19
|
+
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
|
20
|
+
|
|
21
|
+
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
|
|
22
|
+
RCTTurboModuleManager *_turboModuleManager;
|
|
23
|
+
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
|
|
24
|
+
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
|
|
25
|
+
facebook::react::ContextContainer::Shared _contextContainer;
|
|
26
|
+
}
|
|
27
|
+
@end
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
@implementation AppDelegate
|
|
31
|
+
|
|
32
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
33
|
+
{
|
|
34
|
+
RCTAppSetupPrepareApp(application);
|
|
35
|
+
|
|
36
|
+
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
|
37
|
+
|
|
38
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
39
|
+
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
|
|
40
|
+
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
|
|
41
|
+
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
|
|
42
|
+
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
|
|
43
|
+
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
NSDictionary *initProps = [self prepareInitialProps];
|
|
47
|
+
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"app", initProps);
|
|
48
|
+
|
|
49
|
+
if (@available(iOS 13.0, *)) {
|
|
50
|
+
rootView.backgroundColor = [UIColor systemBackgroundColor];
|
|
51
|
+
} else {
|
|
52
|
+
rootView.backgroundColor = [UIColor whiteColor];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
56
|
+
UIViewController *rootViewController = [UIViewController new];
|
|
57
|
+
rootViewController.view = rootView;
|
|
58
|
+
self.window.rootViewController = rootViewController;
|
|
59
|
+
[self.window makeKeyAndVisible];
|
|
60
|
+
return YES;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
|
|
64
|
+
///
|
|
65
|
+
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
|
|
66
|
+
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
|
|
67
|
+
/// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
|
|
68
|
+
- (BOOL)concurrentRootEnabled
|
|
69
|
+
{
|
|
70
|
+
// Switch this bool to turn on and off the concurrent root
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
- (NSDictionary *)prepareInitialProps
|
|
75
|
+
{
|
|
76
|
+
NSMutableDictionary *initProps = [NSMutableDictionary new];
|
|
77
|
+
|
|
78
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
79
|
+
initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
|
|
80
|
+
#endif
|
|
81
|
+
|
|
82
|
+
return initProps;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
86
|
+
{
|
|
87
|
+
#if DEBUG
|
|
88
|
+
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
|
|
89
|
+
#else
|
|
90
|
+
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
91
|
+
#endif
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
95
|
+
|
|
96
|
+
#pragma mark - RCTCxxBridgeDelegate
|
|
97
|
+
|
|
98
|
+
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
|
99
|
+
{
|
|
100
|
+
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
|
|
101
|
+
delegate:self
|
|
102
|
+
jsInvoker:bridge.jsCallInvoker];
|
|
103
|
+
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#pragma mark RCTTurboModuleManagerDelegate
|
|
107
|
+
|
|
108
|
+
- (Class)getModuleClassFromName:(const char *)name
|
|
109
|
+
{
|
|
110
|
+
return RCTCoreModulesClassProvider(name);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
114
|
+
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
|
|
115
|
+
{
|
|
116
|
+
return nullptr;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
120
|
+
initParams:
|
|
121
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
122
|
+
{
|
|
123
|
+
return nullptr;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
|
127
|
+
{
|
|
128
|
+
return RCTAppSetupDefaultModuleFromClass(moduleClass);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#endif
|
|
132
|
+
|
|
133
|
+
@end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package com.app;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactActivity;
|
|
4
|
+
import com.facebook.react.ReactActivityDelegate;
|
|
5
|
+
import com.facebook.react.ReactRootView;
|
|
6
|
+
|
|
7
|
+
public class MainActivity extends ReactActivity {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
|
11
|
+
* rendering of the component.
|
|
12
|
+
*/
|
|
13
|
+
@Override
|
|
14
|
+
protected String getMainComponentName() {
|
|
15
|
+
return "app";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
|
|
20
|
+
* you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
|
|
21
|
+
* (Paper).
|
|
22
|
+
*/
|
|
23
|
+
@Override
|
|
24
|
+
protected ReactActivityDelegate createReactActivityDelegate() {
|
|
25
|
+
return new MainActivityDelegate(this, getMainComponentName());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static class MainActivityDelegate extends ReactActivityDelegate {
|
|
29
|
+
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
|
|
30
|
+
super(activity, mainComponentName);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Override
|
|
34
|
+
protected ReactRootView createRootView() {
|
|
35
|
+
ReactRootView reactRootView = new ReactRootView(getContext());
|
|
36
|
+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
|
|
37
|
+
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
|
|
38
|
+
return reactRootView;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
protected boolean isConcurrentRootEnabled() {
|
|
43
|
+
// If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
|
|
44
|
+
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
|
|
45
|
+
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`activityLinker should work for RN 0.68 1`] = `
|
|
4
|
+
"package com.app;
|
|
5
|
+
|
|
6
|
+
import com.reactnativenavigation.NavigationActivity;
|
|
7
|
+
import com.facebook.react.ReactActivityDelegate;
|
|
8
|
+
import com.facebook.react.ReactRootView;
|
|
9
|
+
|
|
10
|
+
public class MainActivity extends NavigationActivity {
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
public static class MainActivityDelegate extends ReactActivityDelegate {
|
|
17
|
+
public MainActivityDelegate(NavigationActivity activity, String mainComponentName) {
|
|
18
|
+
super(activity, mainComponentName);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Override
|
|
22
|
+
protected ReactRootView createRootView() {
|
|
23
|
+
ReactRootView reactRootView = new ReactRootView(getContext());
|
|
24
|
+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
|
|
25
|
+
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
|
|
26
|
+
return reactRootView;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
"
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
exports[`activityLinker should work for RN 0.69 1`] = `
|
|
34
|
+
"package com.app;
|
|
35
|
+
|
|
36
|
+
import com.reactnativenavigation.NavigationActivity;
|
|
37
|
+
import com.facebook.react.ReactActivityDelegate;
|
|
38
|
+
import com.facebook.react.ReactRootView;
|
|
39
|
+
|
|
40
|
+
public class MainActivity extends NavigationActivity {
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
public static class MainActivityDelegate extends ReactActivityDelegate {
|
|
47
|
+
public MainActivityDelegate(NavigationActivity activity, String mainComponentName) {
|
|
48
|
+
super(activity, mainComponentName);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
protected ReactRootView createRootView() {
|
|
53
|
+
ReactRootView reactRootView = new ReactRootView(getContext());
|
|
54
|
+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
|
|
55
|
+
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
|
|
56
|
+
return reactRootView;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Override
|
|
60
|
+
protected boolean isConcurrentRootEnabled() {
|
|
61
|
+
// If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
|
|
62
|
+
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
|
|
63
|
+
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
"
|
|
68
|
+
`;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`appDelegateLinker should work for RN 0.68 1`] = `
|
|
4
|
+
"#import \\"AppDelegate.h\\"
|
|
5
|
+
#import <ReactNativeNavigation/ReactNativeNavigation.h>
|
|
6
|
+
|
|
7
|
+
#import <React/RCTBridge.h>
|
|
8
|
+
#import <React/RCTBundleURLProvider.h>
|
|
9
|
+
|
|
10
|
+
#import <React/RCTAppSetupUtils.h>
|
|
11
|
+
|
|
12
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
13
|
+
#import <React/CoreModulesPlugins.h>
|
|
14
|
+
#import <React/RCTCxxBridgeDelegate.h>
|
|
15
|
+
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
|
|
16
|
+
#import <React/RCTSurfacePresenter.h>
|
|
17
|
+
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
|
18
|
+
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
19
|
+
|
|
20
|
+
#import <react/config/ReactNativeConfig.h>
|
|
21
|
+
|
|
22
|
+
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
|
|
23
|
+
RCTTurboModuleManager *_turboModuleManager;
|
|
24
|
+
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
|
|
25
|
+
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
|
|
26
|
+
facebook::react::ContextContainer::Shared _contextContainer;
|
|
27
|
+
}
|
|
28
|
+
@end
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
@implementation AppDelegate
|
|
32
|
+
|
|
33
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
34
|
+
{
|
|
35
|
+
RCTAppSetupPrepareApp(application);
|
|
36
|
+
|
|
37
|
+
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
|
38
|
+
[ReactNativeNavigation bootstrapWithBridge:bridge];
|
|
39
|
+
|
|
40
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
41
|
+
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
|
|
42
|
+
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
|
|
43
|
+
_contextContainer->insert(\\"ReactNativeConfig\\", _reactNativeConfig);
|
|
44
|
+
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
|
|
45
|
+
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
return YES;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge {
|
|
56
|
+
return [ReactNativeNavigation extraModulesForBridge:bridge];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
60
|
+
{
|
|
61
|
+
#if DEBUG
|
|
62
|
+
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@\\"index\\"];
|
|
63
|
+
#else
|
|
64
|
+
return [[NSBundle mainBundle] URLForResource:@\\"main\\" withExtension:@\\"jsbundle\\"];
|
|
65
|
+
#endif
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
69
|
+
|
|
70
|
+
#pragma mark - RCTCxxBridgeDelegate
|
|
71
|
+
|
|
72
|
+
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
|
73
|
+
{
|
|
74
|
+
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
|
|
75
|
+
delegate:self
|
|
76
|
+
jsInvoker:bridge.jsCallInvoker];
|
|
77
|
+
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
#pragma mark RCTTurboModuleManagerDelegate
|
|
81
|
+
|
|
82
|
+
- (Class)getModuleClassFromName:(const char *)name
|
|
83
|
+
{
|
|
84
|
+
return RCTCoreModulesClassProvider(name);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
88
|
+
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
|
|
89
|
+
{
|
|
90
|
+
return nullptr;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
94
|
+
initParams:
|
|
95
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
96
|
+
{
|
|
97
|
+
return nullptr;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
|
101
|
+
{
|
|
102
|
+
return RCTAppSetupDefaultModuleFromClass(moduleClass);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
@end
|
|
108
|
+
"
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
exports[`appDelegateLinker should work for RN 0.69 1`] = `
|
|
112
|
+
"#import \\"AppDelegate.h\\"
|
|
113
|
+
#import <ReactNativeNavigation/ReactNativeNavigation.h>
|
|
114
|
+
|
|
115
|
+
#import <React/RCTBridge.h>
|
|
116
|
+
#import <React/RCTBundleURLProvider.h>
|
|
117
|
+
|
|
118
|
+
#import <React/RCTAppSetupUtils.h>
|
|
119
|
+
|
|
120
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
121
|
+
#import <React/CoreModulesPlugins.h>
|
|
122
|
+
#import <React/RCTCxxBridgeDelegate.h>
|
|
123
|
+
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
|
|
124
|
+
#import <React/RCTSurfacePresenter.h>
|
|
125
|
+
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
|
126
|
+
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
127
|
+
|
|
128
|
+
#import <react/config/ReactNativeConfig.h>
|
|
129
|
+
|
|
130
|
+
static NSString *const kRNConcurrentRoot = @\\"concurrentRoot\\";
|
|
131
|
+
|
|
132
|
+
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
|
|
133
|
+
RCTTurboModuleManager *_turboModuleManager;
|
|
134
|
+
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
|
|
135
|
+
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
|
|
136
|
+
facebook::react::ContextContainer::Shared _contextContainer;
|
|
137
|
+
}
|
|
138
|
+
@end
|
|
139
|
+
#endif
|
|
140
|
+
|
|
141
|
+
@implementation AppDelegate
|
|
142
|
+
|
|
143
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
144
|
+
{
|
|
145
|
+
RCTAppSetupPrepareApp(application);
|
|
146
|
+
|
|
147
|
+
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
|
148
|
+
[ReactNativeNavigation bootstrapWithBridge:bridge];
|
|
149
|
+
|
|
150
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
151
|
+
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
|
|
152
|
+
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
|
|
153
|
+
_contextContainer->insert(\\"ReactNativeConfig\\", _reactNativeConfig);
|
|
154
|
+
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
|
|
155
|
+
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
|
|
156
|
+
#endif
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
return YES;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/// This method controls whether the \`concurrentRoot\`feature of React18 is turned on or off.
|
|
166
|
+
///
|
|
167
|
+
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
|
|
168
|
+
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
|
|
169
|
+
/// @return: \`true\` if the \`concurrentRoot\` feture is enabled. Otherwise, it returns \`false\`.
|
|
170
|
+
- (BOOL)concurrentRootEnabled
|
|
171
|
+
{
|
|
172
|
+
// Switch this bool to turn on and off the concurrent root
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
- (NSDictionary *)prepareInitialProps
|
|
177
|
+
{
|
|
178
|
+
NSMutableDictionary *initProps = [NSMutableDictionary new];
|
|
179
|
+
|
|
180
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
181
|
+
initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
|
|
182
|
+
#endif
|
|
183
|
+
|
|
184
|
+
return initProps;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge {
|
|
188
|
+
return [ReactNativeNavigation extraModulesForBridge:bridge];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
192
|
+
{
|
|
193
|
+
#if DEBUG
|
|
194
|
+
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@\\"index\\"];
|
|
195
|
+
#else
|
|
196
|
+
return [[NSBundle mainBundle] URLForResource:@\\"main\\" withExtension:@\\"jsbundle\\"];
|
|
197
|
+
#endif
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
201
|
+
|
|
202
|
+
#pragma mark - RCTCxxBridgeDelegate
|
|
203
|
+
|
|
204
|
+
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
|
205
|
+
{
|
|
206
|
+
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
|
|
207
|
+
delegate:self
|
|
208
|
+
jsInvoker:bridge.jsCallInvoker];
|
|
209
|
+
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#pragma mark RCTTurboModuleManagerDelegate
|
|
213
|
+
|
|
214
|
+
- (Class)getModuleClassFromName:(const char *)name
|
|
215
|
+
{
|
|
216
|
+
return RCTCoreModulesClassProvider(name);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
220
|
+
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
|
|
221
|
+
{
|
|
222
|
+
return nullptr;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
226
|
+
initParams:
|
|
227
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
228
|
+
{
|
|
229
|
+
return nullptr;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
|
233
|
+
{
|
|
234
|
+
return RCTAppSetupDefaultModuleFromClass(moduleClass);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
#endif
|
|
238
|
+
|
|
239
|
+
@end
|
|
240
|
+
"
|
|
241
|
+
`;
|
|
@@ -69,19 +69,24 @@ class ActivityLinker {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
_extendNavigationActivity(activityContent) {
|
|
72
|
+
if (this._hasAlreadyExtendNavigationActivity(activityContent)) {
|
|
73
|
+
warnn(' MainActivity already extends NavigationActivity');
|
|
74
|
+
return activityContent;
|
|
75
|
+
}
|
|
76
|
+
|
|
72
77
|
if (this._doesActivityExtendReactActivity(activityContent)) {
|
|
73
78
|
debugn(' Extending NavigationActivity');
|
|
74
79
|
return activityContent
|
|
75
80
|
.replace(/extends\s+ReactActivity\s*/, 'extends NavigationActivity ')
|
|
81
|
+
.replace(
|
|
82
|
+
/public\s+MainActivityDelegate\s*\(\s*ReactActivity\s+activity,\s*String\s+mainComponentName\s*\)/,
|
|
83
|
+
'public MainActivityDelegate(NavigationActivity activity, String mainComponentName)'
|
|
84
|
+
)
|
|
76
85
|
.replace(
|
|
77
86
|
'import com.facebook.react.ReactActivity;',
|
|
78
87
|
'import com.reactnativenavigation.NavigationActivity;'
|
|
79
88
|
);
|
|
80
89
|
}
|
|
81
|
-
if (this._hasAlreadyExtendReactActivity(activityContent)) {
|
|
82
|
-
warnn(' MainActivity already extends NavigationActivity');
|
|
83
|
-
return activityContent;
|
|
84
|
-
}
|
|
85
90
|
|
|
86
91
|
throw new Error(
|
|
87
92
|
'MainActivity was not successfully replaced. Please check the documentation and proceed manually.'
|
|
@@ -92,8 +97,8 @@ class ActivityLinker {
|
|
|
92
97
|
return /public\s+class\s+MainActivity\s+extends\s+ReactActivity\s*/.test(activityContent);
|
|
93
98
|
}
|
|
94
99
|
|
|
95
|
-
|
|
96
|
-
return /public\s+class\s+MainActivity\s+extends\s+
|
|
100
|
+
_hasAlreadyExtendNavigationActivity(activityContent) {
|
|
101
|
+
return /public\s+class\s+MainActivity\s+extends\s+NavigationActivity\s*/.test(activityContent);
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
_removeCreateReactActivityDelegate(activityContent) {
|
|
@@ -101,19 +106,17 @@ class ActivityLinker {
|
|
|
101
106
|
debugn(' Removing createReactActivityDelegate function');
|
|
102
107
|
return activityContent.replace(
|
|
103
108
|
/\/\*\*(\s+\*.+)+\s+@Override\s+protected ReactActivityDelegate createReactActivityDelegate\(\) {(\s*[\w*(,);])*\s*}/,
|
|
104
|
-
''
|
|
109
|
+
''
|
|
105
110
|
);
|
|
106
111
|
} else {
|
|
107
|
-
warnn(
|
|
108
|
-
' createReactActivityDelegate is already not defined in MainActivity',
|
|
109
|
-
);
|
|
112
|
+
warnn(' createReactActivityDelegate is already not defined in MainActivity');
|
|
110
113
|
return activityContent;
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
_hasCreateReactActivityDelegate(activityContent) {
|
|
115
118
|
return /\/\*\*(\s+\*.+)+\s+@Override\s+protected ReactActivityDelegate createReactActivityDelegate\(\) {(\s*[\w*(,);])*\s*}/.test(
|
|
116
|
-
activityContent
|
|
119
|
+
activityContent
|
|
117
120
|
);
|
|
118
121
|
}
|
|
119
122
|
}
|
|
@@ -153,7 +153,11 @@ class AppDelegateLinker {
|
|
|
153
153
|
/rootViewController\.view\s+=\s+rootView;\s+/,
|
|
154
154
|
/self.window.rootViewController\s+=\s+rootViewController;\s+/,
|
|
155
155
|
/\[self.window\s+makeKeyAndVisible];\s+/,
|
|
156
|
+
// Added from RN 0.69
|
|
157
|
+
/NSDictionary\s+\*initProps\s+=\s+\[self prepareInitialProps];\s+/,
|
|
158
|
+
/UIView \*rootView = RCTAppSetupDefaultRootView\(bridge, @".*", initProps\);/,
|
|
156
159
|
];
|
|
160
|
+
|
|
157
161
|
let elementsRemovedCount = 0;
|
|
158
162
|
|
|
159
163
|
toRemove.forEach((element) => {
|
|
@@ -3,8 +3,6 @@ var ignoreFolders = {
|
|
|
3
3
|
ignore: ['node_modules/**', '**/build/**', '**/Build/**', '**/DerivedData/**', '**/*-tvOS*/**'],
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
var manifestPath = glob.sync('**/AndroidManifest.xml', ignoreFolders)[0];
|
|
7
|
-
|
|
8
6
|
exports.mainActivityJava = glob.sync('**/MainActivity.java', ignoreFolders)[0];
|
|
9
7
|
exports.mainActivityKotlin = glob.sync('**/MainActivity.kt', ignoreFolders)[0];
|
|
10
8
|
var mainApplicationJava = glob.sync('**/MainApplication.java', ignoreFolders)[0];
|
package/jest.config.js
CHANGED
|
@@ -8,6 +8,7 @@ import { connect } from '../connect';
|
|
|
8
8
|
import { TopBar } from './TopBar';
|
|
9
9
|
import { events } from '../Stores/EventsStore';
|
|
10
10
|
import _ from 'lodash';
|
|
11
|
+
import { switchTabByIndex } from '../actions/layoutActions';
|
|
11
12
|
|
|
12
13
|
export const ComponentScreen = connect(
|
|
13
14
|
class extends Component<ComponentProps> {
|
|
@@ -41,7 +42,7 @@ export const ComponentScreen = connect(
|
|
|
41
42
|
tabIndex: i,
|
|
42
43
|
});
|
|
43
44
|
if (_.defaultTo(bottomTabOptions?.selectTabOnPress, true))
|
|
44
|
-
|
|
45
|
+
switchTabByIndex(this.props.layoutNode.getBottomTabs(), i);
|
|
45
46
|
}}
|
|
46
47
|
/>
|
|
47
48
|
<Text>{bottomTabOptions?.badge}</Text>
|
|
@@ -32,10 +32,14 @@ export const NavigationButton = class extends Component<ButtonProps> {
|
|
|
32
32
|
|
|
33
33
|
renderButtonComponent() {
|
|
34
34
|
const { button, componentId } = this.props;
|
|
35
|
-
|
|
35
|
+
// @ts-ignore
|
|
36
36
|
const buttonComponentId = button.component!.componentId;
|
|
37
|
-
|
|
38
|
-
const
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
const ComponentClass = Navigation.mock.store.getComponentClassForName(button.component.name);
|
|
39
|
+
if (!ComponentClass) {
|
|
40
|
+
throw new Error(`Cannot find registered component for: ${button.component?.name}`);
|
|
41
|
+
}
|
|
42
|
+
const ButtonComponent = ComponentClass();
|
|
39
43
|
const props = Navigation.mock.store.getPropsForId(buttonComponentId);
|
|
40
44
|
return (
|
|
41
45
|
<TouchableOpacity
|
|
@@ -52,7 +56,7 @@ export const NavigationButton = class extends Component<ButtonProps> {
|
|
|
52
56
|
}}
|
|
53
57
|
testID={button.testID}
|
|
54
58
|
>
|
|
55
|
-
<
|
|
59
|
+
<ButtonComponent
|
|
56
60
|
key={buttonComponentId}
|
|
57
61
|
{...props}
|
|
58
62
|
componentId={buttonComponentId}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Options } from '../../src/index';
|
|
3
|
-
import {
|
|
3
|
+
import { switchTabByIndex } from '../actions/layoutActions';
|
|
4
4
|
import ParentNode from './ParentNode';
|
|
5
5
|
|
|
6
6
|
export default class BottomTabsNode extends ParentNode {
|
|
@@ -13,7 +13,7 @@ export default class BottomTabsNode extends ParentNode {
|
|
|
13
13
|
super.mergeOptions(options);
|
|
14
14
|
if (options.bottomTabs?.currentTabIndex) {
|
|
15
15
|
this.selectedIndex = options.bottomTabs?.currentTabIndex;
|
|
16
|
-
|
|
16
|
+
switchTabByIndex(this, this.selectedIndex);
|
|
17
17
|
}
|
|
18
18
|
if (options.bottomTabs?.currentTabId) {
|
|
19
19
|
const index = _.findIndex(
|
|
@@ -21,7 +21,7 @@ export default class BottomTabsNode extends ParentNode {
|
|
|
21
21
|
(child) => child.nodeId === options?.bottomTabs?.currentTabId
|
|
22
22
|
);
|
|
23
23
|
if (index !== -1) this.selectedIndex = index;
|
|
24
|
-
|
|
24
|
+
switchTabByIndex(this, this.selectedIndex);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ParentNode from '../Layouts/ParentNode';
|
|
2
|
+
import { LayoutStore } from '../Stores/LayoutStore';
|
|
3
|
+
|
|
4
|
+
export const switchTabByIndex = (bottomTabs: ParentNode | undefined, index: number) => {
|
|
5
|
+
if (bottomTabs) {
|
|
6
|
+
LayoutStore.getVisibleLayout().componentDidDisappear();
|
|
7
|
+
LayoutStore.selectTabIndex(bottomTabs, index);
|
|
8
|
+
LayoutStore.getVisibleLayout().componentDidAppear();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -11,6 +11,7 @@ const connect_1 = require("../connect");
|
|
|
11
11
|
const TopBar_1 = require("./TopBar");
|
|
12
12
|
const EventsStore_1 = require("../Stores/EventsStore");
|
|
13
13
|
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
14
|
+
const layoutActions_1 = require("../actions/layoutActions");
|
|
14
15
|
exports.ComponentScreen = (0, connect_1.connect)(class extends react_1.Component {
|
|
15
16
|
constructor(props) {
|
|
16
17
|
super(props);
|
|
@@ -36,7 +37,7 @@ exports.ComponentScreen = (0, connect_1.connect)(class extends react_1.Component
|
|
|
36
37
|
tabIndex: i,
|
|
37
38
|
});
|
|
38
39
|
if (lodash_1.default.defaultTo(bottomTabOptions?.selectTabOnPress, true))
|
|
39
|
-
|
|
40
|
+
(0, layoutActions_1.switchTabByIndex)(this.props.layoutNode.getBottomTabs(), i);
|
|
40
41
|
} }),
|
|
41
42
|
react_1.default.createElement(react_native_1.Text, null, bottomTabOptions?.badge)));
|
|
42
43
|
});
|
|
@@ -20,10 +20,14 @@ const NavigationButton = class extends react_1.Component {
|
|
|
20
20
|
}
|
|
21
21
|
renderButtonComponent() {
|
|
22
22
|
const { button, componentId } = this.props;
|
|
23
|
-
|
|
23
|
+
// @ts-ignore
|
|
24
24
|
const buttonComponentId = button.component.componentId;
|
|
25
|
-
|
|
26
|
-
const
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
const ComponentClass = react_native_navigation_1.Navigation.mock.store.getComponentClassForName(button.component.name);
|
|
27
|
+
if (!ComponentClass) {
|
|
28
|
+
throw new Error(`Cannot find registered component for: ${button.component?.name}`);
|
|
29
|
+
}
|
|
30
|
+
const ButtonComponent = ComponentClass();
|
|
27
31
|
const props = react_native_navigation_1.Navigation.mock.store.getPropsForId(buttonComponentId);
|
|
28
32
|
return (react_1.default.createElement(react_native_1.TouchableOpacity, { onPress: () => {
|
|
29
33
|
if (this.ref) {
|
|
@@ -35,7 +39,7 @@ const NavigationButton = class extends react_1.Component {
|
|
|
35
39
|
componentId: componentId,
|
|
36
40
|
});
|
|
37
41
|
}, testID: button.testID },
|
|
38
|
-
react_1.default.createElement(
|
|
42
|
+
react_1.default.createElement(ButtonComponent, { key: buttonComponentId, ...props, componentId: buttonComponentId, ref: (ref) => (this.ref = ref) })));
|
|
39
43
|
}
|
|
40
44
|
invokeOnClick(stateNode) {
|
|
41
45
|
if (stateNode.children) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
5
|
-
const
|
|
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
8
|
selectedIndex = 0;
|
|
@@ -13,13 +13,13 @@ class BottomTabsNode extends ParentNode_1.default {
|
|
|
13
13
|
super.mergeOptions(options);
|
|
14
14
|
if (options.bottomTabs?.currentTabIndex) {
|
|
15
15
|
this.selectedIndex = options.bottomTabs?.currentTabIndex;
|
|
16
|
-
|
|
16
|
+
(0, layoutActions_1.switchTabByIndex)(this, this.selectedIndex);
|
|
17
17
|
}
|
|
18
18
|
if (options.bottomTabs?.currentTabId) {
|
|
19
19
|
const index = lodash_1.default.findIndex(this.children, (child) => child.nodeId === options?.bottomTabs?.currentTabId);
|
|
20
20
|
if (index !== -1)
|
|
21
21
|
this.selectedIndex = index;
|
|
22
|
-
|
|
22
|
+
(0, layoutActions_1.switchTabByIndex)(this, this.selectedIndex);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
getVisibleLayout() {
|
|
@@ -3,5 +3,5 @@ import ComponentNode from './ComponentNode';
|
|
|
3
3
|
import Stack from './StackNode';
|
|
4
4
|
import ParentNode from './ParentNode';
|
|
5
5
|
export default class LayoutNodeFactory {
|
|
6
|
-
static create(layout: any, parentNode?: ParentNode):
|
|
6
|
+
static create(layout: any, parentNode?: ParentNode): Stack | BottomTabs | ComponentNode;
|
|
7
7
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.switchTabByIndex = void 0;
|
|
4
|
+
const LayoutStore_1 = require("../Stores/LayoutStore");
|
|
5
|
+
const switchTabByIndex = (bottomTabs, index) => {
|
|
6
|
+
if (bottomTabs) {
|
|
7
|
+
LayoutStore_1.LayoutStore.getVisibleLayout().componentDidDisappear();
|
|
8
|
+
LayoutStore_1.LayoutStore.selectTabIndex(bottomTabs, index);
|
|
9
|
+
LayoutStore_1.LayoutStore.getVisibleLayout().componentDidAppear();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
exports.switchTabByIndex = switchTabByIndex;
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
UIColor *darkBackgroundColor = [backgroundColor resolvedColorWithTraitCollection:[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]];
|
|
15
15
|
UIImage *darkImage = [[self.iconDrawer draw:iconImage
|
|
16
16
|
imageColor:darkColor
|
|
17
|
-
backgroundColor:
|
|
17
|
+
backgroundColor:darkBackgroundColor
|
|
18
18
|
size:iconSize
|
|
19
19
|
cornerRadius:cornerRadius] imageWithInsets:buttonOptions.iconInsets.UIEdgeInsets];
|
|
20
20
|
UIImage *lightImage = [[self.iconDrawer draw:iconImage
|
|
21
21
|
imageColor:lightColor
|
|
22
|
-
backgroundColor:
|
|
22
|
+
backgroundColor:lightBackgroundColor
|
|
23
23
|
size:iconSize
|
|
24
24
|
cornerRadius:cornerRadius] imageWithInsets:buttonOptions.iconInsets.UIEdgeInsets];
|
|
25
25
|
[lightImage.imageAsset registerImage:darkImage withTraitCollection:[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-navigation",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.30.0-alpha",
|
|
4
4
|
"description": "React Native Navigation - truly native navigation for iOS and Android",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"nativePackage": true,
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"pretest-e2e-ios": "npm run build",
|
|
44
44
|
"test-e2e-ios": "node ./scripts/test-e2e --ios",
|
|
45
45
|
"test-e2e-ios-multi": "npm run test-e2e-ios -- --multi",
|
|
46
|
+
"test-autolink": "node ./scripts/test-autolink",
|
|
46
47
|
"test-all": "node ./scripts/test-all",
|
|
47
48
|
"prerelease": "npm run build",
|
|
48
49
|
"release": "node ./scripts/release",
|