-
Notifications
You must be signed in to change notification settings - Fork 4
/
App.js
78 lines (71 loc) · 2.83 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
import React, {Component} from 'react'
import {
View,
Text,
Platform,
TouchableOpacity,
StatusBar,
} from 'react-native'
import TabNavigator from 'react-native-tab-navigator';
import Theme from './Theme'
import TabScan from './Components/TabScan'
import TabFeatures from './Components/TabFeatures'
import TabSetting from './Components/TabSetting'
import ConnectionPanel from './Components/ConnectionPanel'
import ErrorMessagePanel, {ErrorRegistry} from './Components/ErrorMessagePanel'
const Tabs = {
scan: 0,
features: 1,
setting: 2,
}
class App extends Component {
constructor(props) {
super(props);
this.state = {
selectedTab: Tabs.scan,
connectTo: null,
};
}
render() {
let {selectedTab, connectTo} = this.state;
return (
<View style={{flex: 1}}>
<TabNavigator>
<TabNavigator.Item
selected={selectedTab === Tabs.scan}
renderIcon={() => <Text style={{color: '#ccc'}}>SCAN</Text>}
renderSelectedIcon={() => <Text style={{fontWeight: 'bold', color: Theme.color}}>SCAN</Text>}
onPress={() => this.setState({ selectedTab: Tabs.scan })}>
<TabScan onConnect={connectTo => this.setState({connectTo})}/>
</TabNavigator.Item>
<TabNavigator.Item
selected={selectedTab === Tabs.features}
renderIcon={() => <Text style={{color: '#ccc'}}>FEATURES</Text>}
renderSelectedIcon={() => <Text style={{fontWeight: 'bold', color: Theme.color}}>FEATURES</Text>}
onPress={() => this.setState({ selectedTab: Tabs.features })}>
<TabFeatures onConnect={connectTo => this.setState({connectTo})}/>
</TabNavigator.Item>
<TabNavigator.Item
selected={selectedTab === Tabs.setting}
renderIcon={() => <Text style={{color: '#ccc'}}>SETTING</Text>}
renderSelectedIcon={() => <Text style={{fontWeight: 'bold', color: Theme.color}}>SETTING</Text>}
onPress={() => this.setState({ selectedTab: Tabs.setting })}>
<TabSetting />
</TabNavigator.Item>
</TabNavigator>
{
connectTo && (
<ConnectionPanel
peripheral={connectTo}
onClose={() => this.setState({connectTo: null})}
/>
)
}
{
<ErrorMessagePanel />
}
</View>
)
}
}
export default App;