-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathApp.tsx
140 lines (132 loc) · 3.22 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from "react";
import { Platform, StyleSheet, Text, View } from "react-native";
import StyledText from "./lib";
const instructions = Platform.select({
ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
android:
"Double tap R on your keyboard to reload,\n" +
"Shake or press menu button for dev menu",
});
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<StyledText style={styles.welcome} textStyles={textStyles}>
{
"Welcome to <b>React <u>Native</u> <demo><i>Styled</i> Text</demo></b> demo!"
}
</StyledText>
<StyledText style={styles.instruction} textStyles={textStyles}>
{"Run <code>yarn add react-native-styled-text</code> to install"}
</StyledText>
<View style={styles.jsxContainer}>
<StyledText style={styles.jsx} textStyles={jsxStyles}>
{"<ltgt><</ltgt><comp>StyledText</comp>"}
</StyledText>
<StyledText
style={[styles.jsx, styles.jsxProp]}
textStyles={jsxStyles}
>
{"style<eq>=</eq><brace>{</brace>styles.header<brace>}</brace>"}
</StyledText>
<StyledText style={styles.jsx} textStyles={jsxStyles}>
{"<ltgt>></ltgt>"}
</StyledText>
<StyledText
style={[styles.jsx, styles.jsxProp]}
textStyles={jsxStyles}
>
{
'<brace>{</brace><string>"Ha<i>pp</i>y <b>Styling</b>!"<brace>}</brace>'
}
</StyledText>
<StyledText style={styles.jsx} textStyles={jsxStyles}>
{"<ltgt></</ltgt><comp>StyledText</comp><ltgt>></ltgt>"}
</StyledText>
</View>
<StyledText style={styles.header}>
{"Ha<i>pp</i>y <b>Styling</b>!"}
</StyledText>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
backgroundColor: "#F5FCFF",
},
welcome: {
fontSize: 16,
textAlign: "center",
padding: 10,
},
instruction: {
fontSize: 14,
textAlign: "left",
color: "#333333",
padding: 10,
},
header: {
fontSize: 20,
color: "orange",
textAlign: "center",
padding: 10,
},
jsxContainer: {
backgroundColor: "#333",
padding: 10,
},
jsx: {
textAlign: "left",
paddingLeft: 10,
paddingVertical: 0,
fontWeight: "500",
fontSize: 12,
fontFamily: "courier",
},
jsxProp: {
paddingLeft: 25,
color: "#8EDDFF",
},
});
const textStyles = StyleSheet.create({
demo: {
textShadowOffset: { width: 2, height: 2 },
textShadowColor: "#555555",
textShadowRadius: 6,
fontSize: 18,
color: "#22AA44",
},
code: {
fontWeight: "bold",
fontFamily: "courier",
fontSize: 18,
},
});
const jsxStyles = StyleSheet.create({
ltgt: {
color: "#888",
},
comp: {
color: "#00CCB0",
},
eq: {
color: "white",
},
brace: {
color: "#4797D6",
},
string: {
color: "#D68E76",
},
});