import React from 'react' import { View, Pressable, ViewProps, StyleSheet } from 'react-native' import { LinearGradient } from 'expo-linear-gradient' import Svg, { Path, Circle, Defs, Rect, LinearGradient as SvgLinearGradient, Stop } from 'react-native-svg' import Text from './ui/Text' interface ErrorStateProps extends ViewProps { message?: string onRetry?: () => void /** 是否显示为空状态图标(默认)或错误图标 */ variant?: 'empty' | 'error' } /** 空状态图标 - 文件夹 */ function EmptyIcon() { return ( ) } /** 错误状态图标 */ function ErrorIcon() { return ( ) } export default function ErrorState({ message = 'An error occurred', onRetry, testID, variant = 'empty', ...props }: ErrorStateProps) { return ( {/* 图标 */} {variant === 'error' ? : } {/* 消息文本 */} {message} {/* 重试按钮 - 使用渐变边框风格 */} {onRetry && ( 重新加载 )} ) } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 24, paddingVertical: 48, minHeight: 280, }, iconContainer: { marginBottom: 20, }, message: { fontSize: 15, color: '#8E8E93', textAlign: 'center', lineHeight: 22, }, retryButton: { marginTop: 24, borderRadius: 22, overflow: 'hidden', }, gradientBorder: { padding: 1.5, borderRadius: 22, }, buttonInner: { backgroundColor: '#1C1E22', paddingHorizontal: 28, paddingVertical: 12, borderRadius: 20, }, buttonText: { color: '#F5F5F5', fontSize: 14, fontWeight: '500', }, })