Daniel Zlotin пре 8 година
родитељ
комит
8546765f0e

+ 18
- 4
ios/RNN.m Прегледај датотеку

@@ -3,9 +3,10 @@
3 3
 #import "RNNEventEmitter.h"
4 4
 
5 5
 #import "RCTBridge.h"
6
+#import "RNNSplashScreen.h"
6 7
 
7 8
 @interface RNN()
8
-
9
+@property RNNEventEmitter* eventEmitter;
9 10
 @end
10 11
 
11 12
 @implementation RNN
@@ -28,19 +29,32 @@
28 29
 }
29 30
 
30 31
 -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions
32
+{
33
+	self.eventEmitter = [RNNEventEmitter new];
34
+	
35
+	UIApplication.sharedApplication.delegate.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
36
+	UIApplication.sharedApplication.delegate.window.backgroundColor = [UIColor whiteColor];
37
+	
38
+	[RNNSplashScreen show];
39
+	
40
+	[self registerForJsEvents];
41
+	// this will load the JS bundle
42
+	bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation moduleProvider:nil launchOptions:launchOptions];
43
+}
44
+
45
+-(void)registerForJsEvents
31 46
 {
32 47
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptLoaded) name:RCTJavaScriptDidLoadNotification object:nil];
48
+	
33 49
 #pragma GCC diagnostic push
34 50
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
35 51
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptDevReload) name:RCTReloadNotification object:nil];
36 52
 #pragma GCC diagnostic pop
37
-	// this will load the JS bundle
38
-	bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation moduleProvider:nil launchOptions:launchOptions];
39 53
 }
40 54
 
41 55
 -(void)onJavaScriptLoaded
42 56
 {
43
-	[RNNEventEmitter sendOnAppLaunched];
57
+	[self.eventEmitter sendOnAppLaunched];
44 58
 }
45 59
 
46 60
 -(void)onJavaScriptDevReload

+ 1
- 1
ios/RNNEventEmitter.h Прегледај датотеку

@@ -6,6 +6,6 @@
6 6
 
7 7
 @interface RNNEventEmitter : RCTEventEmitter <RCTBridgeModule>
8 8
 
9
-+(void)sendOnAppLaunched;
9
+-(void)sendOnAppLaunched;
10 10
 
11 11
 @end

+ 4
- 4
ios/RNNEventEmitter.m Прегледај датотеку

@@ -6,19 +6,19 @@
6 6
 
7 7
 RCT_EXPORT_MODULE();
8 8
 
9
-static NSString* const onAppLaunched = @"onAppLaunched";
9
+static NSString* const onAppLaunched = @"RNN_onAppLaunched";
10 10
 
11 11
 -(NSArray<NSString *> *)supportedEvents
12 12
 {
13 13
 	return @[onAppLaunched];
14 14
 }
15 15
 
16
-+(void)sendOnAppLaunched
16
+-(void)sendOnAppLaunched
17 17
 {
18
-	[RNNEventEmitter send:onAppLaunched body:nil];
18
+	[self send:onAppLaunched body:nil];
19 19
 }
20 20
 
21
-+(void)send:(NSString *)eventName body:(id)body
21
+-(void)send:(NSString *)eventName body:(id)body
22 22
 {
23 23
 	[[RNN.instance.bridge moduleForClass:[RNNEventEmitter class]] sendEventWithName:eventName body:body];
24 24
 }

+ 1
- 7
ios/ReactNativeNavigation.m Прегледај датотеку

@@ -1,7 +1,6 @@
1 1
 
2 2
 #import "ReactNativeNavigation.h"
3 3
 
4
-#import "RNNSplashScreen.h"
5 4
 #import "RNN.h"
6 5
 
7 6
 @implementation ReactNativeNavigation
@@ -12,12 +11,7 @@
12 11
 }
13 12
 
14 13
 +(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions
15
-{
16
-	UIApplication.sharedApplication.delegate.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
17
-	UIApplication.sharedApplication.delegate.window.backgroundColor = [UIColor whiteColor];
18
-	
19
-	[RNNSplashScreen show];
20
-	
14
+{	
21 15
 	[RNN.instance bootstrap:jsCodeLocation launchOptions:launchOptions];
22 16
 }
23 17
 

+ 2
- 2
ios/ReactNativeNavigation.xcodeproj/project.pbxproj Прегледај датотеку

@@ -87,10 +87,10 @@
87 87
 			children = (
88 88
 				7BA500731E2544B9001B9E1B /* ReactNativeNavigation.h */,
89 89
 				7BA500741E2544B9001B9E1B /* ReactNativeNavigation.m */,
90
-				7BD721F31E2D3AA100724059 /* Bridge */,
91
-				7B1E4C4B1E2D173700C3A525 /* Controllers */,
92 90
 				7BBFE55F1E253F97002A6182 /* RNN.h */,
93 91
 				7BBFE5601E253F97002A6182 /* RNN.m */,
92
+				7BD721F31E2D3AA100724059 /* Bridge */,
93
+				7B1E4C4B1E2D173700C3A525 /* Controllers */,
94 94
 				D8AFADBE1BEE6F3F00A4592D /* Products */,
95 95
 			);
96 96
 			sourceTree = "<group>";

+ 2
- 1
playground/src/containers/SimpleTabScreen.js Прегледај датотеку

@@ -1,7 +1,7 @@
1 1
 import React, { Component } from 'react';
2 2
 import { View, Text } from 'react-native';
3 3
 
4
-export default class SimpleTabScreen extends Component {
4
+class SimpleTabScreen extends Component {
5 5
   render() {
6 6
     return (
7 7
       <View style={styles.root}>
@@ -10,6 +10,7 @@ export default class SimpleTabScreen extends Component {
10 10
     );
11 11
   }
12 12
 }
13
+export default SimpleTabScreen;
13 14
 
14 15
 const styles = {
15 16
   root: {

+ 3
- 1
playground/src/containers/WelcomeScreen.js Прегледај датотеку

@@ -3,7 +3,7 @@ import { View, Text, Button } from 'react-native';
3 3
 
4 4
 import Navigation from 'react-native-navigation';
5 5
 
6
-export default class WelcomeScreen extends Component {
6
+class WelcomeScreen extends Component {
7 7
   render() {
8 8
     return (
9 9
       <View style={styles.root}>
@@ -31,6 +31,8 @@ export default class WelcomeScreen extends Component {
31 31
   }
32 32
 }
33 33
 
34
+export default WelcomeScreen;
35
+
34 36
 const styles = {
35 37
   root: {
36 38
     flexGrow: 1,