/// Main Scaffold with Bottom Navigation /// /// Root navigation wrapper that manages the bottom navigation bar /// and displays different pages based on the selected tab. library; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:worker/core/theme/colors.dart'; import 'package:worker/features/account/presentation/pages/account_page.dart'; import 'package:worker/features/home/presentation/pages/home_page.dart'; import 'package:worker/features/loyalty/presentation/pages/loyalty_page.dart'; import 'package:worker/features/main/presentation/providers/current_page_provider.dart'; import 'package:worker/features/news/presentation/pages/news_list_page.dart'; import 'package:worker/features/notifications/presentation/pages/notifications_page.dart'; import 'package:worker/features/promotions/presentation/pages/promotions_page.dart'; /// Main Scaffold Page /// /// Manages bottom navigation and page switching for: /// - Home (index 0) /// - Loyalty (index 1) /// - News (index 2) /// - Notifications (index 3) /// - Account (index 4) class MainScaffold extends ConsumerWidget { const MainScaffold({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { final currentIndex = ref.watch(currentPageIndexProvider); // Define pages final pages = [ const HomePage(), const LoyaltyPage(), // Loyalty const NewsListPage(), const NotificationsPage(), // Notifications const AccountPage(), // Account ]; return Scaffold( body: IndexedStack( index: currentIndex, children: pages, ), floatingActionButton: currentIndex == 0 ? Padding( padding: const EdgeInsets.only(bottom: 20), child: FloatingActionButton( onPressed: () { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Chat - Đang phát triển'), duration: Duration(seconds: 1), ), ); }, backgroundColor: AppColors.accentCyan, elevation: 8, child: const Icon(Icons.chat_bubble, size: 24, color: Colors.white), ), ) : null, bottomNavigationBar: Container( decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.05), blurRadius: 10, offset: const Offset(0, -2), ), ], ), child: SafeArea( child: SizedBox( height: 70, child: BottomNavigationBar( type: BottomNavigationBarType.fixed, backgroundColor: Colors.white, selectedItemColor: AppColors.primaryBlue, unselectedItemColor: const Color(0xFF666666), selectedFontSize: 11, unselectedFontSize: 11, iconSize: 24, currentIndex: currentIndex, elevation: 0, items: [ const BottomNavigationBarItem( icon: Icon(Icons.home), label: 'Trang chủ', ), const BottomNavigationBarItem( icon: Icon(Icons.loyalty), label: 'Hội viên', ), const BottomNavigationBarItem( icon: Icon(Icons.local_offer), label: 'Tin tức', ), BottomNavigationBarItem( icon: Stack( clipBehavior: Clip.none, children: [ const Icon(Icons.notifications), Positioned( top: -4, right: -4, child: Container( padding: const EdgeInsets.symmetric( horizontal: 6, vertical: 2, ), decoration: BoxDecoration( color: AppColors.danger, borderRadius: BorderRadius.circular(12), ), constraints: const BoxConstraints( minWidth: 20, minHeight: 20, ), child: const Text( '5', style: TextStyle( color: Colors.white, fontSize: 11, fontWeight: FontWeight.w700, ), textAlign: TextAlign.center, ), ), ), ], ), label: 'Thông báo', ), const BottomNavigationBarItem( icon: Icon(Icons.account_circle), label: 'Cài đặt', ), ], onTap: (index) { ref.read(currentPageIndexProvider.notifier).setIndex(index); }, ), ), ), ), ); } }