feat: 알림 설정 개선 및 USD 환율 자동 적용
- 알림 권한 첫 부여 시 기본 설정 자동 적용 (2일전, 반복 알림 활성화) - 반복 알림 설명 문구를 설정 상태에 따라 동적으로 변경 - USD 통화 구독에 대한 환율 자동 적용 기능 추가 - 설정 화면 텍스트 색상을 어두운 색상으로 변경하여 가독성 향상 - 광고 위젯 레이아웃 및 화면 간격 조정 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ class NotificationProvider extends ChangeNotifier {
|
||||
static const String _reminderHourKey = 'reminder_hour';
|
||||
static const String _reminderMinuteKey = 'reminder_minute';
|
||||
static const String _dailyReminderKey = 'daily_reminder_enabled';
|
||||
static const String _firstPermissionGrantedKey = 'first_permission_granted';
|
||||
|
||||
bool _isEnabled = false;
|
||||
bool _isPaymentEnabled = true;
|
||||
@@ -85,6 +86,12 @@ class NotificationProvider extends ChangeNotifier {
|
||||
try {
|
||||
_isEnabled = value;
|
||||
await NotificationService.setNotificationEnabled(value);
|
||||
|
||||
// 첫 권한 부여 시 기본 설정 적용
|
||||
if (value) {
|
||||
await initializeDefaultSettingsOnFirstPermission();
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
debugPrint('알림 활성화 설정 중 오류 발생: $e');
|
||||
@@ -259,4 +266,22 @@ class NotificationProvider extends ChangeNotifier {
|
||||
// 오류가 발생해도 앱 동작에 영향을 주지 않도록 처리
|
||||
}
|
||||
}
|
||||
|
||||
// 첫 권한 부여 시 기본 설정 초기화
|
||||
Future<void> initializeDefaultSettingsOnFirstPermission() async {
|
||||
try {
|
||||
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');
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('기본 설정 초기화 중 오류 발생: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:hive/hive.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import '../models/subscription_model.dart';
|
||||
import '../services/notification_service.dart';
|
||||
import '../services/exchange_rate_service.dart';
|
||||
import 'category_provider.dart';
|
||||
|
||||
class SubscriptionProvider extends ChangeNotifier {
|
||||
@@ -15,9 +16,19 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
double get totalMonthlyExpense {
|
||||
final exchangeRateService = ExchangeRateService();
|
||||
final rate = exchangeRateService.cachedUsdToKrwRate ??
|
||||
ExchangeRateService.DEFAULT_USD_TO_KRW_RATE;
|
||||
|
||||
return _subscriptions.fold(
|
||||
0.0,
|
||||
(sum, subscription) => sum + subscription.currentPrice, // 이벤트 가격 반영
|
||||
(sum, subscription) {
|
||||
final price = subscription.currentPrice;
|
||||
if (subscription.currency == 'USD') {
|
||||
return sum + (price * rate);
|
||||
}
|
||||
return sum + price;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,6 +55,9 @@ class SubscriptionProvider extends ChangeNotifier {
|
||||
_isLoading = true;
|
||||
notifyListeners();
|
||||
|
||||
// 환율 정보 미리 로드
|
||||
await ExchangeRateService().getUsdToKrwRate();
|
||||
|
||||
_subscriptionBox = await Hive.openBox<SubscriptionModel>('subscriptions');
|
||||
await refreshSubscriptions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user