-
-
Notifications
You must be signed in to change notification settings - Fork 226
/
Copy pathPopulerCourseListView.tsx
121 lines (114 loc) · 3.22 KB
/
PopulerCourseListView.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
import React, { useEffect, useRef } from 'react';
import {
StyleSheet,
View,
Text,
Animated,
ListRenderItemInfo,
Image,
} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons';
import MyPressable from '../components/MyPressable';
import { CategoryType } from './model/category';
interface Props {
data: ListRenderItemInfo<CategoryType>;
onScreenClicked: () => void;
}
const PopulerCourseListView: React.FC<Props> = ({ data, onScreenClicked }) => {
const { index, item } = data;
const translateY = useRef<Animated.Value>(new Animated.Value(50)).current;
const opacity = useRef<Animated.Value>(new Animated.Value(0)).current;
useEffect(() => {
Animated.parallel([
Animated.timing(translateY, {
toValue: 0,
duration: 1000,
delay: index * (1000 / 3),
useNativeDriver: true,
}),
Animated.timing(opacity, {
toValue: 1,
duration: 1000,
delay: index * (1000 / 3),
useNativeDriver: true,
}),
]).start();
});
return (
<Animated.View
style={[styles.container, { opacity, transform: [{ translateY }] }]}
renderToHardwareTextureAndroid // just to avoid UI glitch when animating view with elevation
>
<MyPressable
style={{ flex: 1, aspectRatio: 0.8 }}
touchOpacity={0.6}
onPress={onScreenClicked}
>
<View style={styles.bgColorView} />
<View style={{ ...StyleSheet.absoluteFillObject }}>
<View style={{ padding: 16 }}>
<Text style={styles.title}>{item.title}</Text>
<View style={styles.lessionCountRatingContainer}>
<Text style={[styles.textStyle, { flex: 1, fontSize: 12 }]}>
{item.lessonCount} lesson
</Text>
<Text style={styles.textStyle}>{item.rating}</Text>
<Icon name="star" size={20} color="rgb(0, 182, 240)" />
</View>
</View>
<View style={{ flex: 1, alignItems: 'center' }}>
<Animated.View style={[styles.imageContainer /*, { opacity }, */]}>
<Image
style={{ height: '100%', borderRadius: 16, aspectRatio: 1.28 }}
source={item.imagePath}
/>
</Animated.View>
</View>
</View>
</MyPressable>
</Animated.View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
borderRadius: 16,
overflow: 'hidden',
marginHorizontal: 16,
},
bgColorView: {
flex: 1,
marginBottom: 48,
borderRadius: 16,
backgroundColor: '#F8FAFB',
},
title: {
fontSize: 16,
fontFamily: 'WorkSans-SemiBold',
letterSpacing: 0.27,
color: 'rgb(23, 38, 42)',
},
lessionCountRatingContainer: {
flexDirection: 'row',
alignItems: 'center',
paddingTop: 8,
},
textStyle: {
fontSize: 18,
fontFamily: 'WorkSans-Regular',
letterSpacing: 0.27,
color: 'rgb(58, 81, 96)',
},
imageContainer: {
borderRadius: 16,
marginHorizontal: 16,
marginBottom: 4,
backgroundColor: 'white',
elevation: 2,
shadowColor: 'grey',
shadowOffset: { width: 0, height: 0 },
shadowOpacity: 0.22,
shadowRadius: 6.0,
},
});
export default PopulerCourseListView;