-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
71 lines (67 loc) · 2.28 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
import { StatusBar } from "expo-status-bar";
import React, { useState } from "react";
import { Button, SafeAreaView, StyleSheet, Text, View } from "react-native";
import ChildrenAsObjectExample from "./src/ChildrenAsObjectExample";
import CustomNodeExample from "./src/CustomNodeExample";
import DynamicContentExample from "./src/DynamicContentExample";
import ErrorMessageExample from "./src/ErrorMessageExample";
import ExtraDataExample from "./src/ExtraDataExample";
import NestedRowExample from "./src/NestedRowExample";
import PerformanceExample from "./src/PerformanceExample";
import ReduxExample from "./src/ReduxExample";
import StateChangeNodeExample from "./src/StateChangeNodeExample";
import store from "./src/store";
import { Provider } from "react-redux";
const mapScreenComp: any = {
CustomNodeExample: () => <CustomNodeExample />,
StateChangeNodeExample: () => <StateChangeNodeExample />,
ErrorMessageExample: () => <ErrorMessageExample />,
NestedRowExample: () => <NestedRowExample />,
ExtraDataExample: () => <ExtraDataExample />,
DynamicContentExample: () => <DynamicContentExample />,
ChildrenAsObjectExample: () => <ChildrenAsObjectExample />,
PerformanceExample: () => <PerformanceExample />,
ReduxExample: () => <ReduxExample />,
};
export default function App() {
const [selectedScreen, setSelectedScreen] = useState<string>("");
return (
<Provider store={store}>
<SafeAreaView style={{ flex: 1 }}>
{selectedScreen ? (
<Button
onPress={() => {
setSelectedScreen("");
}}
title={"Back to Home"}
/>
) : null}
{selectedScreen ? (
<View style={{ flex: 1 }}>{mapScreenComp[selectedScreen]()}</View>
) : (
<>
{Object.keys(mapScreenComp).map((key, index) => {
return (
<Button
key={index}
onPress={() => {
setSelectedScreen(key);
}}
title={key}
/>
);
})}
</>
)}
</SafeAreaView>
</Provider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});