주요 구현 완료 기능: - 구독 관리 (추가/편집/삭제/카테고리 분류) - 이벤트 할인 시스템 (기본값 자동 설정) - SMS 자동 스캔 및 구독 정보 추출 - 알림 시스템 (타임존 처리 안정화) - 환율 변환 지원 (KRW/USD) - 반응형 UI 및 애니메이션 - 다국어 지원 (한국어/영어) 버그 수정: - NotificationService tz.local 초기화 오류 해결 - MainScreenSummaryCard 레이아웃 오버플로우 수정 - 구독 추가 시 LateInitializationError 완전 해결 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
102 lines
2.3 KiB
Dart
102 lines
2.3 KiB
Dart
import 'package:hive_flutter/hive_flutter.dart';
|
|
|
|
part 'subscription_model.g.dart';
|
|
|
|
@HiveType(typeId: 0)
|
|
class SubscriptionModel extends HiveObject {
|
|
@HiveField(0)
|
|
final String id;
|
|
|
|
@HiveField(1)
|
|
String serviceName;
|
|
|
|
@HiveField(2)
|
|
double monthlyCost;
|
|
|
|
@HiveField(3)
|
|
String billingCycle; // '월간', '연간', '주간' 등
|
|
|
|
@HiveField(4)
|
|
DateTime nextBillingDate;
|
|
|
|
@HiveField(5)
|
|
bool isAutoDetected; // SMS로 추가된 경우 true
|
|
|
|
@HiveField(6)
|
|
String? categoryId;
|
|
|
|
@HiveField(7)
|
|
String? websiteUrl; // 홈페이지 URL
|
|
|
|
@HiveField(8)
|
|
int repeatCount; // 반복 결제 횟수
|
|
|
|
@HiveField(9)
|
|
DateTime? lastPaymentDate; // 마지막 결제일
|
|
|
|
@HiveField(10)
|
|
String currency; // 통화 단위: 'KRW' 또는 'USD'
|
|
|
|
@HiveField(11)
|
|
bool isEventActive; // 이벤트 활성화 여부
|
|
|
|
@HiveField(12)
|
|
DateTime? eventStartDate; // 이벤트 시작일
|
|
|
|
@HiveField(13)
|
|
DateTime? eventEndDate; // 이벤트 종료일
|
|
|
|
@HiveField(14)
|
|
double? eventPrice; // 이벤트 기간 중 가격
|
|
|
|
SubscriptionModel({
|
|
required this.id,
|
|
required this.serviceName,
|
|
required this.monthlyCost,
|
|
required this.billingCycle,
|
|
required this.nextBillingDate,
|
|
this.isAutoDetected = false,
|
|
this.categoryId,
|
|
this.websiteUrl,
|
|
this.repeatCount = 1,
|
|
this.lastPaymentDate,
|
|
this.currency = 'KRW', // 기본값은 KRW
|
|
this.isEventActive = false, // 기본값은 false
|
|
this.eventStartDate,
|
|
this.eventEndDate,
|
|
this.eventPrice,
|
|
});
|
|
|
|
// 주기적 결제 여부 확인
|
|
bool get isRecurring => repeatCount > 1;
|
|
|
|
// 현재 이벤트 기간인지 확인
|
|
bool get isCurrentlyInEvent {
|
|
if (!isEventActive || eventStartDate == null || eventEndDate == null) {
|
|
return false;
|
|
}
|
|
|
|
final now = DateTime.now();
|
|
return now.isAfter(eventStartDate!) && now.isBefore(eventEndDate!);
|
|
}
|
|
|
|
// 현재 적용되는 가격 (이벤트 또는 정상 가격)
|
|
double get currentPrice {
|
|
if (isCurrentlyInEvent && eventPrice != null) {
|
|
return eventPrice!;
|
|
}
|
|
return monthlyCost;
|
|
}
|
|
|
|
// 이벤트로 인한 절약액
|
|
double get eventSavings {
|
|
if (isCurrentlyInEvent && eventPrice != null) {
|
|
return monthlyCost - eventPrice!;
|
|
}
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
// Hive TypeAdapter 생성을 위한 명령어
|
|
// flutter pub run build_runner build
|