style: apply dart format across project
This commit is contained in:
@@ -28,14 +28,14 @@ class CategoryProvider extends ChangeNotifier {
|
||||
sortedCategories.sort((a, b) {
|
||||
final aIndex = _categoryOrder.indexOf(a.name);
|
||||
final bIndex = _categoryOrder.indexOf(b.name);
|
||||
|
||||
|
||||
// 순서 목록에 없는 카테고리는 맨 뒤로
|
||||
if (aIndex == -1) return 1;
|
||||
if (bIndex == -1) return -1;
|
||||
|
||||
|
||||
return aIndex.compareTo(bIndex);
|
||||
});
|
||||
|
||||
|
||||
return sortedCategories;
|
||||
}
|
||||
|
||||
@@ -59,9 +59,17 @@ class CategoryProvider extends ChangeNotifier {
|
||||
{'name': 'storageCloud', 'color': '#2196F3', 'icon': 'cloud'},
|
||||
{'name': 'telecomInternetTv', 'color': '#00BCD4', 'icon': 'wifi'},
|
||||
{'name': 'lifestyle', 'color': '#4CAF50', 'icon': 'home'},
|
||||
{'name': 'shoppingEcommerce', 'color': '#FF9800', 'icon': 'shopping_cart'},
|
||||
{
|
||||
'name': 'shoppingEcommerce',
|
||||
'color': '#FF9800',
|
||||
'icon': 'shopping_cart'
|
||||
},
|
||||
{'name': 'programming', 'color': '#795548', 'icon': 'code'},
|
||||
{'name': 'collaborationOffice', 'color': '#607D8B', 'icon': 'business_center'},
|
||||
{
|
||||
'name': 'collaborationOffice',
|
||||
'color': '#607D8B',
|
||||
'icon': 'business_center'
|
||||
},
|
||||
{'name': 'aiService', 'color': '#673AB7', 'icon': 'smart_toy'},
|
||||
{'name': 'other', 'color': '#9E9E9E', 'icon': 'category'},
|
||||
];
|
||||
@@ -117,7 +125,7 @@ class CategoryProvider extends ChangeNotifier {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 카테고리 이름을 현재 언어에 맞게 반환
|
||||
String getLocalizedCategoryName(BuildContext context, String categoryKey) {
|
||||
final localizations = AppLocalizations.of(context);
|
||||
|
||||
@@ -5,24 +5,24 @@ import 'dart:ui' as ui;
|
||||
class LocaleProvider extends ChangeNotifier {
|
||||
late Box<String> _localeBox;
|
||||
Locale _locale = const Locale('ko');
|
||||
|
||||
|
||||
static const List<String> supportedLanguages = ['en', 'ko', 'ja', 'zh'];
|
||||
|
||||
Locale get locale => _locale;
|
||||
|
||||
Future<void> init() async {
|
||||
_localeBox = await Hive.openBox<String>('locale');
|
||||
|
||||
|
||||
// 저장된 언어 설정 확인
|
||||
final savedLocale = _localeBox.get('locale');
|
||||
|
||||
|
||||
if (savedLocale != null) {
|
||||
// 저장된 언어가 있으면 사용
|
||||
_locale = Locale(savedLocale);
|
||||
} else {
|
||||
// 저장된 언어가 없으면 시스템 언어 감지
|
||||
final systemLocale = ui.PlatformDispatcher.instance.locale;
|
||||
|
||||
|
||||
// 시스템 언어가 지원되는 언어인지 확인
|
||||
if (supportedLanguages.contains(systemLocale.languageCode)) {
|
||||
_locale = Locale(systemLocale.languageCode);
|
||||
@@ -30,11 +30,11 @@ class LocaleProvider extends ChangeNotifier {
|
||||
// 지원되지 않는 언어면 영어 사용
|
||||
_locale = const Locale('en');
|
||||
}
|
||||
|
||||
|
||||
// 감지된 언어 저장
|
||||
await _localeBox.put('locale', _locale.languageCode);
|
||||
}
|
||||
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,25 +36,25 @@ class NavigationProvider extends ChangeNotifier {
|
||||
|
||||
void updateCurrentIndex(int index, {bool addToHistory = true}) {
|
||||
if (_currentIndex == index) return;
|
||||
|
||||
|
||||
_currentIndex = index;
|
||||
_currentRoute = indexToRoute[index] ?? '/';
|
||||
_currentTitle = indexToTitle[index] ?? 'home';
|
||||
|
||||
|
||||
if (addToHistory && index >= 0) {
|
||||
_navigationHistory.add(index);
|
||||
if (_navigationHistory.length > 10) {
|
||||
_navigationHistory.removeAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updateByRoute(String route) {
|
||||
final index = routeToIndex[route] ?? 0;
|
||||
_currentRoute = route;
|
||||
|
||||
|
||||
if (index >= 0) {
|
||||
_currentIndex = index;
|
||||
_currentTitle = indexToTitle[index] ?? 'home';
|
||||
@@ -70,7 +70,7 @@ class NavigationProvider extends ChangeNotifier {
|
||||
_currentTitle = 'home';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -103,4 +103,4 @@ class NavigationProvider extends ChangeNotifier {
|
||||
_navigationHistory.add(0);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ class NotificationProvider extends ChangeNotifier {
|
||||
try {
|
||||
_isEnabled = value;
|
||||
await NotificationService.setNotificationEnabled(value);
|
||||
|
||||
|
||||
// 첫 권한 부여 시 기본 설정 적용
|
||||
if (value) {
|
||||
await initializeDefaultSettingsOnFirstPermission();
|
||||
}
|
||||
|
||||
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
debugPrint('알림 활성화 설정 중 오류 발생: $e');
|
||||
@@ -270,15 +270,17 @@ class NotificationProvider extends ChangeNotifier {
|
||||
// 첫 권한 부여 시 기본 설정 초기화
|
||||
Future<void> initializeDefaultSettingsOnFirstPermission() async {
|
||||
try {
|
||||
final firstGranted = await _secureStorage.read(key: _firstPermissionGrantedKey);
|
||||
final firstGranted =
|
||||
await _secureStorage.read(key: _firstPermissionGrantedKey);
|
||||
if (firstGranted != 'true') {
|
||||
// 첫 권한 부여 시 기본값 설정
|
||||
await setReminderDays(2); // 2일 전 알림
|
||||
await setDailyReminderEnabled(true); // 반복 알림 활성화
|
||||
await setPaymentEnabled(true); // 결제 예정 알림 활성화
|
||||
|
||||
|
||||
// 첫 권한 부여 플래그 저장
|
||||
await _secureStorage.write(key: _firstPermissionGrantedKey, value: 'true');
|
||||
await _secureStorage.write(
|
||||
key: _firstPermissionGrantedKey, value: 'true');
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('기본 설정 초기화 중 오류 발생: $e');
|
||||
|
||||
@@ -19,9 +19,9 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
|
||||
double get totalMonthlyExpense {
|
||||
final exchangeRateService = ExchangeRateService();
|
||||
final rate = exchangeRateService.cachedUsdToKrwRate ??
|
||||
ExchangeRateService.DEFAULT_USD_TO_KRW_RATE;
|
||||
|
||||
final rate = exchangeRateService.cachedUsdToKrwRate ??
|
||||
ExchangeRateService.DEFAULT_USD_TO_KRW_RATE;
|
||||
|
||||
final total = _subscriptions.fold(
|
||||
0.0,
|
||||
(sum, subscription) {
|
||||
@@ -31,11 +31,12 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
'\$${price} × ₩$rate = ₩${price * rate}');
|
||||
return sum + (price * rate);
|
||||
}
|
||||
debugPrint('[SubscriptionProvider] ${subscription.serviceName}: ₩$price');
|
||||
debugPrint(
|
||||
'[SubscriptionProvider] ${subscription.serviceName}: ₩$price');
|
||||
return sum + price;
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
debugPrint('[SubscriptionProvider] totalMonthlyExpense 계산 완료: '
|
||||
'${_subscriptions.length}개 구독, 총액 ₩$total');
|
||||
return total;
|
||||
@@ -69,10 +70,10 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
|
||||
_subscriptionBox = await Hive.openBox<SubscriptionModel>('subscriptions');
|
||||
await refreshSubscriptions();
|
||||
|
||||
|
||||
// categoryId 마이그레이션
|
||||
await _migrateCategoryIds();
|
||||
|
||||
|
||||
// 앱 시작 시 이벤트 상태 확인
|
||||
await checkAndUpdateEventStatus();
|
||||
|
||||
@@ -90,11 +91,11 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
try {
|
||||
_subscriptions = _subscriptionBox.values.toList()
|
||||
..sort((a, b) => a.nextBillingDate.compareTo(b.nextBillingDate));
|
||||
|
||||
|
||||
debugPrint('[SubscriptionProvider] refreshSubscriptions 완료: '
|
||||
'${_subscriptions.length}개 구독, '
|
||||
'총 월간 지출: ${totalMonthlyExpense.toStringAsFixed(2)}');
|
||||
|
||||
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
debugPrint('구독 목록 새로고침 중 오류 발생: $e');
|
||||
@@ -139,7 +140,7 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
|
||||
await _subscriptionBox.put(subscription.id, subscription);
|
||||
await refreshSubscriptions();
|
||||
|
||||
|
||||
// 이벤트가 활성화된 경우 알림 스케줄 재설정
|
||||
if (isEventActive && eventEndDate != null) {
|
||||
await _scheduleEventEndNotification(subscription);
|
||||
@@ -191,7 +192,6 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> clearAllSubscriptions() async {
|
||||
_isLoading = true;
|
||||
notifyListeners();
|
||||
@@ -217,8 +217,9 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
/// 이벤트 종료 알림을 스케줄링합니다.
|
||||
Future<void> _scheduleEventEndNotification(SubscriptionModel subscription) async {
|
||||
if (subscription.eventEndDate != null &&
|
||||
Future<void> _scheduleEventEndNotification(
|
||||
SubscriptionModel subscription) async {
|
||||
if (subscription.eventEndDate != null &&
|
||||
subscription.eventEndDate!.isAfter(DateTime.now())) {
|
||||
await NotificationService.scheduleNotification(
|
||||
id: '${subscription.id}_event_end'.hashCode,
|
||||
@@ -232,19 +233,18 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
/// 모든 구독의 이벤트 상태를 확인하고 업데이트합니다.
|
||||
Future<void> checkAndUpdateEventStatus() async {
|
||||
bool hasChanges = false;
|
||||
|
||||
|
||||
for (var subscription in _subscriptions) {
|
||||
// 이벤트가 종료되었지만 아직 활성화되어 있는 경우
|
||||
if (subscription.isEventActive &&
|
||||
if (subscription.isEventActive &&
|
||||
subscription.eventEndDate != null &&
|
||||
subscription.eventEndDate!.isBefore(DateTime.now())) {
|
||||
|
||||
subscription.isEventActive = false;
|
||||
await _subscriptionBox.put(subscription.id, subscription);
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hasChanges) {
|
||||
await refreshSubscriptions();
|
||||
}
|
||||
@@ -253,70 +253,73 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
/// 총 월간 지출을 계산합니다. (로케일별 기본 통화로 환산)
|
||||
Future<double> calculateTotalExpense({String? locale}) async {
|
||||
if (_subscriptions.isEmpty) return 0.0;
|
||||
|
||||
|
||||
// locale이 제공되지 않으면 현재 로케일 사용
|
||||
final targetCurrency = locale != null
|
||||
? CurrencyUtil.getDefaultCurrency(locale)
|
||||
: 'KRW'; // 기본값
|
||||
|
||||
final targetCurrency =
|
||||
locale != null ? CurrencyUtil.getDefaultCurrency(locale) : 'KRW'; // 기본값
|
||||
|
||||
debugPrint('[calculateTotalExpense] 계산 시작 - 타겟 통화: $targetCurrency');
|
||||
double total = 0.0;
|
||||
|
||||
|
||||
for (final subscription in _subscriptions) {
|
||||
final currentPrice = subscription.currentPrice;
|
||||
debugPrint('[calculateTotalExpense] ${subscription.serviceName}: '
|
||||
'${currentPrice} ${subscription.currency} (이벤트 적용: ${subscription.isCurrentlyInEvent})');
|
||||
|
||||
|
||||
final converted = await ExchangeRateService().convertBetweenCurrencies(
|
||||
currentPrice,
|
||||
subscription.currency,
|
||||
targetCurrency,
|
||||
);
|
||||
|
||||
|
||||
total += converted ?? currentPrice;
|
||||
}
|
||||
|
||||
|
||||
debugPrint('[calculateTotalExpense] 총 지출 계산 완료: $total $targetCurrency');
|
||||
return total;
|
||||
}
|
||||
|
||||
/// 최근 6개월의 월별 지출 데이터를 반환합니다. (로케일별 기본 통화로 환산)
|
||||
Future<List<Map<String, dynamic>>> getMonthlyExpenseData({String? locale}) async {
|
||||
Future<List<Map<String, dynamic>>> getMonthlyExpenseData(
|
||||
{String? locale}) async {
|
||||
final now = DateTime.now();
|
||||
final List<Map<String, dynamic>> monthlyData = [];
|
||||
|
||||
|
||||
// locale이 제공되지 않으면 현재 로케일 사용
|
||||
final targetCurrency = locale != null
|
||||
? CurrencyUtil.getDefaultCurrency(locale)
|
||||
: 'KRW'; // 기본값
|
||||
|
||||
final targetCurrency =
|
||||
locale != null ? CurrencyUtil.getDefaultCurrency(locale) : 'KRW'; // 기본값
|
||||
|
||||
// 최근 6개월 데이터 생성
|
||||
for (int i = 5; i >= 0; i--) {
|
||||
final month = DateTime(now.year, now.month - i, 1);
|
||||
double monthTotal = 0.0;
|
||||
|
||||
|
||||
// 현재 월인지 확인
|
||||
final isCurrentMonth = (month.year == now.year && month.month == now.month);
|
||||
|
||||
final isCurrentMonth =
|
||||
(month.year == now.year && month.month == now.month);
|
||||
|
||||
if (isCurrentMonth) {
|
||||
debugPrint('[getMonthlyExpenseData] 현재 월(${month.year}-${month.month}) 계산 중...');
|
||||
debugPrint(
|
||||
'[getMonthlyExpenseData] 현재 월(${month.year}-${month.month}) 계산 중...');
|
||||
}
|
||||
|
||||
|
||||
// 해당 월에 활성화된 구독 계산
|
||||
for (final subscription in _subscriptions) {
|
||||
if (isCurrentMonth) {
|
||||
// 현재 월인 경우: 모든 활성 구독 포함 (calculateTotalExpense와 동일하게)
|
||||
final cost = subscription.currentPrice;
|
||||
debugPrint('[getMonthlyExpenseData] 현재 월 - ${subscription.serviceName}: '
|
||||
debugPrint(
|
||||
'[getMonthlyExpenseData] 현재 월 - ${subscription.serviceName}: '
|
||||
'${cost} ${subscription.currency} (이벤트 적용: ${subscription.isCurrentlyInEvent})');
|
||||
|
||||
|
||||
// 통화 변환
|
||||
final converted = await ExchangeRateService().convertBetweenCurrencies(
|
||||
final converted =
|
||||
await ExchangeRateService().convertBetweenCurrencies(
|
||||
cost,
|
||||
subscription.currency,
|
||||
targetCurrency,
|
||||
);
|
||||
|
||||
|
||||
monthTotal += converted ?? cost;
|
||||
} else {
|
||||
// 과거 월인 경우: 기존 로직 유지
|
||||
@@ -324,46 +327,50 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
final subscriptionStartDate = subscription.nextBillingDate.subtract(
|
||||
Duration(days: _getBillingCycleDays(subscription.billingCycle)),
|
||||
);
|
||||
|
||||
if (subscriptionStartDate.isBefore(DateTime(month.year, month.month + 1, 1)) &&
|
||||
|
||||
if (subscriptionStartDate
|
||||
.isBefore(DateTime(month.year, month.month + 1, 1)) &&
|
||||
subscription.nextBillingDate.isAfter(month)) {
|
||||
// 해당 월의 비용 계산 (이벤트 가격 고려)
|
||||
double cost;
|
||||
|
||||
if (subscription.isEventActive &&
|
||||
|
||||
if (subscription.isEventActive &&
|
||||
subscription.eventStartDate != null &&
|
||||
subscription.eventEndDate != null &&
|
||||
// 이벤트 기간과 해당 월이 겹치는지 확인
|
||||
subscription.eventStartDate!.isBefore(DateTime(month.year, month.month + 1, 1)) &&
|
||||
subscription.eventStartDate!
|
||||
.isBefore(DateTime(month.year, month.month + 1, 1)) &&
|
||||
subscription.eventEndDate!.isAfter(month)) {
|
||||
cost = subscription.eventPrice ?? subscription.monthlyCost;
|
||||
} else {
|
||||
cost = subscription.monthlyCost;
|
||||
}
|
||||
|
||||
|
||||
// 통화 변환
|
||||
final converted = await ExchangeRateService().convertBetweenCurrencies(
|
||||
final converted =
|
||||
await ExchangeRateService().convertBetweenCurrencies(
|
||||
cost,
|
||||
subscription.currency,
|
||||
targetCurrency,
|
||||
);
|
||||
|
||||
|
||||
monthTotal += converted ?? cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isCurrentMonth) {
|
||||
debugPrint('[getMonthlyExpenseData] 현재 월(${_getMonthLabel(month, locale ?? 'en')}) 총 지출: $monthTotal $targetCurrency');
|
||||
debugPrint(
|
||||
'[getMonthlyExpenseData] 현재 월(${_getMonthLabel(month, locale ?? 'en')}) 총 지출: $monthTotal $targetCurrency');
|
||||
}
|
||||
|
||||
|
||||
monthlyData.add({
|
||||
'month': month,
|
||||
'totalExpense': monthTotal,
|
||||
'monthName': _getMonthLabel(month, locale ?? 'en'),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return monthlyData;
|
||||
}
|
||||
|
||||
@@ -409,96 +416,109 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
/// categoryId가 없는 기존 구독들에 대해 자동으로 카테고리 할당
|
||||
Future<void> _migrateCategoryIds() async {
|
||||
debugPrint('❎ CategoryId 마이그레이션 시작...');
|
||||
|
||||
|
||||
final categoryProvider = CategoryProvider();
|
||||
await categoryProvider.init();
|
||||
final categories = categoryProvider.categories;
|
||||
|
||||
|
||||
int migratedCount = 0;
|
||||
|
||||
|
||||
for (var subscription in _subscriptions) {
|
||||
if (subscription.categoryId == null) {
|
||||
final serviceName = subscription.serviceName.toLowerCase();
|
||||
String? categoryId;
|
||||
|
||||
|
||||
debugPrint('🔍 ${subscription.serviceName} 카테고리 매칭 시도...');
|
||||
|
||||
|
||||
// OTT 서비스
|
||||
if (serviceName.contains('netflix') ||
|
||||
serviceName.contains('youtube') ||
|
||||
if (serviceName.contains('netflix') ||
|
||||
serviceName.contains('youtube') ||
|
||||
serviceName.contains('disney') ||
|
||||
serviceName.contains('왓차') ||
|
||||
serviceName.contains('티빙') ||
|
||||
serviceName.contains('디즈니') ||
|
||||
serviceName.contains('넷플릭스')) {
|
||||
categoryId = categories.firstWhere(
|
||||
(cat) => cat.name == 'OTT 서비스',
|
||||
orElse: () => categories.first,
|
||||
).id;
|
||||
categoryId = categories
|
||||
.firstWhere(
|
||||
(cat) => cat.name == 'OTT 서비스',
|
||||
orElse: () => categories.first,
|
||||
)
|
||||
.id;
|
||||
}
|
||||
// 음악 서비스
|
||||
else if (serviceName.contains('spotify') ||
|
||||
serviceName.contains('apple music') ||
|
||||
serviceName.contains('멜론') ||
|
||||
serviceName.contains('지니') ||
|
||||
serviceName.contains('플로') ||
|
||||
serviceName.contains('벡스')) {
|
||||
categoryId = categories.firstWhere(
|
||||
(cat) => cat.name == 'music',
|
||||
orElse: () => categories.first,
|
||||
).id;
|
||||
else if (serviceName.contains('spotify') ||
|
||||
serviceName.contains('apple music') ||
|
||||
serviceName.contains('멜론') ||
|
||||
serviceName.contains('지니') ||
|
||||
serviceName.contains('플로') ||
|
||||
serviceName.contains('벡스')) {
|
||||
categoryId = categories
|
||||
.firstWhere(
|
||||
(cat) => cat.name == 'music',
|
||||
orElse: () => categories.first,
|
||||
)
|
||||
.id;
|
||||
}
|
||||
// AI 서비스
|
||||
else if (serviceName.contains('chatgpt') ||
|
||||
serviceName.contains('claude') ||
|
||||
serviceName.contains('midjourney') ||
|
||||
serviceName.contains('copilot')) {
|
||||
categoryId = categories.firstWhere(
|
||||
(cat) => cat.name == 'aiService',
|
||||
orElse: () => categories.first,
|
||||
).id;
|
||||
else if (serviceName.contains('chatgpt') ||
|
||||
serviceName.contains('claude') ||
|
||||
serviceName.contains('midjourney') ||
|
||||
serviceName.contains('copilot')) {
|
||||
categoryId = categories
|
||||
.firstWhere(
|
||||
(cat) => cat.name == 'aiService',
|
||||
orElse: () => categories.first,
|
||||
)
|
||||
.id;
|
||||
}
|
||||
// 프로그래밍/개발
|
||||
else if (serviceName.contains('github') ||
|
||||
serviceName.contains('intellij') ||
|
||||
serviceName.contains('webstorm') ||
|
||||
serviceName.contains('jetbrains')) {
|
||||
categoryId = categories.firstWhere(
|
||||
(cat) => cat.name == 'programming',
|
||||
orElse: () => categories.first,
|
||||
).id;
|
||||
else if (serviceName.contains('github') ||
|
||||
serviceName.contains('intellij') ||
|
||||
serviceName.contains('webstorm') ||
|
||||
serviceName.contains('jetbrains')) {
|
||||
categoryId = categories
|
||||
.firstWhere(
|
||||
(cat) => cat.name == 'programming',
|
||||
orElse: () => categories.first,
|
||||
)
|
||||
.id;
|
||||
}
|
||||
// 오피스/협업 툴
|
||||
else if (serviceName.contains('notion') ||
|
||||
serviceName.contains('microsoft') ||
|
||||
serviceName.contains('office') ||
|
||||
serviceName.contains('slack') ||
|
||||
serviceName.contains('figma') ||
|
||||
serviceName.contains('icloud') ||
|
||||
serviceName.contains('아이클라우드')) {
|
||||
categoryId = categories.firstWhere(
|
||||
(cat) => cat.name == 'collaborationOffice',
|
||||
orElse: () => categories.first,
|
||||
).id;
|
||||
else if (serviceName.contains('notion') ||
|
||||
serviceName.contains('microsoft') ||
|
||||
serviceName.contains('office') ||
|
||||
serviceName.contains('slack') ||
|
||||
serviceName.contains('figma') ||
|
||||
serviceName.contains('icloud') ||
|
||||
serviceName.contains('아이클라우드')) {
|
||||
categoryId = categories
|
||||
.firstWhere(
|
||||
(cat) => cat.name == 'collaborationOffice',
|
||||
orElse: () => categories.first,
|
||||
)
|
||||
.id;
|
||||
}
|
||||
// 기타 서비스 (기본값)
|
||||
else {
|
||||
categoryId = categories.firstWhere(
|
||||
(cat) => cat.name == 'other',
|
||||
orElse: () => categories.first,
|
||||
).id;
|
||||
categoryId = categories
|
||||
.firstWhere(
|
||||
(cat) => cat.name == 'other',
|
||||
orElse: () => categories.first,
|
||||
)
|
||||
.id;
|
||||
}
|
||||
|
||||
|
||||
if (categoryId != null) {
|
||||
subscription.categoryId = categoryId;
|
||||
await subscription.save();
|
||||
migratedCount++;
|
||||
final categoryName = categories.firstWhere((cat) => cat.id == categoryId).name;
|
||||
final categoryName =
|
||||
categories.firstWhere((cat) => cat.id == categoryId).name;
|
||||
debugPrint('✅ ${subscription.serviceName} → $categoryName');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (migratedCount > 0) {
|
||||
debugPrint('❎ 총 ${migratedCount}개의 구독에 categoryId 할당 완료');
|
||||
await refreshSubscriptions();
|
||||
|
||||
@@ -7,24 +7,24 @@ import '../theme/adaptive_theme.dart';
|
||||
class ThemeProvider extends ChangeNotifier {
|
||||
static const String _themeBoxName = 'theme_settings';
|
||||
static const String _themeKey = 'theme_settings';
|
||||
|
||||
|
||||
late Box<Map> _themeBox;
|
||||
ThemeSettings _themeSettings = const ThemeSettings();
|
||||
|
||||
|
||||
ThemeSettings get themeSettings => _themeSettings;
|
||||
|
||||
|
||||
AppThemeMode get themeMode => _themeSettings.mode;
|
||||
bool get useSystemColors => _themeSettings.useSystemColors;
|
||||
bool get largeText => _themeSettings.largeText;
|
||||
bool get reduceMotion => _themeSettings.reduceMotion;
|
||||
bool get highContrast => _themeSettings.highContrast;
|
||||
|
||||
|
||||
/// Provider 초기화
|
||||
Future<void> initialize() async {
|
||||
_themeBox = await Hive.openBox<Map>(_themeBoxName);
|
||||
await _loadThemeSettings();
|
||||
}
|
||||
|
||||
|
||||
/// 저장된 테마 설정 로드
|
||||
Future<void> _loadThemeSettings() async {
|
||||
final savedSettings = _themeBox.get(_themeKey);
|
||||
@@ -35,53 +35,53 @@ class ThemeProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 테마 설정 저장
|
||||
Future<void> _saveThemeSettings() async {
|
||||
await _themeBox.put(_themeKey, _themeSettings.toJson());
|
||||
}
|
||||
|
||||
|
||||
/// 테마 모드 변경
|
||||
Future<void> setThemeMode(AppThemeMode mode) async {
|
||||
_themeSettings = _themeSettings.copyWith(mode: mode);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 시스템 색상 사용 설정
|
||||
Future<void> setUseSystemColors(bool value) async {
|
||||
_themeSettings = _themeSettings.copyWith(useSystemColors: value);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 큰 텍스트 설정
|
||||
Future<void> setLargeText(bool value) async {
|
||||
_themeSettings = _themeSettings.copyWith(largeText: value);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 모션 감소 설정
|
||||
Future<void> setReduceMotion(bool value) async {
|
||||
_themeSettings = _themeSettings.copyWith(reduceMotion: value);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 고대비 설정
|
||||
Future<void> setHighContrast(bool value) async {
|
||||
_themeSettings = _themeSettings.copyWith(highContrast: value);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 현재 설정에 따른 테마 가져오기
|
||||
ThemeData getTheme(BuildContext context) {
|
||||
final platformBrightness = MediaQuery.of(context).platformBrightness;
|
||||
|
||||
|
||||
ThemeData baseTheme;
|
||||
|
||||
|
||||
switch (_themeSettings.mode) {
|
||||
case AppThemeMode.light:
|
||||
baseTheme = AdaptiveTheme.lightTheme;
|
||||
@@ -98,7 +98,7 @@ class ThemeProvider extends ChangeNotifier {
|
||||
: AdaptiveTheme.lightTheme;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// 접근성 설정 적용
|
||||
return AdaptiveTheme.getAccessibleTheme(
|
||||
baseTheme,
|
||||
@@ -107,11 +107,11 @@ class ThemeProvider extends ChangeNotifier {
|
||||
highContrast: _themeSettings.highContrast,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// 현재 테마가 다크 모드인지 확인
|
||||
bool isDarkMode(BuildContext context) {
|
||||
final platformBrightness = MediaQuery.of(context).platformBrightness;
|
||||
|
||||
|
||||
switch (_themeSettings.mode) {
|
||||
case AppThemeMode.light:
|
||||
return false;
|
||||
@@ -122,7 +122,7 @@ class ThemeProvider extends ChangeNotifier {
|
||||
return platformBrightness == Brightness.dark;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 테마 토글 (라이트/다크)
|
||||
Future<void> toggleTheme() async {
|
||||
if (_themeSettings.mode == AppThemeMode.light) {
|
||||
@@ -137,7 +137,7 @@ class ThemeProvider extends ChangeNotifier {
|
||||
class AnimatedThemeBuilder extends StatelessWidget {
|
||||
final Widget Function(BuildContext, ThemeData) builder;
|
||||
final Duration duration;
|
||||
|
||||
|
||||
const AnimatedThemeBuilder({
|
||||
super.key,
|
||||
required this.builder,
|
||||
@@ -148,7 +148,7 @@ class AnimatedThemeBuilder extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final themeProvider = context.watch<ThemeProvider>();
|
||||
final theme = themeProvider.getTheme(context);
|
||||
|
||||
|
||||
return AnimatedTheme(
|
||||
data: theme,
|
||||
duration: duration,
|
||||
@@ -164,7 +164,7 @@ class ThemedColor extends StatelessWidget {
|
||||
final Color lightColor;
|
||||
final Color darkColor;
|
||||
final Widget child;
|
||||
|
||||
|
||||
const ThemedColor({
|
||||
super.key,
|
||||
required this.lightColor,
|
||||
@@ -175,7 +175,7 @@ class ThemedColor extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = context.read<ThemeProvider>().isDarkMode(context);
|
||||
|
||||
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
primaryColor: isDark ? darkColor : lightColor,
|
||||
@@ -183,4 +183,4 @@ class ThemedColor extends StatelessWidget {
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user