/// Account Page /// /// Displays user account information and settings menu. /// Features: /// - User profile card with avatar, name, role, tier, and phone /// - Account menu section (personal info, orders, addresses, etc.) /// - Support section (contact, FAQ, about) /// - Logout button library; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:worker/core/constants/ui_constants.dart'; import 'package:worker/core/router/app_router.dart'; import 'package:worker/core/theme/colors.dart'; import 'package:worker/features/account/presentation/widgets/account_menu_item.dart'; /// Account Page /// /// Main account/settings page accessible from the bottom navigation bar. class AccountPage extends StatelessWidget { const AccountPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color(0xFFF4F6F8), body: SafeArea( child: SingleChildScrollView( child: Column( spacing: AppSpacing.md, children: [ // Simple Header _buildHeader(), // User Profile Card _buildProfileCard(context), // Account Menu Section _buildAccountMenu(context), // Support Section _buildSupportSection(context), // Logout Button _buildLogoutButton(context), const SizedBox(height: AppSpacing.lg), ], ), ), ), ); } /// Build simple header with title Widget _buildHeader() { return Container( width: double.infinity, padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.05), blurRadius: 8, offset: const Offset(0, 2), ), ], ), child: const Text( 'Tài khoản', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Color(0xFF212121), ), ), ); } /// Build user profile card with avatar and info Widget _buildProfileCard(BuildContext context) { return Container( margin: const EdgeInsets.symmetric(horizontal: AppSpacing.md), padding: const EdgeInsets.all(AppSpacing.md), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(AppRadius.card), boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.05), blurRadius: 8, offset: const Offset(0, 2), ), ], ), child: Row( children: [ // Avatar with gradient background Container( width: 80, height: 80, decoration: const BoxDecoration( shape: BoxShape.circle, gradient: LinearGradient( colors: [Color(0xFF005B9A), Color(0xFF38B6FF)], begin: Alignment.topLeft, end: Alignment.bottomRight, ), ), child: const Center( child: Text( 'LQ', style: TextStyle( color: Colors.white, fontSize: 32, fontWeight: FontWeight.w700, ), ), ), ), const SizedBox(width: AppSpacing.md), // User info Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'La Nguyen Quynh', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: AppColors.grey900, ), ), const SizedBox(height: 4), const Text( 'Kiến trúc sư · Hạng Diamond', style: TextStyle( fontSize: 13, color: AppColors.grey500, ), ), const SizedBox(height: 4), const Text( '0983 441 099', style: TextStyle( fontSize: 13, color: AppColors.primaryBlue, ), ), ], ), ), ], ), ); } /// Build account menu section Widget _buildAccountMenu(BuildContext context) { return Container( margin: const EdgeInsets.symmetric(horizontal: AppSpacing.md), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(AppRadius.card), boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.05), blurRadius: 8, offset: const Offset(0, 2), ), ], ), child: Column( children: [ AccountMenuItem( icon: Icons.edit, title: 'Thông tin cá nhân', subtitle: 'Cập nhật thông tin tài khoản', onTap: () { _showComingSoon(context); }, ), AccountMenuItem( icon: Icons.history, title: 'Lịch sử đơn hàng', subtitle: 'Xem các đơn hàng đã đặt', onTap: () { context.push(RouteNames.orders); }, ), AccountMenuItem( icon: Icons.location_on, title: 'Địa chỉ đã lưu', subtitle: 'Quản lý địa chỉ giao hàng', onTap: () { _showComingSoon(context); }, ), AccountMenuItem( icon: Icons.notifications, title: 'Cài đặt thông báo', subtitle: 'Quản lý thông báo đẩy', onTap: () { _showComingSoon(context); }, ), AccountMenuItem( icon: Icons.lock, title: 'Đổi mật khẩu', subtitle: 'Cập nhật mật khẩu mới', onTap: () { _showComingSoon(context); }, ), AccountMenuItem( icon: Icons.language, title: 'Ngôn ngữ', subtitle: 'Tiếng Việt', onTap: () { _showComingSoon(context); }, ), ], ), ); } /// Build support section Widget _buildSupportSection(BuildContext context) { return Container( margin: const EdgeInsets.symmetric(horizontal: AppSpacing.md), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(AppRadius.card), boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.05), blurRadius: 8, offset: const Offset(0, 2), ), ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Section title Padding( padding: const EdgeInsets.fromLTRB( AppSpacing.md, AppSpacing.md, AppSpacing.md, AppSpacing.sm, ), child: const Text( 'Hỗ trợ', style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: AppColors.grey900, ), ), ), // Support menu items AccountMenuItem( icon: Icons.headset_mic, title: 'Liên hệ hỗ trợ', subtitle: 'Hotline: 1900 1234', trailing: const Icon( Icons.phone, size: 20, color: AppColors.grey500, ), onTap: () { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Hotline: 1900 1234'), duration: Duration(seconds: 2), ), ); }, ), AccountMenuItem( icon: Icons.help_outline, title: 'Câu hỏi thường gặp', onTap: () { _showComingSoon(context); }, ), AccountMenuItem( icon: Icons.info_outline, title: 'Về ứng dụng', subtitle: 'Phiên bản 1.0.0', onTap: () { _showAboutDialog(context); }, ), ], ), ); } /// Build logout button Widget _buildLogoutButton(BuildContext context) { return Container( margin: const EdgeInsets.symmetric(horizontal: AppSpacing.md), width: double.infinity, child: OutlinedButton.icon( onPressed: () { _showLogoutConfirmation(context); }, icon: const Icon(Icons.logout), label: const Text('Đăng xuất'), style: OutlinedButton.styleFrom( foregroundColor: AppColors.danger, side: const BorderSide(color: AppColors.danger, width: 1.5), padding: const EdgeInsets.symmetric(vertical: 14), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppRadius.button), ), ), ), ); } /// Show coming soon message void _showComingSoon(BuildContext context) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Tính năng đang phát triển'), duration: Duration(seconds: 1), ), ); } /// Show about dialog void _showAboutDialog(BuildContext context) { showDialog( context: context, builder: (context) => AlertDialog( title: const Text('Về ứng dụng'), content: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'EuroTile & Vasta Stone Worker', style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, ), ), const SizedBox(height: 8), const Text('Phiên bản: 1.0.0'), const SizedBox(height: 8), Text( 'Ứng dụng dành cho thầu thợ, kiến trúc sư, đại lý và môi giới trong ngành gạch ốp lát và nội thất.', style: TextStyle( fontSize: 14, color: AppColors.grey500, ), ), ], ), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), child: const Text('Đóng'), ), ], ), ); } /// Show logout confirmation dialog void _showLogoutConfirmation(BuildContext context) { showDialog( context: context, builder: (context) => AlertDialog( title: const Text('Đăng xuất'), content: const Text('Bạn có chắc chắn muốn đăng xuất?'), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), child: const Text('Hủy'), ), TextButton( onPressed: () { Navigator.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Đã đăng xuất'), duration: Duration(seconds: 1), ), ); }, style: TextButton.styleFrom( foregroundColor: AppColors.danger, ), child: const Text('Đăng xuất'), ), ], ), ); } }