-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
42 lines (34 loc) · 1.14 KB
/
App.tsx
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
import { StatusBar } from "expo-status-bar"
import React, { useEffect, useState } from "react"
import { StyleSheet, Text, View, KeyboardAvoidingView } from "react-native"
import { BleManager, State } from "react-native-ble-plx"
import { Bridge } from "./src/components"
import { ScreenWrapper } from "./src/components/ScreenWrapper"
export const bleManager = new BleManager()
export default function App() {
const [bleState, setBleState] = useState(State.Unknown)
// Subscribe to manager status
useEffect(() => {
const stateListener = bleManager.onStateChange(setBleState, true)
return () => stateListener.remove()
}, [])
return (
<ScreenWrapper>
<View style={styles.container}>
<Text style={{ fontSize: 72 }}>🧐</Text>
<Text style={{ fontSize: 32 }}>SCRYE mono</Text>
<Text>BLE {bleState}</Text>
{bleState === State.PoweredOn && <Bridge bleManager={bleManager} />}
<StatusBar style="auto" />
</View>
</ScreenWrapper>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
})