-
Notifications
You must be signed in to change notification settings - Fork 0
/
AttachmentCard.js
105 lines (102 loc) · 2.92 KB
/
AttachmentCard.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
import React from 'react';
import {
Animated,
Dimensions,
StyleSheet,
View,
Image,
Text,
} from 'react-native';
import FontAwesome from 'react-native-vector-icons/FontAwesome5';
import styles from './styles';
const {height: wHeight, width: wWidth} = Dimensions.get('window');
const MARGIN = 16;
const internalStyles = StyleSheet.create({
card: {
marginVertical: MARGIN,
alignSelf: 'center',
},
});
const AttachmentCard = ({type, y, index, buttonContainerHeight}) => {
const offSet = index ? 60 - MARGIN : 0;
const CARD_HEIGHT = (wWidth * 0.8 * 228) / 362 + MARGIN * 2;
const height = wHeight - buttonContainerHeight;
const position = Animated.subtract(index * CARD_HEIGHT, y);
const isDisappearing = -CARD_HEIGHT;
const isTop = 0;
const isBottom = height - CARD_HEIGHT;
const isAppearing = height;
const translateY = Animated.add(
Animated.add(
y,
y.interpolate({
inputRange: [0, 0.00001 + index * CARD_HEIGHT],
outputRange: [0, -index * CARD_HEIGHT - offSet],
extrapolateRight: 'clamp',
}),
),
position.interpolate({
inputRange: [isBottom, isAppearing],
outputRange: [0, -CARD_HEIGHT / 2],
extrapolate: 'clamp',
}),
);
const scale = position.interpolate({
inputRange: [isDisappearing, isTop, isBottom, isAppearing],
outputRange: [0.5, 1, 1, 0.2],
extrapolate: 'clamp',
});
const opacity = position.interpolate({
inputRange: [isDisappearing, isTop, isBottom, isAppearing],
outputRange: [0.2, 1, 1, 0.2],
});
return (
<Animated.View
style={[
internalStyles.card,
{opacity, transform: [{translateY}, {scale}]},
]}
key={index}>
{index ? (
<Image
source={require('./card1.png')}
style={{
width: wWidth * 0.8,
height: (wWidth * 0.8 * 228) / 362,
alignSelf: 'center',
resizeMode: 'contain',
}}
/>
) : (
<View
style={[internalStyles.card, styles.CardContainer, {height: 200}]}>
<View style={{alignItems: 'center'}}>
<Image
style={styles.ProfileImage}
source={require('./avatar.jpeg')}
/>
</View>
<View style={styles.info}>
<Text style={styles.iconProfile} />
<Text style={styles.FF_Regular}>Name </Text>
<Text style={[styles.FF_Bold, styles.FS_18]}>
{''}
Jhone Doe
</Text>
</View>
<View style={styles.info}>
<Text style={styles.iconProfile}>
<FontAwesome name="birthday-cake" size={25} />
</Text>
<Text style={styles.FF_Regular}>Age </Text>
<Text style={[styles.FF_Bold, styles.FS_18]}>
{''}
24
</Text>
</View>
</View>
)}
</Animated.View>
);
};
export default AttachmentCard;