- @doc/color.md 가이드라인에 따른 색상 시스템 전면 개편 - 딥 블루(#2563EB), 스카이 블루(#60A5FA) 메인 컬러로 변경 - 모든 화면과 위젯에 글래스모피즘 효과 일관성 있게 적용 - darkNavy, navyGray 등 새로운 텍스트 색상 체계 도입 - 공통 스낵바 및 다이얼로그 컴포넌트 추가 - Claude AI 프로젝트 컨텍스트 파일(CLAUDE.md) 추가 영향받은 컴포넌트: - 10개 스크린 (main, settings, detail, splash 등) - 30개 이상 위젯 (buttons, cards, forms 등) - 테마 시스템 (AppColors, AppTheme) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
161 lines
6.6 KiB
Dart
161 lines
6.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../models/subscription_model.dart';
|
|
import '../widgets/category_header_widget.dart';
|
|
import '../widgets/swipeable_subscription_card.dart';
|
|
import '../widgets/staggered_list_animation.dart';
|
|
import '../widgets/app_navigator.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../providers/subscription_provider.dart';
|
|
import './dialogs/delete_confirmation_dialog.dart';
|
|
import './common/snackbar/app_snackbar.dart';
|
|
|
|
/// 카테고리별로 구독 목록을 표시하는 위젯
|
|
class SubscriptionListWidget extends StatelessWidget {
|
|
final Map<String, List<SubscriptionModel>> categorizedSubscriptions;
|
|
final AnimationController fadeController;
|
|
|
|
const SubscriptionListWidget({
|
|
Key? key,
|
|
required this.categorizedSubscriptions,
|
|
required this.fadeController,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 카테고리 키 목록 (정렬된)
|
|
final categories = categorizedSubscriptions.keys.toList();
|
|
|
|
return SliverList(
|
|
delegate: SliverChildBuilderDelegate(
|
|
(context, index) {
|
|
final category = categories[index];
|
|
final subscriptions = categorizedSubscriptions[category]!;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: 8.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// 카테고리 헤더
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(20, 16, 20, 8),
|
|
child: CategoryHeaderWidget(
|
|
categoryName: category,
|
|
subscriptionCount: subscriptions.length,
|
|
totalCost: subscriptions.fold(
|
|
0.0,
|
|
(sum, sub) => sum + sub.monthlyCost,
|
|
),
|
|
),
|
|
),
|
|
// 카테고리별 구독 목록
|
|
FadeTransition(
|
|
opacity: Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
CurvedAnimation(
|
|
parent: fadeController, curve: Curves.easeIn)),
|
|
child: ListView.builder(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
itemCount: subscriptions.length,
|
|
itemBuilder: (context, subIndex) {
|
|
// 각 구독의 지연값 계산 (순차적으로 나타나도록)
|
|
final delay = 0.05 * subIndex;
|
|
const animationBegin = 0.2;
|
|
const animationEnd = 1.0;
|
|
final intervalStart = delay;
|
|
final intervalEnd = intervalStart + 0.4;
|
|
|
|
// 간격 계산 (0.0~1.0 사이의 값으로 정규화)
|
|
final intervalStartNormalized =
|
|
intervalStart.clamp(0.0, 0.9);
|
|
final intervalEndNormalized = intervalEnd.clamp(0.1, 1.0);
|
|
|
|
return FadeTransition(
|
|
opacity: Tween<double>(
|
|
begin: animationBegin, end: animationEnd)
|
|
.animate(CurvedAnimation(
|
|
parent: fadeController,
|
|
curve: Interval(intervalStartNormalized,
|
|
intervalEndNormalized,
|
|
curve: Curves.easeOut))),
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(bottom: 12.0),
|
|
child: StaggeredAnimationItem(
|
|
index: subIndex,
|
|
delay: const Duration(milliseconds: 50),
|
|
child: SwipeableSubscriptionCard(
|
|
subscription: subscriptions[subIndex],
|
|
onTap: () {
|
|
AppNavigator.toDetail(context, subscriptions[subIndex]);
|
|
},
|
|
onEdit: () {
|
|
// 편집 화면으로 이동
|
|
AppNavigator.toDetail(context, subscriptions[subIndex]);
|
|
},
|
|
onDelete: () async {
|
|
// 삭제 확인 다이얼로그 표시
|
|
final shouldDelete = await DeleteConfirmationDialog.show(
|
|
context: context,
|
|
serviceName: subscriptions[subIndex].serviceName,
|
|
);
|
|
|
|
if (shouldDelete && context.mounted) {
|
|
// 사용자가 확인한 경우에만 삭제 진행
|
|
final provider = Provider.of<SubscriptionProvider>(
|
|
context,
|
|
listen: false,
|
|
);
|
|
await provider.deleteSubscription(
|
|
subscriptions[subIndex].id,
|
|
);
|
|
|
|
if (context.mounted) {
|
|
AppSnackBar.showSuccess(
|
|
context: context,
|
|
message: '${subscriptions[subIndex].serviceName} 구독이 삭제되었습니다.',
|
|
icon: Icons.delete_forever_rounded,
|
|
);
|
|
}
|
|
}
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
childCount: categories.length,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 여러 Sliver 위젯을 하나의 위젯으로 감싸는 도우미 위젯
|
|
class MultiSliver extends StatelessWidget {
|
|
final List<Widget> children;
|
|
|
|
const MultiSliver({
|
|
Key? key,
|
|
required this.children,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SliverList(
|
|
delegate: SliverChildBuilderDelegate(
|
|
(context, index) {
|
|
if (index >= children.length) return null;
|
|
return children[index];
|
|
},
|
|
childCount: children.length,
|
|
),
|
|
);
|
|
}
|
|
}
|