Browse Source

trying to run locally

Daniel Zlotin 7 years ago
parent
commit
8546765f0e

+ 18
- 4
ios/RNN.m View File

3
 #import "RNNEventEmitter.h"
3
 #import "RNNEventEmitter.h"
4
 
4
 
5
 #import "RCTBridge.h"
5
 #import "RCTBridge.h"
6
+#import "RNNSplashScreen.h"
6
 
7
 
7
 @interface RNN()
8
 @interface RNN()
8
-
9
+@property RNNEventEmitter* eventEmitter;
9
 @end
10
 @end
10
 
11
 
11
 @implementation RNN
12
 @implementation RNN
28
 }
29
 }
29
 
30
 
30
 -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions
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
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptLoaded) name:RCTJavaScriptDidLoadNotification object:nil];
47
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptLoaded) name:RCTJavaScriptDidLoadNotification object:nil];
48
+	
33
 #pragma GCC diagnostic push
49
 #pragma GCC diagnostic push
34
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
50
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
35
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptDevReload) name:RCTReloadNotification object:nil];
51
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptDevReload) name:RCTReloadNotification object:nil];
36
 #pragma GCC diagnostic pop
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
 -(void)onJavaScriptLoaded
55
 -(void)onJavaScriptLoaded
42
 {
56
 {
43
-	[RNNEventEmitter sendOnAppLaunched];
57
+	[self.eventEmitter sendOnAppLaunched];
44
 }
58
 }
45
 
59
 
46
 -(void)onJavaScriptDevReload
60
 -(void)onJavaScriptDevReload

+ 1
- 1
ios/RNNEventEmitter.h View File

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

+ 4
- 4
ios/RNNEventEmitter.m View File

6
 
6
 
7
 RCT_EXPORT_MODULE();
7
 RCT_EXPORT_MODULE();
8
 
8
 
9
-static NSString* const onAppLaunched = @"onAppLaunched";
9
+static NSString* const onAppLaunched = @"RNN_onAppLaunched";
10
 
10
 
11
 -(NSArray<NSString *> *)supportedEvents
11
 -(NSArray<NSString *> *)supportedEvents
12
 {
12
 {
13
 	return @[onAppLaunched];
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
 	[[RNN.instance.bridge moduleForClass:[RNNEventEmitter class]] sendEventWithName:eventName body:body];
23
 	[[RNN.instance.bridge moduleForClass:[RNNEventEmitter class]] sendEventWithName:eventName body:body];
24
 }
24
 }

+ 1
- 7
ios/ReactNativeNavigation.m View File

1
 
1
 
2
 #import "ReactNativeNavigation.h"
2
 #import "ReactNativeNavigation.h"
3
 
3
 
4
-#import "RNNSplashScreen.h"
5
 #import "RNN.h"
4
 #import "RNN.h"
6
 
5
 
7
 @implementation ReactNativeNavigation
6
 @implementation ReactNativeNavigation
12
 }
11
 }
13
 
12
 
14
 +(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions
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
 	[RNN.instance bootstrap:jsCodeLocation launchOptions:launchOptions];
15
 	[RNN.instance bootstrap:jsCodeLocation launchOptions:launchOptions];
22
 }
16
 }
23
 
17
 

+ 2
- 2
ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

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

+ 2
- 1
playground/src/containers/SimpleTabScreen.js View File

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

+ 3
- 1
playground/src/containers/WelcomeScreen.js View File

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