LunchPick(오늘 뭐 먹Z?) Flutter 앱의 초기 구현입니다. 주요 기능: - 네이버 지도 연동 맛집 추가 - 랜덤 메뉴 추천 시스템 - 날씨 기반 거리 조정 - 방문 기록 관리 - Bluetooth 맛집 공유 - 다크모드 지원 기술 스택: - Flutter 3.8.1+ - Riverpod 상태 관리 - Hive 로컬 DB - Clean Architecture 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
116 lines
3.3 KiB
Dart
116 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../constants/app_colors.dart';
|
|
import '../constants/app_typography.dart';
|
|
|
|
/// 커스텀 에러 위젯
|
|
///
|
|
/// Flutter의 기본 ErrorWidget과 이름 충돌을 피하기 위해 CustomErrorWidget으로 명명
|
|
class CustomErrorWidget extends StatelessWidget {
|
|
/// 에러 메시지
|
|
final String message;
|
|
|
|
/// 에러 아이콘 (선택사항)
|
|
final IconData? icon;
|
|
|
|
/// 재시도 버튼 콜백 (선택사항)
|
|
final VoidCallback? onRetry;
|
|
|
|
/// 상세 에러 메시지 (선택사항)
|
|
final String? details;
|
|
|
|
const CustomErrorWidget({
|
|
super.key,
|
|
required this.message,
|
|
this.icon,
|
|
this.onRetry,
|
|
this.details,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
return Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
// 에러 아이콘
|
|
Icon(
|
|
icon ?? Icons.error_outline,
|
|
size: 64,
|
|
color: isDark ? AppColors.darkError : AppColors.lightError,
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
// 에러 메시지
|
|
Text(
|
|
message,
|
|
style: AppTypography.heading2(isDark),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
|
|
// 상세 메시지 (있을 경우)
|
|
if (details != null) ...[
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
details!,
|
|
style: AppTypography.body2(isDark),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
|
|
// 재시도 버튼 (있을 경우)
|
|
if (onRetry != null) ...[
|
|
const SizedBox(height: 24),
|
|
ElevatedButton.icon(
|
|
onPressed: onRetry,
|
|
icon: const Icon(Icons.refresh),
|
|
label: const Text('다시 시도'),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: isDark
|
|
? AppColors.darkPrimary
|
|
: AppColors.lightPrimary,
|
|
foregroundColor: Colors.white,
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 24,
|
|
vertical: 12,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 간단한 에러 스낵바를 표시하는 유틸리티 함수
|
|
void showErrorSnackBar({
|
|
required BuildContext context,
|
|
required String message,
|
|
Duration duration = const Duration(seconds: 3),
|
|
SnackBarAction? action,
|
|
}) {
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
message,
|
|
style: const TextStyle(color: Colors.white),
|
|
),
|
|
backgroundColor: isDark ? AppColors.darkError : AppColors.lightError,
|
|
duration: duration,
|
|
action: action,
|
|
behavior: SnackBarBehavior.floating,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
margin: const EdgeInsets.all(8),
|
|
),
|
|
);
|
|
} |