Files
submanager/lib/models/subscription_model.dart
JiWoong Sul 4731288622 Major UI/UX and architecture improvements
- Implemented new navigation system with NavigationProvider and route management
- Added adaptive theme system with ThemeProvider for better theme handling
- Introduced glassmorphism design elements (app bars, scaffolds, cards)
- Added advanced animations (spring animations, page transitions, staggered lists)
- Implemented performance optimizations (memory manager, lazy loading)
- Refactored Analysis screen into modular components
- Added floating navigation bar with haptic feedback
- Improved subscription cards with swipe actions
- Enhanced skeleton loading with better animations
- Added cached network image support
- Improved overall app architecture and code organization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-10 18:36:57 +09:00

105 lines
2.4 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;
}
// 원래 가격 (이벤트와 관계없이 항상 정상 가격)
double get originalPrice => monthlyCost;
}
// Hive TypeAdapter 생성을 위한 명령어
// flutter pub run build_runner build