- Extract business logic from screens into dedicated controllers - Split large screen files into smaller, reusable widget components - Add controllers for AddSubscriptionScreen and DetailScreen - Create modular widgets for subscription and detail features - Improve code organization and maintainability - Remove duplicated code and improve reusability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
153 lines
5.2 KiB
Dart
153 lines
5.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../providers/subscription_provider.dart';
|
|
import '../providers/category_provider.dart';
|
|
import '../utils/subscription_category_helper.dart';
|
|
import '../widgets/native_ad_widget.dart';
|
|
import '../widgets/main_summary_card.dart';
|
|
import '../widgets/subscription_list_widget.dart';
|
|
import '../widgets/empty_state_widget.dart';
|
|
import '../widgets/glassmorphic_app_bar.dart';
|
|
import '../theme/app_colors.dart';
|
|
|
|
class HomeContent extends StatelessWidget {
|
|
final AnimationController fadeController;
|
|
final AnimationController rotateController;
|
|
final AnimationController slideController;
|
|
final AnimationController pulseController;
|
|
final AnimationController waveController;
|
|
final ScrollController scrollController;
|
|
final VoidCallback onAddPressed;
|
|
|
|
const HomeContent({
|
|
super.key,
|
|
required this.fadeController,
|
|
required this.rotateController,
|
|
required this.slideController,
|
|
required this.pulseController,
|
|
required this.waveController,
|
|
required this.scrollController,
|
|
required this.onAddPressed,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final provider = context.watch<SubscriptionProvider>();
|
|
|
|
if (provider.isLoading) {
|
|
return const Center(
|
|
child: CircularProgressIndicator(
|
|
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFF3B82F6)),
|
|
),
|
|
);
|
|
}
|
|
|
|
if (provider.subscriptions.isEmpty) {
|
|
return EmptyStateWidget(
|
|
fadeController: fadeController,
|
|
rotateController: rotateController,
|
|
slideController: slideController,
|
|
onAddPressed: onAddPressed,
|
|
);
|
|
}
|
|
|
|
// 카테고리별 구독 구분
|
|
final categoryProvider = Provider.of<CategoryProvider>(context, listen: false);
|
|
final categorizedSubscriptions = SubscriptionCategoryHelper.categorizeSubscriptions(
|
|
provider.subscriptions,
|
|
categoryProvider,
|
|
);
|
|
|
|
return RefreshIndicator(
|
|
onRefresh: () async {
|
|
await provider.refreshSubscriptions();
|
|
},
|
|
color: const Color(0xFF3B82F6),
|
|
child: CustomScrollView(
|
|
controller: scrollController,
|
|
physics: const BouncingScrollPhysics(),
|
|
slivers: [
|
|
const GlassmorphicSliverAppBar(
|
|
title: '홈',
|
|
pinned: true,
|
|
expandedHeight: kToolbarHeight,
|
|
),
|
|
const SliverToBoxAdapter(
|
|
child: NativeAdWidget(key: ValueKey('home_ad')),
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: SlideTransition(
|
|
position: Tween<Offset>(
|
|
begin: const Offset(0, 0.2),
|
|
end: Offset.zero,
|
|
).animate(CurvedAnimation(
|
|
parent: slideController, curve: Curves.easeOutCubic)),
|
|
child: MainScreenSummaryCard(
|
|
provider: provider,
|
|
fadeController: fadeController,
|
|
pulseController: pulseController,
|
|
waveController: waveController,
|
|
slideController: slideController,
|
|
),
|
|
),
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(20, 24, 20, 4),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
SlideTransition(
|
|
position: Tween<Offset>(
|
|
begin: const Offset(-0.2, 0),
|
|
end: Offset.zero,
|
|
).animate(CurvedAnimation(
|
|
parent: slideController, curve: Curves.easeOutCubic)),
|
|
child: Text(
|
|
'나의 구독 서비스',
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
),
|
|
),
|
|
SlideTransition(
|
|
position: Tween<Offset>(
|
|
begin: const Offset(0.2, 0),
|
|
end: Offset.zero,
|
|
).animate(CurvedAnimation(
|
|
parent: slideController, curve: Curves.easeOutCubic)),
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
'${provider.subscriptions.length}개',
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.primaryColor,
|
|
),
|
|
),
|
|
const SizedBox(width: 4),
|
|
const Icon(
|
|
Icons.arrow_forward_ios,
|
|
size: 14,
|
|
color: AppColors.primaryColor,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SubscriptionListWidget(
|
|
categorizedSubscriptions: categorizedSubscriptions,
|
|
fadeController: fadeController,
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: SizedBox(
|
|
height: 100 + MediaQuery.of(context).padding.bottom,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |