-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
72 lines (67 loc) 路 1.63 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
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
import React from "react";
import {
FlatList,
SafeAreaView,
Text,
TouchableOpacity,
View,
} from "react-native";
import HomeKitModule, { Home } from "./src/HomeKitModule/HomeKitModule";
const App = () => {
const [home, setHome] = React.useState<Home>();
const addAndSetupAccessories = async () => {
const homeData = await HomeKitModule.addAndSetupAccessories("");
setHome(homeData);
};
React.useEffect(() => {
console.log("home data", home);
}, [home]);
return (
<SafeAreaView>
<TouchableOpacity
onPress={addAndSetupAccessories}
style={{
backgroundColor: "#007AFF",
padding: 10,
margin: 10,
borderRadius: 10,
height: 200,
justifyContent: "center",
alignItems: "center",
}}>
<Text
style={{
color: "white",
fontSize: 34,
}}>
+ Add HomeKit Device
</Text>
</TouchableOpacity>
<FlatList
contentContainerStyle={{ paddingBottom: 300 }}
data={home?.accessories}
renderItem={({ item }) => (
<View
style={{
backgroundColor: "#adbffa",
padding: 10,
margin: 10,
borderRadius: 10,
justifyContent: "center",
alignItems: "center",
}}>
<Text
style={{
color: "black",
fontSize: 34,
fontWeight: "200",
}}>
{item}
</Text>
</View>
)}
/>
</SafeAreaView>
);
};
export default App;