-
Notifications
You must be signed in to change notification settings - Fork 14
/
App.tsx
157 lines (146 loc) · 3.85 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import * as React from 'react';
import { View, Text, AnimatedValue, timing, AnimatedTiming, Touchable, withContext } from '../revas';
import Intro from './Intro';
import Timeline from './Timeline';
import MusicApp from './Music';
import SimpleRouter from './common/simple-router';
@withContext
export default class App extends React.Component {
router = React.createRef<SimpleRouter>();
push = (Comp: any) => () => {
this.router.current?.push(Comp);
};
open = () => {
window.open('https://pinqy520.github.io/demo/revas-three/');
};
render() {
const cardHeight = this.context.clientHeight / 7;
return (
<SimpleRouter ref={this.router} width={this.context.clientWidth}>
<View style={styles.container}>
<Text style={styles.title}>Revas Examples</Text>
<View style={styles.cards}>
<Card
color="#9254DE"
shadowColor="rgba(146, 84, 222, 0.5)"
height={cardHeight}
text="Overview"
tap={this.push(Intro)}
/>
<Card
color="#F759AB"
shadowColor="rgba(247, 89, 171, 0.5)"
height={cardHeight}
text="Timeline App"
tap={this.push(Timeline)}
/>
<Card
color="#597EF7"
shadowColor="rgba(89, 126, 247, 0.5)"
height={cardHeight}
text="Music App"
tap={this.push(MusicApp)}
/>
<Touchable style={styles.extra} onPress={this.open}>
<Text style={styles.extraText}>Revas + THREE.js</Text>
</Touchable>
</View>
</View>
</SimpleRouter>
);
}
}
interface CardProps {
color: string;
shadowColor: string;
text: string;
tap: Function;
height: number;
}
class Card extends React.Component<CardProps> {
animated = new AnimatedValue(30);
animating?: AnimatedTiming;
style = [
// eslint-disable-next-line
styles.card,
{
height: this.props.height,
backgroundColor: this.props.color,
shadowColor: this.props.shadowColor,
shadowBlur: this.animated,
shadowOffsetY: this.animated.interpolate([4, 30], [1, 5]),
animated: true,
},
];
onPress = () => {
this.animating?.stop();
this.animating = timing(this.animated, {
to: 4,
duration: (this.animated.getValue() - 4) * 10,
}).start();
};
onPressOut = () => {
this.animating?.stop();
this.animating = timing(this.animated, {
to: 30,
duration: (30 - this.animated.getValue()) * 10,
}).start();
};
render() {
return (
<Touchable
activeOpacity={1}
style={this.style}
onPress={this.props.tap}
onPressIn={this.onPress}
onPressOut={this.onPressOut}
cache
>
<Text style={styles.text}>{this.props.text}</Text>
</Touchable>
);
}
}
const styles = {
container: {
justifyContent: 'center',
flex: 1,
},
title: {
textAlign: 'center',
fontSize: 24,
fontWeight: '500',
color: '#000',
opacity: 0.56,
marginBottom: 20,
fontFamily:
"'Avenir Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue'",
},
cards: {
alignItems: 'center',
},
card: {
width: 280,
shadowOffsetX: 0,
borderRadius: 15,
justifyContent: 'center',
marginTop: 20,
},
text: {
textAlign: 'center',
fontSize: 24,
fontWeight: '500',
color: '#fff',
fontFamily:
"'Avenir Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue'",
},
extra: {
width: 280,
height: 50,
justifyContent: 'center',
marginTop: 10,
},
extraText: {
textAlign: 'center',
},
};