-
Notifications
You must be signed in to change notification settings - Fork 26
/
App.js
119 lines (111 loc) · 3.5 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { useFonts } from "expo-font";
import { useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
import Dripsy from "./components/Dripsy";
import EmotionNative from "./components/EmotionNative";
import Gluestack from "./components/Gluestack";
import NativeWind from "./components/NativeWind";
import Native from "./components/ReactNative";
import Restyle from "./components/Restyle";
import StyledComponents from "./components/StyledComponents";
import Tamagui from "./components/Tamagui";
import TimedRender from "./components/TimedRender";
import Twrnc from "./components/Twrnc";
import { Zephyr } from "./components/Zephyr";
import FastStyles from "./components/FastStyles";
import Unistyles from "./components/Unistyles";
export default function App() {
const [styleType, setStyleType] = useState(undefined);
const onStyleTypePress = (curry) => () => {
setStyleType(curry);
};
const renderStyleLibrary = () => {
switch (styleType) {
case "React Native":
return <Native />;
case "Styled Components":
return <StyledComponents />;
case "Tamagui":
return <Tamagui />;
case "Restyle":
return <Restyle />;
case "NativeWind":
return <NativeWind />;
case "Emotion Native":
return <EmotionNative />;
case "Dripsy":
return <Dripsy />;
case "Zephyr":
return <Zephyr />;
case "Gluestack":
return <Gluestack />;
case "Twrnc":
return <Twrnc />;
case "FastStyles":
return <FastStyles />;
case "Unistyles":
return <Unistyles />;
default:
return null;
}
};
const [loaded] = useFonts({
Inter: require("@tamagui/font-inter/otf/Inter-Medium.otf"),
InterBold: require("@tamagui/font-inter/otf/Inter-Bold.otf"),
});
if (!loaded) {
return null;
}
return (
<View style={styles.container}>
<Text style={styles.text}>Tap a style library to start rendering</Text>
<Button title="React Native" onPress={onStyleTypePress("React Native")} />
<Button
title="react-native-unistyles"
onPress={onStyleTypePress("Unistyles")}
/>
<Button title="fast-styles" onPress={onStyleTypePress("FastStyles")} />
<Button
title="twrnc (tailwind rn class names)"
onPress={onStyleTypePress("Twrnc")}
/>
<Button title="Zephyr" onPress={onStyleTypePress("Zephyr")} />
<Button title="Restyle" onPress={onStyleTypePress("Restyle")} />
<Button
title="Styled Components"
onPress={onStyleTypePress("Styled Components")}
/>
<Button
title="Emotion Native"
onPress={onStyleTypePress("Emotion Native")}
/>
<Button title="NativeWind" onPress={onStyleTypePress("NativeWind")} />
<Button title="Tamagui" onPress={onStyleTypePress("Tamagui")} />
<Button title="Gluestack" onPress={onStyleTypePress("Gluestack")} />
<Button title="Dripsy" onPress={onStyleTypePress("Dripsy")} />
{styleType ? (
<TimedRender key={styleType}>
<Text style={styles.text}>
Rendering with <Text style={styles.bold}>{styleType}</Text>
</Text>
</TimedRender>
) : null}
{renderStyleLibrary()}
</View>
);
}
const styles = StyleSheet.create({
container: {
alignItems: "center",
backgroundColor: "#fff",
flex: 1,
justifyContent: "center",
},
text: {
marginVertical: 12,
},
bold: {
fontWeight: "bold",
fontSize: 16,
},
});