import 'package:flutter/material.dart'; /// 加载态 class LoadingView extends StatelessWidget { const LoadingView({super.key, this.tip = '加载中...', this.padding = const EdgeInsets.all(40)}); final String tip; final EdgeInsetsGeometry padding; @override Widget build(BuildContext context) { return Padding( padding: padding, child: Column( children: [ const SizedBox( width: 26, height: 26, child: CircularProgressIndicator(strokeWidth: 2.5, color: Color(0xFFC8956E)), ), const SizedBox(height: 12), Text(tip, style: const TextStyle(fontSize: 13, color: Color(0xFF8D6E63))), ], ), ); } } /// 错误态(可带重试) class ErrorView extends StatelessWidget { const ErrorView({super.key, required this.message, this.onRetry}); final String message; final VoidCallback? onRetry; @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white.withValues(alpha: 0.85), borderRadius: BorderRadius.circular(14), ), child: Column( children: [ const Text('😵', style: TextStyle(fontSize: 30)), const SizedBox(height: 8), Text( message, textAlign: TextAlign.center, style: const TextStyle(fontSize: 13, color: Color(0xFF8D6E63)), ), if (onRetry != null) ...[ const SizedBox(height: 12), OutlinedButton( onPressed: onRetry, style: OutlinedButton.styleFrom( foregroundColor: const Color(0xFFC8956E), side: const BorderSide(color: Color(0xFFC8956E)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18)), ), child: const Text('重试'), ), ], ], ), ); } } /// 空状态 class EmptyView extends StatelessWidget { const EmptyView({ super.key, this.icon = '📭', required this.title, this.tip, this.padding = const EdgeInsets.symmetric(vertical: 40), }); final String icon; final String title; final String? tip; final EdgeInsetsGeometry padding; @override Widget build(BuildContext context) { return Padding( padding: padding, child: Column( children: [ Text(icon, style: const TextStyle(fontSize: 44)), const SizedBox(height: 10), Text(title, style: const TextStyle(fontSize: 15, color: Color(0xFF5D4037))), if (tip != null) ...[ const SizedBox(height: 6), Text( tip!, textAlign: TextAlign.center, style: const TextStyle(fontSize: 12.5, color: Color(0xFFBCAAA4)), ), ], ], ), ); } }