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:
JiWoong Sul
2025-07-16 17:34:32 +09:00
parent 4d1c0f5dab
commit 0f0b02bf08
55 changed files with 4100 additions and 1197 deletions

View File

@@ -3,10 +3,14 @@ import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../models/subscription_model.dart';
import '../providers/category_provider.dart';
import '../providers/locale_provider.dart';
import '../services/subscription_url_matcher.dart';
import '../services/currency_util.dart';
import 'website_icon.dart';
import 'app_navigator.dart';
import '../theme/app_colors.dart';
import 'glassmorphism_card.dart';
import '../l10n/app_localizations.dart';
class SubscriptionCard extends StatefulWidget {
final SubscriptionModel subscription;
@@ -26,6 +30,7 @@ class _SubscriptionCardState extends State<SubscriptionCard>
with SingleTickerProviderStateMixin {
late AnimationController _hoverController;
bool _isHovering = false;
String? _displayName;
@override
void initState() {
@@ -34,9 +39,36 @@ class _SubscriptionCardState extends State<SubscriptionCard>
vsync: this,
duration: const Duration(milliseconds: 200),
);
_loadDisplayName();
}
Future<void> _loadDisplayName() async {
if (!mounted) return;
final localeProvider = context.read<LocaleProvider>();
final locale = localeProvider.locale.languageCode;
final displayName = await SubscriptionUrlMatcher.getServiceDisplayName(
serviceName: widget.subscription.serviceName,
locale: locale,
);
if (mounted) {
setState(() {
_displayName = displayName;
});
}
}
@override
void didUpdateWidget(SubscriptionCard oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.subscription.serviceName != widget.subscription.serviceName) {
_loadDisplayName();
}
}
@override
void dispose() {
_hoverController.dispose();
@@ -66,20 +98,20 @@ class _SubscriptionCardState extends State<SubscriptionCard>
// 오늘이 결제일인 경우
if (dateOnlyNow.isAtSameMomentAs(dateOnlyBilling)) {
return '오늘 결제 예정';
return AppLocalizations.of(context).paymentDueToday;
}
// 미래 날짜인 경우 남은 일수 계산
if (dateOnlyBilling.isAfter(dateOnlyNow)) {
final difference = dateOnlyBilling.difference(dateOnlyNow).inDays;
return '$difference일 후 결제 예정';
return AppLocalizations.of(context).paymentDueInDays(difference);
}
// 과거 날짜인 경우, 다음 결제일 계산
final billingCycle = widget.subscription.billingCycle;
// 월간 구독인 경우
if (billingCycle == '월간') {
if (SubscriptionModel.normalizeBillingCycle(billingCycle) == 'monthly') {
// 결제일에 해당하는 날짜 가져오기
int day = nextBillingDate.day;
int nextMonth = now.month;
@@ -109,12 +141,12 @@ class _SubscriptionCardState extends State<SubscriptionCard>
final nextDate = DateTime(nextYear, nextMonth, day);
final days = nextDate.difference(dateOnlyNow).inDays;
if (days == 0) return '오늘 결제 예정';
return '$days일 후 결제 예정';
if (days == 0) return AppLocalizations.of(context).paymentDueToday;
return AppLocalizations.of(context).paymentDueInDays(days);
}
// 연간 구독인 경우
if (billingCycle == '연간') {
if (SubscriptionModel.normalizeBillingCycle(billingCycle) == 'yearly') {
// 결제일에 해당하는 날짜와 월 가져오기
int day = nextBillingDate.day;
int month = nextBillingDate.month;
@@ -143,18 +175,18 @@ class _SubscriptionCardState extends State<SubscriptionCard>
final nextYearDate = DateTime(year, month, day);
final days = nextYearDate.difference(dateOnlyNow).inDays;
if (days == 0) return '오늘 결제 예정';
return '$days일 후 결제 예정';
if (days == 0) return AppLocalizations.of(context).paymentDueToday;
return AppLocalizations.of(context).paymentDueInDays(days);
} else {
final days = thisYearDate.difference(dateOnlyNow).inDays;
if (days == 0) return '오늘 결제 예정';
return '$days일 후 결제 예정';
if (days == 0) return AppLocalizations.of(context).paymentDueToday;
return AppLocalizations.of(context).paymentDueInDays(days);
}
}
// 주간 구독인 경우
if (billingCycle == '주간') {
if (SubscriptionModel.normalizeBillingCycle(billingCycle) == 'weekly') {
// 결제 요일 가져오기
final billingWeekday = nextBillingDate.weekday;
// 현재 요일
@@ -171,20 +203,20 @@ class _SubscriptionCardState extends State<SubscriptionCard>
daysUntilNext = 7; // 다음 주 같은 요일
}
if (daysUntilNext == 0) return '오늘 결제 예정';
return '$daysUntilNext 후 결제 예정';
if (daysUntilNext == 0) return AppLocalizations.of(context).paymentDueToday;
return AppLocalizations.of(context).paymentDueInDays(daysUntilNext);
}
// 기본값 - 예상할 수 없는 경우
return '결제일 정보 필요';
return AppLocalizations.of(context).paymentInfoNeeded;
}
// 결제일이 가까운지 확인 (7일 이내)
bool _isNearBilling() {
final text = _getNextBillingText();
if (text == '오늘 결제 예정') return true;
if (text == AppLocalizations.of(context).paymentDueToday) return true;
final regex = RegExp(r'(\d+)일 후');
final regex = RegExp(r'(\d+)');
final match = regex.firstMatch(text);
if (match != null) {
final days = int.parse(match.group(1) ?? '0');
@@ -222,9 +254,41 @@ class _SubscriptionCardState extends State<SubscriptionCard>
}
}
// 가격 포맷팅 함수 (언어별 통화)
Future<String> _getFormattedPrice() async {
final locale = context.read<LocaleProvider>().locale.languageCode;
if (widget.subscription.isCurrentlyInEvent) {
// 이벤트 중인 경우 원래 가격과 현재 가격 모두 표시
final originalPrice = await CurrencyUtil.formatAmountWithLocale(
widget.subscription.monthlyCost,
widget.subscription.currency,
locale,
);
final currentPrice = await CurrencyUtil.formatAmountWithLocale(
widget.subscription.currentPrice,
widget.subscription.currency,
locale,
);
return '$originalPrice|$currentPrice';
} else {
return CurrencyUtil.formatAmountWithLocale(
widget.subscription.currentPrice,
widget.subscription.currency,
locale,
);
}
}
@override
Widget build(BuildContext context) {
// LocaleProvider를 watch하여 언어 변경시 자동 업데이트
final localeProvider = context.watch<LocaleProvider>();
// 언어가 변경되면 displayName 다시 로드
WidgetsBinding.instance.addPostFrameCallback((_) {
_loadDisplayName();
});
final isNearBilling = _isNearBilling();
return Hero(
@@ -238,6 +302,7 @@ class _SubscriptionCardState extends State<SubscriptionCard>
blur: _isHovering ? 15 : 10,
width: double.infinity, // 전체 너비를 차지하도록 설정
onTap: widget.onTap ?? () async {
print('[SubscriptionCard] AnimatedGlassmorphismCard onTap 호출됨 - ${widget.subscription.serviceName}');
await AppNavigator.toDetail(context, widget.subscription);
},
child: Column(
@@ -290,7 +355,7 @@ class _SubscriptionCardState extends State<SubscriptionCard>
// 서비스명
Flexible(
child: Text(
widget.subscription.serviceName,
_displayName ?? widget.subscription.serviceName,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18,
@@ -322,18 +387,18 @@ class _SubscriptionCardState extends State<SubscriptionCard>
borderRadius:
BorderRadius.circular(12),
),
child: const Row(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
const Icon(
Icons.local_offer_rounded,
size: 11,
color: AppColors.pureWhite,
),
SizedBox(width: 3),
const SizedBox(width: 3),
Text(
'이벤트',
style: TextStyle(
AppLocalizations.of(context).event,
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: AppColors.pureWhite,
@@ -361,7 +426,7 @@ class _SubscriptionCardState extends State<SubscriptionCard>
),
),
child: Text(
widget.subscription.billingCycle,
AppLocalizations.of(context).getBillingCycleName(widget.subscription.billingCycle),
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
@@ -382,57 +447,51 @@ class _SubscriptionCardState extends State<SubscriptionCard>
MainAxisAlignment.spaceBetween,
children: [
// 가격 표시 (이벤트 가격 반영)
Row(
children: [
// 이벤트 중인 경우 원래 가격을 취소선으로 표시
if (widget.subscription.isCurrentlyInEvent) ...[
Text(
widget.subscription.currency == 'USD'
? NumberFormat.currency(
locale: 'en_US',
symbol: '\$',
decimalDigits: 2,
).format(widget
.subscription.monthlyCost)
: NumberFormat.currency(
locale: 'ko_KR',
symbol: '',
decimalDigits: 0,
).format(widget
.subscription.monthlyCost),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.navyGray, // color.md 가이드: 서브 텍스트
decoration: TextDecoration.lineThrough,
// 가격 표시 (언어별 통화)
FutureBuilder<String>(
future: _getFormattedPrice(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
}
if (widget.subscription.isCurrentlyInEvent && snapshot.data!.contains('|')) {
final prices = snapshot.data!.split('|');
return Row(
children: [
Text(
prices[0],
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.navyGray,
decoration: TextDecoration.lineThrough,
),
),
const SizedBox(width: 8),
Text(
prices[1],
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Color(0xFFFF6B6B),
),
),
],
);
} else {
return Text(
snapshot.data!,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: widget.subscription.isCurrentlyInEvent
? const Color(0xFFFF6B6B)
: AppColors.primaryColor,
),
),
const SizedBox(width: 8),
],
// 현재 가격 (이벤트 또는 정상 가격)
Text(
widget.subscription.currency == 'USD'
? NumberFormat.currency(
locale: 'en_US',
symbol: '\$',
decimalDigits: 2,
).format(widget
.subscription.currentPrice)
: NumberFormat.currency(
locale: 'ko_KR',
symbol: '',
decimalDigits: 0,
).format(widget
.subscription.currentPrice),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: widget.subscription.isCurrentlyInEvent
? const Color(0xFFFF6B6B)
: AppColors.primaryColor,
),
),
],
);
}
},
),
// 결제 예정일 정보
@@ -505,23 +564,25 @@ class _SubscriptionCardState extends State<SubscriptionCard>
color: Color(0xFFFF6B6B),
),
const SizedBox(width: 4),
Text(
widget.subscription.currency == 'USD'
? '${NumberFormat.currency(
locale: 'en_US',
symbol: '\$',
decimalDigits: 2,
).format(widget.subscription.eventSavings)} 절약'
: '${NumberFormat.currency(
locale: 'ko_KR',
symbol: '',
decimalDigits: 0,
).format(widget.subscription.eventSavings)} 절약',
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xFFFF6B6B),
// 이벤트 절약액 표시 (언어별 통화)
FutureBuilder<String>(
future: CurrencyUtil.formatEventSavingsWithLocale(
widget.subscription,
localeProvider.locale.languageCode,
),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
}
return Text(
'${snapshot.data!} ${AppLocalizations.of(context).saving}',
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xFFFF6B6B),
),
);
},
),
],
),
@@ -530,7 +591,7 @@ class _SubscriptionCardState extends State<SubscriptionCard>
// 이벤트 종료일까지 남은 일수
if (widget.subscription.eventEndDate != null) ...[
Text(
'${widget.subscription.eventEndDate!.difference(DateTime.now()).inDays}일 남음',
AppLocalizations.of(context).daysRemaining(widget.subscription.eventEndDate!.difference(DateTime.now()).inDays),
style: const TextStyle(
fontSize: 11,
color: AppColors.navyGray, // color.md 가이드: 서브 텍스트