-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathApp.js
119 lines (107 loc) · 2.59 KB
/
App.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, {Component} from 'react';
import {
Platform,
StyleSheet,
Text,
View,
TouchableOpacity
} from 'react-native';
import LiveView from './src'
export default class App extends Component<{}> {
constructor(props) {
super(props);
this.state = {
showLive: false,
err: undefined
};
}
componentDidMount() {
const oneArr = [
{id:0, name: 'sam0'},
{id:1, name: 'sam1'},
{id:2, name: 'sam2'},
{id:3, name: 'sam3'},
{id:4, name: 'sam4'}
];
const twoArr = [
{id:0, name: 'sam0'},
{id:5, name: 'Max5'},
{id:6, name: 'Max6'},
{id:7, name: 'Max7'},
{id:2, name: 'sam2'}
];
let mergeObj = {};
[...oneArr, ...twoArr].map(v=>{
mergeObj[v.id] = v
});
const mergeArr = Object.values(mergeObj);
console.log(mergeArr);
}
handleJoin = () => {
this.setState({
showLive: true
})
};
handleCancel = (err) => {
this.setState({
showLive: false,
err
})
};
render() {
const {showLive, err} = this.state;
if (showLive) {
return (
<LiveView
onCancel={this.handleCancel}
/>
)
} else {
return (
<View style={styles.container}>
{!!err &&
<Text>错误代码 {err}</Text>
}
<TouchableOpacity
style={styles.button}
onPress={this.handleJoin}
>
<Text style={{color:'#fff'}}>点击进入房间 开始视频</Text>
</TouchableOpacity>
</View>
);
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
button: {
height: 44,
paddingHorizontal:20,
backgroundColor:'#6A71DD',
borderRadius:10,
justifyContent:'center',
alignItems:'center',
marginTop: 10
}
});