주요 구현 완료 기능: - 구독 관리 (추가/편집/삭제/카테고리 분류) - 이벤트 할인 시스템 (기본값 자동 설정) - SMS 자동 스캔 및 구독 정보 추출 - 알림 시스템 (타임존 처리 안정화) - 환율 변환 지원 (KRW/USD) - 반응형 UI 및 애니메이션 - 다국어 지원 (한국어/영어) 버그 수정: - NotificationService tz.local 초기화 오류 해결 - MainScreenSummaryCard 레이아웃 오버플로우 수정 - 구독 추가 시 LateInitializationError 완전 해결 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
281 lines
12 KiB
Dart
281 lines
12 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:intl/intl.dart';
|
|
import '../providers/subscription_provider.dart';
|
|
import '../theme/app_colors.dart';
|
|
import '../utils/format_helper.dart';
|
|
import 'animated_wave_background.dart';
|
|
|
|
/// 메인 화면 상단에 표시되는 요약 카드 위젯
|
|
///
|
|
/// 총 구독 수와 월별 총 지출을 표시하며, 분석 화면으로 이동하는 기능을 제공합니다.
|
|
class MainScreenSummaryCard extends StatelessWidget {
|
|
final SubscriptionProvider provider;
|
|
final AnimationController fadeController;
|
|
final AnimationController pulseController;
|
|
final AnimationController waveController;
|
|
final AnimationController slideController;
|
|
final VoidCallback onTap;
|
|
|
|
const MainScreenSummaryCard({
|
|
Key? key,
|
|
required this.provider,
|
|
required this.fadeController,
|
|
required this.pulseController,
|
|
required this.waveController,
|
|
required this.slideController,
|
|
required this.onTap,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final double monthlyCost = provider.totalMonthlyExpense;
|
|
final double yearlyCost = monthlyCost * 12;
|
|
final int totalSubscriptions = provider.subscriptions.length;
|
|
final double eventSavings = provider.totalEventSavings;
|
|
final int activeEvents = provider.activeEventSubscriptions.length;
|
|
|
|
return FadeTransition(
|
|
opacity: Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
CurvedAnimation(parent: fadeController, curve: Curves.easeIn)),
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(20, 16, 20, 4),
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
HapticFeedback.mediumImpact();
|
|
onTap();
|
|
},
|
|
child: Card(
|
|
elevation: 4,
|
|
shadowColor: Colors.black12,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(24),
|
|
),
|
|
child: Container(
|
|
width: double.infinity,
|
|
constraints: BoxConstraints(
|
|
minHeight: 180,
|
|
maxHeight: activeEvents > 0 ? 300 : 240,
|
|
),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(24),
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
colors: [
|
|
AppColors.primaryColor,
|
|
AppColors.primaryColor.withBlue(
|
|
(AppColors.primaryColor.blue * 1.3)
|
|
.clamp(0, 255)
|
|
.toInt()),
|
|
],
|
|
),
|
|
),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(24),
|
|
child: Stack(
|
|
children: [
|
|
// 애니메이션 웨이브 배경
|
|
Positioned.fill(
|
|
child: AnimatedWaveBackground(
|
|
controller: waveController,
|
|
pulseController: pulseController,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'이번 달 총 구독 비용',
|
|
style: TextStyle(
|
|
color: Colors.white.withOpacity(0.9),
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
|
textBaseline: TextBaseline.alphabetic,
|
|
children: [
|
|
Text(
|
|
NumberFormat.currency(
|
|
locale: 'ko_KR',
|
|
symbol: '',
|
|
decimalDigits: 0,
|
|
).format(monthlyCost),
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 32,
|
|
fontWeight: FontWeight.bold,
|
|
letterSpacing: -1,
|
|
),
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
'원',
|
|
style: TextStyle(
|
|
color: Colors.white.withOpacity(0.9),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
Row(
|
|
children: [
|
|
_buildInfoBox(
|
|
context,
|
|
title: '연간 구독 비용',
|
|
value: '${NumberFormat.currency(
|
|
locale: 'ko_KR',
|
|
symbol: '',
|
|
decimalDigits: 0,
|
|
).format(yearlyCost)}원',
|
|
),
|
|
const SizedBox(width: 16),
|
|
_buildInfoBox(
|
|
context,
|
|
title: '총 구독 서비스',
|
|
value: '$totalSubscriptions개',
|
|
),
|
|
],
|
|
),
|
|
// 이벤트 절약액 표시
|
|
if (activeEvents > 0) ...[
|
|
const SizedBox(height: 12),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14),
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Colors.white.withOpacity(0.2),
|
|
Colors.white.withOpacity(0.15),
|
|
],
|
|
),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(
|
|
color: Colors.white.withOpacity(0.3),
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(6),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.25),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.local_offer_rounded,
|
|
size: 14,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(width: 10),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'이벤트 할인 중',
|
|
style: TextStyle(
|
|
color: Colors.white.withOpacity(0.9),
|
|
fontSize: 11,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
NumberFormat.currency(
|
|
locale: 'ko_KR',
|
|
symbol: '₩',
|
|
decimalDigits: 0,
|
|
).format(eventSavings),
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text(
|
|
' 절약 ($activeEvents개)',
|
|
style: TextStyle(
|
|
color: Colors.white.withOpacity(0.85),
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
Positioned(
|
|
right: 16,
|
|
top: 16,
|
|
child: Icon(
|
|
Icons.arrow_forward_ios,
|
|
color: Colors.white.withOpacity(0.7),
|
|
size: 16,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildInfoBox(BuildContext context,
|
|
{required String title, required String value}) {
|
|
return Expanded(
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.15),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
color: Colors.white.withOpacity(0.85),
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
value,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|