|
| 1 | +import React from 'react'; |
| 2 | +import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'; |
| 3 | +import { colors, spacing, typography, borderRadius } from '../utils/constants'; |
| 4 | + |
| 5 | +interface EmptyStateProps { |
| 6 | + icon: string; |
| 7 | + title: string; |
| 8 | + message: string; |
| 9 | + actionText?: string; |
| 10 | + onAction?: () => void; |
| 11 | +} |
| 12 | + |
| 13 | +export const EmptyState: React.FC<EmptyStateProps> = ({ |
| 14 | + icon, |
| 15 | + title, |
| 16 | + message, |
| 17 | + actionText, |
| 18 | + onAction, |
| 19 | +}) => { |
| 20 | + return ( |
| 21 | + <View style={styles.container}> |
| 22 | + <Text style={styles.icon}>{icon}</Text> |
| 23 | + <Text style={styles.title}>{title}</Text> |
| 24 | + <Text style={styles.message}>{message}</Text> |
| 25 | + {actionText && onAction && ( |
| 26 | + <TouchableOpacity style={styles.button} onPress={onAction}> |
| 27 | + <Text style={styles.buttonText}>{actionText}</Text> |
| 28 | + </TouchableOpacity> |
| 29 | + )} |
| 30 | + </View> |
| 31 | + ); |
| 32 | +}; |
| 33 | + |
| 34 | +const styles = StyleSheet.create({ |
| 35 | + container: { |
| 36 | + alignItems: 'center', |
| 37 | + justifyContent: 'center', |
| 38 | + paddingVertical: spacing.xl * 2, |
| 39 | + paddingHorizontal: spacing.lg, |
| 40 | + }, |
| 41 | + icon: { |
| 42 | + fontSize: 56, |
| 43 | + marginBottom: spacing.md, |
| 44 | + }, |
| 45 | + title: { |
| 46 | + ...typography.h3, |
| 47 | + color: colors.text, |
| 48 | + marginBottom: spacing.sm, |
| 49 | + textAlign: 'center', |
| 50 | + fontWeight: '600', |
| 51 | + }, |
| 52 | + message: { |
| 53 | + ...typography.body, |
| 54 | + color: colors.textSecondary, |
| 55 | + textAlign: 'center', |
| 56 | + lineHeight: 24, |
| 57 | + marginBottom: spacing.lg, |
| 58 | + }, |
| 59 | + button: { |
| 60 | + backgroundColor: colors.primary, |
| 61 | + paddingVertical: spacing.md, |
| 62 | + paddingHorizontal: spacing.lg, |
| 63 | + borderRadius: borderRadius.md, |
| 64 | + marginTop: spacing.md, |
| 65 | + }, |
| 66 | + buttonText: { |
| 67 | + ...typography.body, |
| 68 | + color: colors.text, |
| 69 | + fontWeight: '600', |
| 70 | + fontSize: 16, |
| 71 | + }, |
| 72 | +}); |
0 commit comments