prodycrts
This commit is contained in:
@@ -6,6 +6,8 @@ library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:worker/core/router/app_router.dart';
|
||||
import 'package:worker/core/theme/colors.dart';
|
||||
import 'package:worker/features/home/presentation/providers/member_card_provider.dart';
|
||||
import 'package:worker/features/home/presentation/providers/promotions_provider.dart';
|
||||
@@ -37,224 +39,223 @@ class HomePage extends ConsumerWidget {
|
||||
final promotionsAsync = ref.watch(promotionsProvider);
|
||||
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true, // allow body to render behind status bar
|
||||
|
||||
backgroundColor: AppColors.grey50,
|
||||
body: MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true,
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
// Refresh both member card and promotions
|
||||
await Future.wait<void>([
|
||||
ref.read(memberCardProvider.notifier).refresh(),
|
||||
ref.read(promotionsProvider.notifier).refresh(),
|
||||
]);
|
||||
},
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
// App Bar
|
||||
// SliverAppBar(
|
||||
// floating: true,
|
||||
// snap: true,
|
||||
// backgroundColor: AppColors.primaryBlue,
|
||||
// title: Text(l10n.home),
|
||||
// centerTitle: true,
|
||||
// ),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
// Refresh both member card and promotions
|
||||
await Future.wait<void>([
|
||||
ref.read(memberCardProvider.notifier).refresh(),
|
||||
ref.read(promotionsProvider.notifier).refresh(),
|
||||
]);
|
||||
},
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
// Add top padding for status bar
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
||||
),
|
||||
|
||||
// Member Card Section
|
||||
SliverToBoxAdapter(
|
||||
child: memberCardAsync.when(
|
||||
data: (memberCard) => MemberCardWidget(memberCard: memberCard),
|
||||
loading: () => Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.grey100,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
// Member Card Section
|
||||
SliverToBoxAdapter(
|
||||
child: memberCardAsync.when(
|
||||
data: (memberCard) => MemberCardWidget(memberCard: memberCard),
|
||||
loading: () => Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.grey100,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
error: (error, stack) => Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.danger.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
error: (error, stack) => Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.danger.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
color: AppColors.danger,
|
||||
size: 48,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.error,
|
||||
style: const TextStyle(
|
||||
color: AppColors.danger,
|
||||
size: 48,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.error,
|
||||
style: const TextStyle(
|
||||
color: AppColors.danger,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
error.toString(),
|
||||
style: const TextStyle(
|
||||
color: AppColors.grey500,
|
||||
fontSize: 12,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
error.toString(),
|
||||
style: const TextStyle(
|
||||
color: AppColors.grey500,
|
||||
fontSize: 12,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Promotions Section
|
||||
SliverToBoxAdapter(
|
||||
child: promotionsAsync.when(
|
||||
data: (promotions) => promotions.isNotEmpty
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: PromotionSlider(
|
||||
promotions: promotions,
|
||||
onPromotionTap: (promotion) {
|
||||
// TODO: Navigate to promotion details
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('${l10n.viewDetails}: ${promotion.title}'),
|
||||
// Promotions Section
|
||||
SliverToBoxAdapter(
|
||||
child: promotionsAsync.when(
|
||||
data: (promotions) => promotions.isNotEmpty
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: PromotionSlider(
|
||||
promotions: promotions,
|
||||
onPromotionTap: (promotion) {
|
||||
// TODO: Navigate to promotion details
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'${l10n.viewDetails}: ${promotion.title}',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
loading: () => const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
loading: () => const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
error: (error, stack) => const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
|
||||
// Quick Action Sections
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
// Products & Cart Section
|
||||
QuickActionSection(
|
||||
title: '${l10n.products} & ${l10n.cart}',
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.grid_view,
|
||||
label: l10n.products,
|
||||
onTap: () => context.go(RouteNames.products),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.shopping_cart,
|
||||
label: l10n.cart,
|
||||
badge: '3',
|
||||
onTap: () => _showComingSoon(context, l10n.cart, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.favorite,
|
||||
label: 'Yêu thích',
|
||||
onTap: () =>
|
||||
_showComingSoon(context, 'Yêu thích', l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
error: (error, stack) => const SizedBox.shrink(),
|
||||
),
|
||||
|
||||
// Loyalty Section
|
||||
QuickActionSection(
|
||||
title: l10n.loyalty,
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.card_giftcard,
|
||||
label: l10n.redeemReward,
|
||||
onTap: () =>
|
||||
_showComingSoon(context, l10n.redeemReward, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.history,
|
||||
label: l10n.pointsHistory,
|
||||
onTap: () =>
|
||||
_showComingSoon(context, l10n.pointsHistory, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.person_add,
|
||||
label: l10n.referral,
|
||||
onTap: () =>
|
||||
_showComingSoon(context, l10n.referral, l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Quote Requests Section
|
||||
QuickActionSection(
|
||||
title: l10n.quotes,
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.description,
|
||||
label: l10n.quotes,
|
||||
onTap: () =>
|
||||
_showComingSoon(context, l10n.quotes, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.receipt_long,
|
||||
label: l10n.quotes,
|
||||
onTap: () =>
|
||||
_showComingSoon(context, l10n.quotes, l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Orders & Payments Section
|
||||
QuickActionSection(
|
||||
title: '${l10n.orders} & ${l10n.payments}',
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.inventory_2,
|
||||
label: l10n.orders,
|
||||
onTap: () =>
|
||||
_showComingSoon(context, l10n.orders, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.payment,
|
||||
label: l10n.payments,
|
||||
onTap: () =>
|
||||
_showComingSoon(context, l10n.payments, l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Sample Houses & News Section
|
||||
QuickActionSection(
|
||||
title: l10n.projects,
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.home_work,
|
||||
label: 'Nhà mẫu',
|
||||
onTap: () => _showComingSoon(context, 'Nhà mẫu', l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.business,
|
||||
label: l10n.projects,
|
||||
onTap: () =>
|
||||
_showComingSoon(context, l10n.projects, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.article,
|
||||
label: 'Tin tức',
|
||||
onTap: () => _showComingSoon(context, 'Tin tức', l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Bottom Padding (for FAB clearance)
|
||||
const SizedBox(height: 80),
|
||||
],
|
||||
),
|
||||
|
||||
// Quick Action Sections
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
// Products & Cart Section
|
||||
QuickActionSection(
|
||||
title: '${l10n.products} & ${l10n.cart}',
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.grid_view,
|
||||
label: l10n.products,
|
||||
onTap: () => _showComingSoon(context, l10n.products, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.shopping_cart,
|
||||
label: l10n.cart,
|
||||
badge: '3',
|
||||
onTap: () => _showComingSoon(context, l10n.cart, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.favorite,
|
||||
label: 'Yêu thích',
|
||||
onTap: () => _showComingSoon(context, 'Yêu thích', l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Loyalty Section
|
||||
QuickActionSection(
|
||||
title: l10n.loyalty,
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.card_giftcard,
|
||||
label: l10n.redeemReward,
|
||||
onTap: () => _showComingSoon(context, l10n.redeemReward, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.history,
|
||||
label: l10n.pointsHistory,
|
||||
onTap: () => _showComingSoon(context, l10n.pointsHistory, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.person_add,
|
||||
label: l10n.referral,
|
||||
onTap: () => _showComingSoon(context, l10n.referral, l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Quote Requests Section
|
||||
QuickActionSection(
|
||||
title: l10n.quotes,
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.description,
|
||||
label: l10n.quotes,
|
||||
onTap: () => _showComingSoon(context, l10n.quotes, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.receipt_long,
|
||||
label: l10n.quotes,
|
||||
onTap: () => _showComingSoon(context, l10n.quotes, l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Orders & Payments Section
|
||||
QuickActionSection(
|
||||
title: '${l10n.orders} & ${l10n.payments}',
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.inventory_2,
|
||||
label: l10n.orders,
|
||||
onTap: () => _showComingSoon(context, l10n.orders, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.payment,
|
||||
label: l10n.payments,
|
||||
onTap: () => _showComingSoon(context, l10n.payments, l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Sample Houses & News Section
|
||||
QuickActionSection(
|
||||
title: l10n.projects,
|
||||
actions: [
|
||||
QuickAction(
|
||||
icon: Icons.home_work,
|
||||
label: 'Nhà mẫu',
|
||||
onTap: () => _showComingSoon(context, 'Nhà mẫu', l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.business,
|
||||
label: l10n.projects,
|
||||
onTap: () => _showComingSoon(context, l10n.projects, l10n),
|
||||
),
|
||||
QuickAction(
|
||||
icon: Icons.article,
|
||||
label: 'Tin tức',
|
||||
onTap: () => _showComingSoon(context, 'Tin tức', l10n),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Bottom Padding (for FAB clearance)
|
||||
const SizedBox(height: 80),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -310,7 +311,11 @@ class HomePage extends ConsumerWidget {
|
||||
}
|
||||
|
||||
/// Show coming soon message
|
||||
void _showComingSoon(BuildContext context, String feature, AppLocalizations l10n) {
|
||||
void _showComingSoon(
|
||||
BuildContext context,
|
||||
String feature,
|
||||
AppLocalizations l10n,
|
||||
) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('$feature - ${l10n.comingSoon}'),
|
||||
|
||||
Reference in New Issue
Block a user