feat: 다국어 지원 및 다중 통화 환율 변환 기능 확대
- ExchangeRateService에 JPY, CNY 환율 지원 추가 - 구독 서비스별 다국어 표시 이름 지원 - 분석 화면 차트 및 UI/UX 개선 - 설정 화면 전면 리팩토링 - SMS 스캔 기능 사용성 개선 - 전체 앱 다국어 번역 확대 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../models/subscription_model.dart';
|
||||
import '../../services/currency_util.dart';
|
||||
import '../../providers/locale_provider.dart';
|
||||
import '../../theme/app_colors.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
|
||||
/// 파이 차트에서 선택된 섹션에 표시되는 배지 위젯
|
||||
class AnalysisBadge extends StatelessWidget {
|
||||
@@ -54,17 +57,26 @@ class AnalysisBadge extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 0),
|
||||
FutureBuilder<String>(
|
||||
future: CurrencyUtil.formatAmount(
|
||||
future: CurrencyUtil.formatAmountWithLocale(
|
||||
subscription.monthlyCost,
|
||||
subscription.currency,
|
||||
context.read<LocaleProvider>().locale.languageCode,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final amountText = snapshot.data!;
|
||||
// 금액이 너무 길면 축약
|
||||
final displayText = amountText.length > 8
|
||||
? amountText.replaceAll('원', '').trim()
|
||||
: amountText;
|
||||
// 금액이 너무 길면 축약 (괄호 제거)
|
||||
String displayText = amountText;
|
||||
if (amountText.length > 12) {
|
||||
// 괄호 안의 내용 제거
|
||||
displayText = amountText.replaceAll(RegExp(r'\([^)]*\)'), '').trim();
|
||||
}
|
||||
if (displayText.length > 10) {
|
||||
// 통화 기호만 남기고 숫자만 표시
|
||||
final currencySymbol = CurrencyUtil.getCurrencySymbol(subscription.currency);
|
||||
displayText = displayText.replaceAll(currencySymbol, '').trim();
|
||||
displayText = '$currencySymbol${displayText.substring(0, 6)}...';
|
||||
}
|
||||
return Text(
|
||||
displayText,
|
||||
style: const TextStyle(
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../services/currency_util.dart';
|
||||
import '../../theme/app_colors.dart';
|
||||
import '../glassmorphism_card.dart';
|
||||
import '../themed_text.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
|
||||
/// 이벤트 할인 현황을 보여주는 카드 위젯
|
||||
class EventAnalysisCard extends StatelessWidget {
|
||||
@@ -50,7 +51,7 @@ class EventAnalysisCard extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ThemedText.headline(
|
||||
text: '이벤트 할인 현황',
|
||||
text: AppLocalizations.of(context).eventDiscountStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
@@ -78,7 +79,7 @@ class EventAnalysisCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'${provider.activeEventSubscriptions.length}개 진행중',
|
||||
AppLocalizations.of(context).servicesInProgress(provider.activeEventSubscriptions.length),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -119,9 +120,9 @@ class EventAnalysisCard extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const ThemedText(
|
||||
'월간 절약 금액',
|
||||
style: TextStyle(
|
||||
ThemedText(
|
||||
AppLocalizations.of(context).monthlySavingAmount,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
@@ -144,9 +145,9 @@ class EventAnalysisCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const ThemedText(
|
||||
'진행중인 이벤트',
|
||||
style: TextStyle(
|
||||
ThemedText(
|
||||
AppLocalizations.of(context).eventsInProgress,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -246,7 +247,7 @@ class EventAnalysisCard extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'$discountRate% 할인',
|
||||
'$discountRate${AppLocalizations.of(context).discountPercent}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'dart:math' as math;
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../services/currency_util.dart';
|
||||
import '../../providers/locale_provider.dart';
|
||||
import '../../theme/app_colors.dart';
|
||||
import '../glassmorphism_card.dart';
|
||||
import '../themed_text.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
|
||||
/// 월별 지출 현황을 차트로 보여주는 카드 위젯
|
||||
class MonthlyExpenseChartCard extends StatelessWidget {
|
||||
@@ -17,12 +20,64 @@ class MonthlyExpenseChartCard extends StatelessWidget {
|
||||
required this.animationController,
|
||||
});
|
||||
|
||||
/// Y축 최대값을 계산합니다 (언어별 통화 단위에 맞춰)
|
||||
double _calculateChartMaxY(double maxValue, String locale) {
|
||||
final currency = CurrencyUtil.getDefaultCurrency(locale);
|
||||
|
||||
if (currency == 'KRW' || currency == 'JPY') {
|
||||
// 소수점이 없는 통화 (원화, 엔화)
|
||||
if (maxValue <= 0) return 100000;
|
||||
if (maxValue <= 10000) return 10000;
|
||||
if (maxValue <= 50000) return 50000;
|
||||
if (maxValue <= 100000) return 100000;
|
||||
if (maxValue <= 200000) return 200000;
|
||||
if (maxValue <= 500000) return 500000;
|
||||
if (maxValue <= 1000000) return 1000000;
|
||||
|
||||
// 큰 금액은 자릿수에 맞춰 반올림
|
||||
final magnitude = math.pow(10, maxValue.toString().split('.')[0].length - 1).toDouble();
|
||||
return ((maxValue / magnitude).ceil() * magnitude).toDouble();
|
||||
} else {
|
||||
// 소수점이 있는 통화 (달러, 위안)
|
||||
if (maxValue <= 0) return 100.0;
|
||||
if (maxValue <= 10) return 10.0;
|
||||
if (maxValue <= 25) return 25.0;
|
||||
if (maxValue <= 50) return 50.0;
|
||||
if (maxValue <= 100) return 100.0;
|
||||
if (maxValue <= 250) return 250.0;
|
||||
if (maxValue <= 500) return 500.0;
|
||||
if (maxValue <= 1000) return 1000.0;
|
||||
|
||||
// 큰 금액은 100 단위로 반올림
|
||||
return ((maxValue / 100).ceil() * 100).toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
/// 그리드 라인 간격을 계산합니다
|
||||
double _calculateGridInterval(double maxY, String currency) {
|
||||
if (currency == 'KRW' || currency == 'JPY') {
|
||||
// 4등분하되 깔끔한 숫자로
|
||||
if (maxY <= 40000) return 10000;
|
||||
if (maxY <= 100000) return 25000;
|
||||
if (maxY <= 200000) return 50000;
|
||||
if (maxY <= 400000) return 100000;
|
||||
return maxY / 4;
|
||||
} else {
|
||||
// 달러 등은 4등분
|
||||
if (maxY <= 40) return 10;
|
||||
if (maxY <= 100) return 25;
|
||||
if (maxY <= 200) return 50;
|
||||
if (maxY <= 400) return 100;
|
||||
return maxY / 4;
|
||||
}
|
||||
}
|
||||
|
||||
// 월간 지출 차트 데이터
|
||||
List<BarChartGroupData> _getMonthlyBarGroups() {
|
||||
List<BarChartGroupData> _getMonthlyBarGroups(String locale) {
|
||||
final List<BarChartGroupData> barGroups = [];
|
||||
final calculatedMax = monthlyData.fold<double>(
|
||||
0, (max, data) => math.max(max, data['totalExpense'] as double));
|
||||
final maxAmount = calculatedMax > 0 ? calculatedMax : 100000.0; // 기본값 10만원
|
||||
final maxAmount = _calculateChartMaxY(calculatedMax, locale);
|
||||
|
||||
for (int i = 0; i < monthlyData.length; i++) {
|
||||
final data = monthlyData[i];
|
||||
@@ -44,7 +99,7 @@ class MonthlyExpenseChartCard extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
backDrawRodData: BackgroundBarChartRodData(
|
||||
show: true,
|
||||
toY: maxAmount + (maxAmount * 0.1),
|
||||
toY: maxAmount,
|
||||
color: AppColors.navyGray.withValues(alpha: 0.1),
|
||||
),
|
||||
),
|
||||
@@ -58,6 +113,7 @@ class MonthlyExpenseChartCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.watch<LocaleProvider>().locale.languageCode;
|
||||
return SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
@@ -84,14 +140,14 @@ class MonthlyExpenseChartCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ThemedText.headline(
|
||||
text: '월별 지출 현황',
|
||||
text: AppLocalizations.of(context).monthlyExpenseTitle,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ThemedText.subtitle(
|
||||
text: '최근 6개월간 추이',
|
||||
text: AppLocalizations.of(context).recentSixMonthsTrend,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
@@ -103,25 +159,26 @@ class MonthlyExpenseChartCard extends StatelessWidget {
|
||||
child: BarChart(
|
||||
BarChartData(
|
||||
alignment: BarChartAlignment.spaceAround,
|
||||
maxY: math.max(
|
||||
maxY: _calculateChartMaxY(
|
||||
monthlyData.fold<double>(
|
||||
0,
|
||||
(max, data) => math.max(
|
||||
max, data['totalExpense'] as double)) *
|
||||
1.2,
|
||||
100000.0 // 최소값 10만원
|
||||
max, data['totalExpense'] as double)),
|
||||
locale
|
||||
),
|
||||
barGroups: _getMonthlyBarGroups(),
|
||||
barGroups: _getMonthlyBarGroups(locale),
|
||||
gridData: FlGridData(
|
||||
show: true,
|
||||
drawVerticalLine: false,
|
||||
horizontalInterval: math.max(
|
||||
monthlyData.fold<double>(
|
||||
horizontalInterval: _calculateGridInterval(
|
||||
_calculateChartMaxY(
|
||||
monthlyData.fold<double>(
|
||||
0,
|
||||
(max, data) => math.max(max,
|
||||
data['totalExpense'] as double)) /
|
||||
4,
|
||||
25000.0 // 최소 간격 2.5만원
|
||||
data['totalExpense'] as double)),
|
||||
locale
|
||||
),
|
||||
CurrencyUtil.getDefaultCurrency(locale)
|
||||
),
|
||||
getDrawingHorizontalLine: (value) {
|
||||
return FlLine(
|
||||
@@ -176,9 +233,10 @@ class MonthlyExpenseChartCard extends StatelessWidget {
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: CurrencyUtil.formatTotalAmount(
|
||||
text: CurrencyUtil.formatTotalAmountWithLocale(
|
||||
monthlyData[group.x]['totalExpense']
|
||||
as double),
|
||||
as double,
|
||||
locale),
|
||||
style: const TextStyle(
|
||||
color: Color(0xFFFBBF24),
|
||||
fontSize: 14,
|
||||
@@ -196,7 +254,7 @@ class MonthlyExpenseChartCard extends StatelessWidget {
|
||||
const SizedBox(height: 16),
|
||||
Center(
|
||||
child: ThemedText.caption(
|
||||
text: '월 구독 지출',
|
||||
text: AppLocalizations.of(context).monthlySubscriptionExpense,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
@@ -1,72 +1,175 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../models/subscription_model.dart';
|
||||
import '../../services/currency_util.dart';
|
||||
import '../../services/exchange_rate_service.dart';
|
||||
import '../../theme/app_colors.dart';
|
||||
import '../glassmorphism_card.dart';
|
||||
import '../themed_text.dart';
|
||||
import 'analysis_badge.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import '../../providers/locale_provider.dart';
|
||||
|
||||
/// 구독 서비스 비율을 파이 차트로 보여주는 카드 위젯
|
||||
class SubscriptionPieChartCard extends StatelessWidget {
|
||||
class SubscriptionPieChartCard extends StatefulWidget {
|
||||
final List<SubscriptionModel> subscriptions;
|
||||
final AnimationController animationController;
|
||||
final int touchedIndex;
|
||||
final Function(int) onPieTouch;
|
||||
|
||||
const SubscriptionPieChartCard({
|
||||
super.key,
|
||||
required this.subscriptions,
|
||||
required this.animationController,
|
||||
required this.touchedIndex,
|
||||
required this.onPieTouch,
|
||||
});
|
||||
|
||||
// 파이 차트 섹션 데이터
|
||||
List<PieChartSectionData> _getPieSections() {
|
||||
if (subscriptions.isEmpty) return [];
|
||||
@override
|
||||
State<SubscriptionPieChartCard> createState() => _SubscriptionPieChartCardState();
|
||||
}
|
||||
|
||||
final colors = [
|
||||
const Color(0xFF3B82F6),
|
||||
const Color(0xFF10B981),
|
||||
const Color(0xFFF59E0B),
|
||||
const Color(0xFFEF4444),
|
||||
const Color(0xFF8B5CF6),
|
||||
const Color(0xFF0EA5E9),
|
||||
const Color(0xFFEC4899),
|
||||
];
|
||||
class _SubscriptionPieChartCardState extends State<SubscriptionPieChartCard> {
|
||||
int _touchedIndex = -1;
|
||||
late Future<List<PieChartSectionData>> _pieSectionsFuture;
|
||||
String? _lastLocale;
|
||||
|
||||
static const _chartColors = [
|
||||
Color(0xFF3B82F6),
|
||||
Color(0xFF10B981),
|
||||
Color(0xFFF59E0B),
|
||||
Color(0xFFEF4444),
|
||||
Color(0xFF8B5CF6),
|
||||
Color(0xFF0EA5E9),
|
||||
Color(0xFFEC4899),
|
||||
];
|
||||
|
||||
// 개별 구독의 비율 계산을 위한 값들
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializeFuture();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(SubscriptionPieChartCard oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
// subscriptions나 locale이 변경된 경우만 Future 재생성
|
||||
final currentLocale = context.read<LocaleProvider>().locale.languageCode;
|
||||
if (!_listEquals(oldWidget.subscriptions, widget.subscriptions) ||
|
||||
_lastLocale != currentLocale) {
|
||||
_initializeFuture();
|
||||
}
|
||||
}
|
||||
|
||||
void _initializeFuture() {
|
||||
_lastLocale = context.read<LocaleProvider>().locale.languageCode;
|
||||
_pieSectionsFuture = _getPieSections();
|
||||
}
|
||||
|
||||
bool _listEquals(List<SubscriptionModel> a, List<SubscriptionModel> b) {
|
||||
if (a.length != b.length) return false;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (a[i].id != b[i].id ||
|
||||
a[i].currentPrice != b[i].currentPrice ||
|
||||
a[i].currency != b[i].currency ||
|
||||
a[i].serviceName != b[i].serviceName) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 파이 차트 섹션 데이터 (언어별 기본 통화로 환산)
|
||||
Future<List<PieChartSectionData>> _getPieSections() async {
|
||||
|
||||
if (widget.subscriptions.isEmpty) return [];
|
||||
|
||||
// 현재 locale 가져오기
|
||||
final locale = context.read<LocaleProvider>().locale.languageCode;
|
||||
final defaultCurrency = CurrencyUtil.getDefaultCurrency(locale);
|
||||
|
||||
// 개별 구독의 비율 계산을 위한 값들 (기본 통화로 환산)
|
||||
List<double> sectionValues = [];
|
||||
|
||||
// 각 구독의 원화 환산 금액 또는 원화 금액을 계산
|
||||
for (var subscription in subscriptions) {
|
||||
double value = subscription.monthlyCost;
|
||||
if (subscription.currency == 'USD') {
|
||||
// USD의 경우 마지막으로 조회된 환율로 대략적인 계산
|
||||
// (정확한 계산은 비동기로 이루어지므로 UI 표시용으로만 사용)
|
||||
const rate = 1350.0; // 기본 환율 (실제 값은 API로 별도로 가져옴)
|
||||
value = value * rate;
|
||||
// 각 구독의 현재 가격을 언어별 기본 통화로 환산
|
||||
for (var subscription in widget.subscriptions) {
|
||||
double value = subscription.currentPrice;
|
||||
|
||||
if (subscription.currency == defaultCurrency) {
|
||||
// 이미 기본 통화인 경우 그대로 사용
|
||||
sectionValues.add(value);
|
||||
} else if (subscription.currency == 'USD') {
|
||||
// USD를 기본 통화로 변환
|
||||
final converted = await ExchangeRateService().convertUsdToTarget(value, defaultCurrency);
|
||||
sectionValues.add(converted ?? value);
|
||||
} else if (defaultCurrency == 'USD') {
|
||||
// 기본 통화가 USD인 경우 다른 통화를 USD로 변환
|
||||
final converted = await ExchangeRateService().convertTargetToUsd(value, subscription.currency);
|
||||
sectionValues.add(converted ?? value);
|
||||
} else {
|
||||
// 기타 통화는 일단 그대로 사용 (환율 정보가 없는 경우)
|
||||
sectionValues.add(value);
|
||||
}
|
||||
sectionValues.add(value);
|
||||
}
|
||||
|
||||
// 총합 계산
|
||||
double sectionsTotal = sectionValues.fold(0, (sum, value) => sum + value);
|
||||
|
||||
// 총합이 0이면 빈 배열 반환
|
||||
if (sectionsTotal == 0) return [];
|
||||
|
||||
// 섹션 데이터 생성
|
||||
return List.generate(subscriptions.length, (i) {
|
||||
final subscription = subscriptions[i];
|
||||
// 섹션 데이터 생성 (터치 상태 제외)
|
||||
final sections = List.generate(widget.subscriptions.length, (i) {
|
||||
final percentage = (sectionValues[i] / sectionsTotal) * 100;
|
||||
final index = i % colors.length;
|
||||
final isTouched = touchedIndex == i;
|
||||
final fontSize = isTouched ? 16.0 : 12.0;
|
||||
final radius = isTouched ? 105.0 : 100.0;
|
||||
final index = i % _chartColors.length;
|
||||
|
||||
return PieChartSectionData(
|
||||
value: sectionValues[i],
|
||||
title: '${percentage.toStringAsFixed(1)}%',
|
||||
titleStyle: TextStyle(
|
||||
titleStyle: const TextStyle(
|
||||
fontSize: 12.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.pureWhite,
|
||||
shadows: [
|
||||
Shadow(color: Colors.black26, blurRadius: 2, offset: Offset(0, 1))
|
||||
],
|
||||
),
|
||||
color: _chartColors[index],
|
||||
radius: 100.0,
|
||||
titlePositionPercentageOffset: 0.6,
|
||||
badgeWidget: null,
|
||||
badgePositionPercentageOffset: .98,
|
||||
);
|
||||
});
|
||||
|
||||
return sections;
|
||||
}
|
||||
|
||||
// 배지 위젯 생성
|
||||
Widget _createBadgeWidget(int index) {
|
||||
if (index >= widget.subscriptions.length) return const SizedBox.shrink();
|
||||
|
||||
final subscription = widget.subscriptions[index];
|
||||
final colorIndex = index % _chartColors.length;
|
||||
|
||||
return IgnorePointer(
|
||||
child: AnalysisBadge(
|
||||
size: 40,
|
||||
borderColor: _chartColors[colorIndex],
|
||||
subscription: subscription,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 터치 상태를 반영한 섹션 데이터 생성
|
||||
List<PieChartSectionData> _applyTouchedState(List<PieChartSectionData> sections) {
|
||||
return List.generate(sections.length, (i) {
|
||||
final section = sections[i];
|
||||
final isTouched = _touchedIndex == i;
|
||||
final fontSize = isTouched ? 16.0 : 12.0;
|
||||
final radius = isTouched ? 105.0 : 100.0;
|
||||
|
||||
return PieChartSectionData(
|
||||
value: section.value,
|
||||
title: section.title,
|
||||
titleStyle: section.titleStyle?.copyWith(fontSize: fontSize) ?? TextStyle(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.pureWhite,
|
||||
@@ -74,17 +177,11 @@ class SubscriptionPieChartCard extends StatelessWidget {
|
||||
Shadow(color: Colors.black26, blurRadius: 2, offset: Offset(0, 1))
|
||||
],
|
||||
),
|
||||
color: colors[index],
|
||||
color: section.color,
|
||||
radius: radius,
|
||||
titlePositionPercentageOffset: 0.6,
|
||||
badgeWidget: isTouched
|
||||
? AnalysisBadge(
|
||||
size: 40,
|
||||
borderColor: colors[index],
|
||||
subscription: subscription,
|
||||
)
|
||||
: null,
|
||||
badgePositionPercentageOffset: .98,
|
||||
titlePositionPercentageOffset: section.titlePositionPercentageOffset,
|
||||
badgeWidget: isTouched ? _createBadgeWidget(i) : null,
|
||||
badgePositionPercentageOffset: section.badgePositionPercentageOffset,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -96,7 +193,7 @@ class SubscriptionPieChartCard extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: FadeTransition(
|
||||
opacity: CurvedAnimation(
|
||||
parent: animationController,
|
||||
parent: widget.animationController,
|
||||
curve: const Interval(0.0, 0.7, curve: Curves.easeOut),
|
||||
),
|
||||
child: SlideTransition(
|
||||
@@ -104,7 +201,7 @@ class SubscriptionPieChartCard extends StatelessWidget {
|
||||
begin: const Offset(0, 0.2),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(
|
||||
parent: animationController,
|
||||
parent: widget.animationController,
|
||||
curve: const Interval(0.0, 0.7, curve: Curves.easeOut),
|
||||
)),
|
||||
child: GlassmorphismCard(
|
||||
@@ -120,13 +217,15 @@ class SubscriptionPieChartCard extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ThemedText.headline(
|
||||
text: '구독 서비스 비율',
|
||||
text: AppLocalizations.of(context).subscriptionServiceRatio,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
FutureBuilder<String>(
|
||||
future: CurrencyUtil.getExchangeRateInfo(),
|
||||
future: CurrencyUtil.getExchangeRateInfoForLocale(
|
||||
context.watch<LocaleProvider>().locale.languageCode
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData &&
|
||||
snapshot.data!.isNotEmpty) {
|
||||
@@ -145,7 +244,7 @@ class SubscriptionPieChartCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
snapshot.data!,
|
||||
AppLocalizations.of(context).exchangeRateFormat(snapshot.data!),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -161,20 +260,20 @@ class SubscriptionPieChartCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ThemedText.subtitle(
|
||||
text: '월 지출 기준',
|
||||
text: AppLocalizations.of(context).monthlyExpenseBasis,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Center(
|
||||
child: subscriptions.isEmpty
|
||||
? const SizedBox(
|
||||
child: widget.subscriptions.isEmpty
|
||||
? SizedBox(
|
||||
height: 250,
|
||||
child: Center(
|
||||
child: ThemedText(
|
||||
'구독중인 서비스가 없습니다',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(context).noSubscriptionServices,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -182,52 +281,90 @@ class SubscriptionPieChartCard extends StatelessWidget {
|
||||
)
|
||||
: SizedBox(
|
||||
height: 250,
|
||||
child: PieChart(
|
||||
PieChartData(
|
||||
borderData: FlBorderData(show: false),
|
||||
sectionsSpace: 2,
|
||||
centerSpaceRadius: 60,
|
||||
sections: _getPieSections(),
|
||||
pieTouchData: PieTouchData(
|
||||
touchCallback: (FlTouchEvent event,
|
||||
pieTouchResponse) {
|
||||
if (!event
|
||||
.isInterestedForInteractions ||
|
||||
pieTouchResponse == null ||
|
||||
pieTouchResponse
|
||||
.touchedSection ==
|
||||
null) {
|
||||
onPieTouch(-1);
|
||||
return;
|
||||
}
|
||||
onPieTouch(pieTouchResponse
|
||||
.touchedSection!
|
||||
.touchedSectionIndex);
|
||||
},
|
||||
),
|
||||
),
|
||||
child: FutureBuilder<List<PieChartSectionData>>(
|
||||
future: _pieSectionsFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||
return Center(
|
||||
child: ThemedText(
|
||||
AppLocalizations.of(context).noSubscriptionServices,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return PieChart(
|
||||
PieChartData(
|
||||
borderData: FlBorderData(show: false),
|
||||
sectionsSpace: 2,
|
||||
centerSpaceRadius: 60,
|
||||
sections: _applyTouchedState(snapshot.data!),
|
||||
pieTouchData: PieTouchData(
|
||||
enabled: true,
|
||||
touchCallback: (FlTouchEvent event,
|
||||
pieTouchResponse) {
|
||||
// 터치 응답이 없거나 섹션이 없는 경우
|
||||
if (pieTouchResponse == null ||
|
||||
pieTouchResponse.touchedSection == null) {
|
||||
// 차트 밖으로 나갔을 때만 리셋
|
||||
if (_touchedIndex != -1) {
|
||||
setState(() {
|
||||
_touchedIndex = -1;
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final touchedIndex = pieTouchResponse
|
||||
.touchedSection!
|
||||
.touchedSectionIndex;
|
||||
|
||||
// 탭 이벤트 처리 (토글)
|
||||
if (event is FlTapUpEvent) {
|
||||
setState(() {
|
||||
// 동일 섹션 탭하면 선택 해제, 아니면 선택
|
||||
_touchedIndex = (_touchedIndex == touchedIndex) ? -1 : touchedIndex;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// hover 이벤트 처리 (단순 표시)
|
||||
if (event is FlPointerHoverEvent ||
|
||||
event is FlPointerEnterEvent) {
|
||||
// 현재 인덱스와 다른 경우만 업데이트
|
||||
if (_touchedIndex != touchedIndex) {
|
||||
setState(() {
|
||||
_touchedIndex = touchedIndex;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// 서비스 목록
|
||||
Column(
|
||||
children: subscriptions.isEmpty
|
||||
children: widget.subscriptions.isEmpty
|
||||
? []
|
||||
: List.generate(
|
||||
subscriptions.length,
|
||||
widget.subscriptions.length,
|
||||
(index) {
|
||||
final subscription =
|
||||
subscriptions[index];
|
||||
final color = [
|
||||
const Color(0xFF3B82F6),
|
||||
const Color(0xFF10B981),
|
||||
const Color(0xFFF59E0B),
|
||||
const Color(0xFFEF4444),
|
||||
const Color(0xFF8B5CF6),
|
||||
const Color(0xFF0EA5E9),
|
||||
const Color(0xFFEC4899),
|
||||
][index % 7];
|
||||
widget.subscriptions[index];
|
||||
final color = _chartColors[index % _chartColors.length];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 4.0),
|
||||
@@ -254,8 +391,9 @@ class SubscriptionPieChartCard extends StatelessWidget {
|
||||
),
|
||||
FutureBuilder<String>(
|
||||
future: CurrencyUtil
|
||||
.formatSubscriptionAmount(
|
||||
subscription),
|
||||
.formatSubscriptionAmountWithLocale(
|
||||
subscription,
|
||||
context.read<LocaleProvider>().locale.languageCode),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return ThemedText(
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../models/subscription_model.dart';
|
||||
import '../../services/currency_util.dart';
|
||||
import '../../providers/locale_provider.dart';
|
||||
import '../../utils/haptic_feedback_helper.dart';
|
||||
import '../../theme/app_colors.dart';
|
||||
import '../glassmorphism_card.dart';
|
||||
import '../themed_text.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
|
||||
/// 총 지출 요약을 보여주는 카드 위젯
|
||||
class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
@@ -23,6 +26,7 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.watch<LocaleProvider>().locale.languageCode;
|
||||
return SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
@@ -52,7 +56,7 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ThemedText.headline(
|
||||
text: '총 지출 요약',
|
||||
text: AppLocalizations.of(context).totalExpenseSummary,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
@@ -63,14 +67,14 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () async {
|
||||
final totalExpenseText = CurrencyUtil.formatTotalAmount(totalExpense);
|
||||
final totalExpenseText = CurrencyUtil.formatTotalAmountWithLocale(totalExpense, locale);
|
||||
await Clipboard.setData(
|
||||
ClipboardData(text: totalExpenseText));
|
||||
HapticFeedbackHelper.lightImpact();
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('총 지출액이 복사되었습니다: $totalExpenseText'),
|
||||
content: Text(AppLocalizations.of(context).totalExpenseCopied(totalExpenseText)),
|
||||
duration: const Duration(seconds: 2),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -89,7 +93,7 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ThemedText.subtitle(
|
||||
text: '월 단위 총액',
|
||||
text: AppLocalizations.of(context).monthlyTotalAmount,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
@@ -103,7 +107,7 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ThemedText.caption(
|
||||
text: '총 지출',
|
||||
text: AppLocalizations.of(context).totalExpense,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -111,7 +115,7 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
ThemedText(
|
||||
CurrencyUtil.formatTotalAmount(totalExpense),
|
||||
CurrencyUtil.formatTotalAmountWithLocale(totalExpense, locale),
|
||||
style: const TextStyle(
|
||||
fontSize: 26,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -148,7 +152,7 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
ThemedText.caption(
|
||||
text: '총 서비스',
|
||||
text: AppLocalizations.of(context).totalServices,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -156,7 +160,7 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
ThemedText(
|
||||
'${subscriptions.length}개',
|
||||
AppLocalizations.of(context).subscriptionCount(subscriptions.length),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -190,7 +194,7 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
ThemedText.caption(
|
||||
text: '평균 요금',
|
||||
text: AppLocalizations.of(context).averageCost,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -198,10 +202,11 @@ class TotalExpenseSummaryCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
ThemedText(
|
||||
CurrencyUtil.formatTotalAmount(
|
||||
CurrencyUtil.formatTotalAmountWithLocale(
|
||||
subscriptions.isEmpty
|
||||
? 0
|
||||
: totalExpense / subscriptions.length),
|
||||
: totalExpense / subscriptions.length,
|
||||
locale),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
Reference in New Issue
Block a user