forked from revtel/react-native-ble-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
64 lines (58 loc) · 2.15 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
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 TabConnected from './Components/TabConnected'
import ConnectionPanel from './Components/ConnectionPanel'
const Tabs = {
scan: 0,
connected: 1,
}
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.connected}
renderIcon={() => <Text style={{color: '#ccc'}}>Connected</Text>}
renderSelectedIcon={() => <Text style={{fontWeight: 'bold', color: Theme.color}}>Connected</Text>}
onPress={() => this.setState({ selectedTab: Tabs.connected })}>
<TabConnected onConnect={connectTo => this.setState({connectTo})}/>
</TabNavigator.Item>
</TabNavigator>
{
connectTo && (
<ConnectionPanel
peripheral={connectTo}
onClose={() => this.setState({connectTo: null})}
/>
)
}
</View>
)
}
}
export default App;