-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
84 lines (77 loc) · 2.54 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React from 'react';
import {AppRegistry, StyleSheet, Text, View ,TouchableOpacity,TextInput} from 'react-native';
import { DeviceEventEmitter , NativeModules } from 'react-native';
import AuthReactNative from './auth.index';
class HelloWorld extends React.Component {
constructor(props) {
super(props);
this.state={
text:' '
}
}
componentDidMount(): void {
DeviceEventEmitter.addListener('customEventName', function(e: Event) {
// handle event and you will get a value in event object, you can log it here
// console.log('log:::',e)
// alert(JSON.stringify(e))
});
DeviceEventEmitter.addListener('qrCode', function(e: Event) {
// console.warn('log:: qrCode : ', e);
});
// console.log('log:: this.props ',this.props);
// console.log('log:: NativeModules',NativeModules)
}
render() {
return (
<View style={styles.container}>
<Text style={styles.hello}>this is First React activity (Screen 1)</Text>
<View style={{width:100,height:40,backgroundColor:'grey'}}>
<TextInput style={{width:'100%',height:'100%'}} value={this.state.text} onChangeText={e=>this.setState({text:e})} />
</View>
<TouchableOpacity
onPress={()=>{
NativeModules.ActivityStarter.navigateToActivity('MainActivity',this.state.text)
// const nativeComm = NativeModules.ReactNativeBridge;
// if(nativeComm){
// nativeComm.saveUser({name:'ali'});
// }
}}
style={{backgroundColor:'#a5def1'}}
>
<Text>
press To Back Native Activity
</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={()=>{
NativeModules.ActivityStarter.navigateToActivity('AuthReactActivity',this.state.text)
// const nativeComm = NativeModules.ReactNativeBridge;
// if(nativeComm){
// nativeComm.saveUser({name:'ali'});
// }
}}
style={{backgroundColor:'#a5def1',marginVertical:30}}
>
<Text>
navigate Auth React Activity
</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems:'center'
},
hello: {
fontSize: 20,
textAlign: 'center',
margin: 10,
color:'blue'
},
});
AppRegistry.registerComponent('AuthReactNativeApp', () => AuthReactNative);
AppRegistry.registerComponent('MyReactNativeApp', () => HelloWorld);