-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
118 lines (103 loc) · 2.83 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
import React from 'react';
import {StatusBar} from 'react-native';
import Header from './src/components/Header';
import Tabs from './src/components/Tabs';
import Menu from './src/components/Menu';
import {Animated} from 'react-native';
import {PanGestureHandler, State} from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/MaterialIcons';
import {
Container,
Title,
Content,
Card,
CardHeader,
CardContent,
CardFooter,
Description,
Annotation,
} from './styles';
const date = Date();
const App = () => {
let offset = 0;
const translateY = new Animated.Value(0);
const animatedEvent = new Animated.event(
[
{
nativeEvent: {
translationY: translateY,
},
},
],
{
useNativeDriver: true,
},
);
function onHandlerStateChanged(event) {
if (event.nativeEvent.oldState === State.ACTIVE) {
let opened = false;
const {translationY} = event.nativeEvent;
offset += translationY;
if (translationY >= 100) {
opened = true;
} else {
translateY.setValue(offset);
translateY.setOffset(0);
offset = 0;
}
Animated.timing(translateY, {
toValue: opened ? 380 : 0,
duration: 200,
useNativeDriver: true,
}).start(() => {
offset = opened ? 380 : 0;
translateY.setOffset(offset);
translateY.setValue(0);
});
}
}
return (
<>
<StatusBar barStyle="light-content" backgroundColor="#8b10ae" />
<Container>
<Header />
<Content>
<Menu translateY={translateY} />
<PanGestureHandler
onGestureEvent={animatedEvent}
onHandlerStateChange={onHandlerStateChanged}>
<Card
style={{
transform: [
{
translateY: translateY.interpolate({
inputRange: [-350, 0, 380],
outputRange: [-50, 0, 380],
extrapolate: 'clamp',
}),
},
],
}}>
<CardHeader>
<Icon name="attach-money" size={20} color="#333" />
<Icon name="visibility" size={20} color="#333" />
</CardHeader>
<CardContent>
<Title>Saldo Disponível</Title>
<Description>R$ 200.000,00</Description>
</CardContent>
<CardFooter>
<Annotation>
Transferência recebida {date} de João Guilherme no valor de R$
20,00 às 15:00hs
</Annotation>
</CardFooter>
</Card>
</PanGestureHandler>
</Content>
<Tabs translateY={translateY} />
</Container>
</>
);
};
export default App;