|
| 1 | +import React from 'react'; |
| 2 | +import { View, Text, StyleSheet, TouchableOpacity, FlatList, Image } from 'react-native'; |
| 3 | +import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; |
| 4 | + |
| 5 | +const notifications = [ |
| 6 | + { id: '1', title: "Hey, it's time for lunch", time: 'About 1 minute ago', icon: require('./assets/lunch.png') }, |
| 7 | + { id: '2', title: "Don't miss your lowerbody workout", time: 'About 3 hours ago', icon: require('./assets/workout.png') }, |
| 8 | + { id: '3', title: "Hey, let's add some meals for your b..", time: 'About 3 hours ago', icon: require('./assets/meals.png') }, |
| 9 | + { id: '4', title: 'Congratulations, You have finished A..', time: '29 May', icon: require('./assets/congrats.png') }, |
| 10 | + { id: '5', title: "Hey, it's time for lunch", time: '8 April', icon: require('./assets/lunch.png') }, |
| 11 | + { id: '6', title: 'Ups, You have missed your Lowerbo..', time: '3 April', icon: require('./assets/workout.png') }, |
| 12 | +]; |
| 13 | + |
| 14 | +export default function NotificationScreen({ navigation }) { |
| 15 | + const renderItem = ({ item }) => ( |
| 16 | + <View style={styles.item}> |
| 17 | + <Image source={item.icon} style={styles.itemIcon} /> |
| 18 | + <View style={styles.itemText}> |
| 19 | + <Text style={styles.title} numberOfLines={1}>{item.title}</Text> |
| 20 | + <Text style={styles.time}>{item.time}</Text> |
| 21 | + </View> |
| 22 | + <TouchableOpacity style={styles.itemMenu}> |
| 23 | + <Icon name="dots-vertical" size={20} /> |
| 24 | + </TouchableOpacity> |
| 25 | + </View> |
| 26 | + ); |
| 27 | + return ( |
| 28 | + <View style={styles.container}> |
| 29 | + <View style={styles.header}> |
| 30 | + <TouchableOpacity onPress={() => navigation.goBack()}> |
| 31 | + <Icon name="arrow-left" size={24} /> |
| 32 | + </TouchableOpacity> |
| 33 | + <Text style={styles.headerTitle}>Notification</Text> |
| 34 | + <TouchableOpacity> |
| 35 | + <Icon name="dots-horizontal" size={24} /> |
| 36 | + </TouchableOpacity> |
| 37 | + </View> |
| 38 | + <FlatList |
| 39 | + data={notifications} |
| 40 | + keyExtractor={item => item.id} |
| 41 | + renderItem={renderItem} |
| 42 | + ItemSeparatorComponent={() => <View style={styles.separator} />} |
| 43 | + /> |
| 44 | + </View> |
| 45 | + ); |
| 46 | +} |
| 47 | + |
| 48 | +const styles = StyleSheet.create({ |
| 49 | + container: { flex: 1, backgroundColor: '#fff' }, |
| 50 | + header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', padding: 16 }, |
| 51 | + headerTitle: { fontSize: 18, fontWeight: 'bold' }, |
| 52 | + item: { flexDirection: 'row', alignItems: 'center', padding: 16 }, |
| 53 | + itemIcon: { width: 40, height: 40, borderRadius: 20 }, |
| 54 | + itemText: { flex: 1, marginLeft: 12 }, |
| 55 | + title: { fontSize: 16 }, |
| 56 | + time: { fontSize: 12, color: '#888' }, |
| 57 | + itemMenu: { padding: 8 }, |
| 58 | + separator: { height: 1, backgroundColor: '#eee', marginLeft: 68 }, |
| 59 | +}); |
0 commit comments