From 623bf3597d98d7206f7e46090595d617a6ac3bda Mon Sep 17 00:00:00 2001 From: ahmed albatati Date: Fri, 24 Apr 2026 15:57:35 +0300 Subject: [PATCH] feat: implement agent dashboard UI with order management, service categorization, and application routing --- .../lib/core/enums/laundry_type.dart | 15 + .../lib/core/enums/order_status.dart | 15 + .../localization/language_controller.dart | 17 + .../lib/core/routing/app_router.dart | 10 +- .../lib/core/theme/app_colors.dart | 13 +- .../presentation/agent_dashboard_screen.dart | 615 ++++++++++++++++-- .../agent_order_management_screen.dart | 421 ++++++++++-- .../widgets/agent_app_bar_actions.dart | 58 ++ 8 files changed, 1022 insertions(+), 142 deletions(-) create mode 100644 brightcleanproject/lib/core/enums/laundry_type.dart create mode 100644 brightcleanproject/lib/core/enums/order_status.dart create mode 100644 brightcleanproject/lib/core/localization/language_controller.dart create mode 100644 brightcleanproject/lib/features/agent/presentation/widgets/agent_app_bar_actions.dart diff --git a/brightcleanproject/lib/core/enums/laundry_type.dart b/brightcleanproject/lib/core/enums/laundry_type.dart new file mode 100644 index 0000000..929fc21 --- /dev/null +++ b/brightcleanproject/lib/core/enums/laundry_type.dart @@ -0,0 +1,15 @@ +// import 'package:flutter/material.dart'; + +enum LaundryType { + clothes('ملابس', 'Clothes'), + carsBikes('سيارات ودراجات', 'Cars & Bikes'), + carpets('سجاد', 'Carpets'), + ac('مكيفات', 'AC'), + tanks('خزانات', 'Tanks'), + solarPanels('ألواح شمسية', 'Solar Panels'); + + final String title; + final String englishTitle; + + const LaundryType(this.title, this.englishTitle); +} diff --git a/brightcleanproject/lib/core/enums/order_status.dart b/brightcleanproject/lib/core/enums/order_status.dart new file mode 100644 index 0000000..e6a11af --- /dev/null +++ b/brightcleanproject/lib/core/enums/order_status.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; +import 'package:brightcleanprojet/core/theme/app_colors.dart'; + +enum OrderStatus { + received('تم الاستلام', 'Received', AppColors.primary), + inProgress('قيد التنفيذ', 'In Progress', AppColors.tertiary), + ready('جاهز للتسليم', 'Ready', AppColors.success), + delivered('تم التسليم', 'Delivered', AppColors.secondary); + + final String title; + final String englishTitle; + final Color color; + + const OrderStatus(this.title, this.englishTitle, this.color); +} diff --git a/brightcleanproject/lib/core/localization/language_controller.dart b/brightcleanproject/lib/core/localization/language_controller.dart new file mode 100644 index 0000000..6914e97 --- /dev/null +++ b/brightcleanproject/lib/core/localization/language_controller.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +class LanguageController { + static final LanguageController _instance = LanguageController._internal(); + factory LanguageController() => _instance; + LanguageController._internal(); + + final ValueNotifier locale = ValueNotifier(const Locale('ar')); + + bool get isArabic => locale.value.languageCode == 'ar'; + + void toggleLanguage() { + locale.value = locale.value.languageCode == 'ar' + ? const Locale('en') + : const Locale('ar'); + } +} diff --git a/brightcleanproject/lib/core/routing/app_router.dart b/brightcleanproject/lib/core/routing/app_router.dart index 27f845b..7c65c2d 100644 --- a/brightcleanproject/lib/core/routing/app_router.dart +++ b/brightcleanproject/lib/core/routing/app_router.dart @@ -1,4 +1,5 @@ import 'package:go_router/go_router.dart'; +import 'package:brightcleanprojet/core/enums/order_status.dart'; import '../../features/auth/presentation/splash_screen.dart'; import '../../features/auth/presentation/login_screen.dart'; import '../../features/auth/presentation/role_selection_screen.dart'; @@ -65,7 +66,14 @@ class AppRouter { path: '/agent_order_management/:id', builder: (context, state) { final id = state.pathParameters['id'] ?? 'unknown'; - return AgentOrderManagementScreen(orderId: id); + final extra = state.extra as Map?; + final initialStatus = extra?['status'] as OrderStatus? ?? OrderStatus.received; + final isReadOnly = extra?['isReadOnly'] as bool? ?? false; + return AgentOrderManagementScreen( + orderId: id, + initialStatus: initialStatus, + isReadOnly: isReadOnly + ); }, ), GoRoute( diff --git a/brightcleanproject/lib/core/theme/app_colors.dart b/brightcleanproject/lib/core/theme/app_colors.dart index aedd0d5..ad55b67 100644 --- a/brightcleanproject/lib/core/theme/app_colors.dart +++ b/brightcleanproject/lib/core/theme/app_colors.dart @@ -5,12 +5,11 @@ class AppColors { static const Color secondary = Color(0xFF1C4D8D); static const Color tertiary = Color(0xFF4988C4); static const Color lightBlue = Color(0xFFBDE8F5); - - static const Color background = Color(0xFFF5F7FA); - static const Color textMain = Color(0xFF333333); - static const Color textLight = Color(0xFF888888); + static const Color background = Color(0xFFF8FAFC); + static const Color success = Color(0xFF10B981); + static const Color error = Color(0xFFEF4444); + static const Color warning = Color(0xFFF59E0B); + static const Color textMain = Color(0xFF1E293B); + static const Color textLight = Color(0xFF64748B); static const Color white = Colors.white; - static const Color error = Color(0xFFD32F2F); - static const Color success = Color(0xFF388E3C); - static const Color warning = Color(0xFFF57C00); } diff --git a/brightcleanproject/lib/features/agent/presentation/agent_dashboard_screen.dart b/brightcleanproject/lib/features/agent/presentation/agent_dashboard_screen.dart index f8ef4d6..fae7a84 100644 --- a/brightcleanproject/lib/features/agent/presentation/agent_dashboard_screen.dart +++ b/brightcleanproject/lib/features/agent/presentation/agent_dashboard_screen.dart @@ -1,99 +1,580 @@ import 'package:flutter/material.dart'; -import '../../../../core/theme/app_colors.dart'; +import 'package:brightcleanprojet/core/theme/app_colors.dart'; import 'package:go_router/go_router.dart'; +import 'package:brightcleanprojet/core/enums/laundry_type.dart'; +import 'package:brightcleanprojet/core/enums/order_status.dart'; +import 'package:brightcleanprojet/core/localization/language_controller.dart'; +import 'package:brightcleanprojet/features/agent/presentation/widgets/agent_app_bar_actions.dart'; -class AgentDashboardScreen extends StatelessWidget { - const AgentDashboardScreen({super.key}); +// --- (Mock) نموذج بيانات الطلب --- +class AgentOrderModel { + final String id; + final LaundryType laundryType; + final List services; + OrderStatus status; + final String customerLocation; + final String time; - Widget _buildStatCard(String title, String count, Color color) { + AgentOrderModel({ + required this.id, + required this.laundryType, + required this.services, + required this.status, + required this.customerLocation, + required this.time, + }); +} + +class AgentDashboardScreen extends StatefulWidget { + final LaundryType laundryType; + + const AgentDashboardScreen({ + super.key, + this.laundryType = LaundryType.clothes, + }); + + @override + State createState() => _AgentDashboardScreenState(); +} + +class _AgentDashboardScreenState extends State { + late List _allOrders; + bool _isLaundryOpen = true; + int _selectedIndex = 0; + + // Settings State + bool _notifyOrders = true; + bool _notifyPromotions = false; + bool _notifySystem = true; + + final TextEditingController _nameController = TextEditingController(text: 'مغسلة الخليج'); + final TextEditingController _phoneController = TextEditingController(text: '+966 50 123 4567'); + final TextEditingController _emailController = TextEditingController(text: 'laundry@example.com'); + + @override + void initState() { + super.initState(); + _allOrders = [ + AgentOrderModel(id: '1025', laundryType: LaundryType.clothes, services: ['غسيل', 'كوي'], status: OrderStatus.received, customerLocation: 'شارع الشيخ زايد', time: 'الآن'), + AgentOrderModel(id: '1026', laundryType: LaundryType.clothes, services: ['تنظيف جاف'], status: OrderStatus.inProgress, customerLocation: 'حي الملك فهد', time: 'منذ ساعتين'), + AgentOrderModel(id: '1027', laundryType: LaundryType.clothes, services: ['كوي'], status: OrderStatus.delivered, customerLocation: 'البرشاء', time: 'أمس'), + AgentOrderModel(id: '2001', laundryType: LaundryType.carsBikes, services: ['غسيل خارجي', 'تلميع'], status: OrderStatus.received, customerLocation: 'حي العليا', time: 'الآن'), + AgentOrderModel(id: '3001', laundryType: LaundryType.carpets, services: ['غسيل سجاد', 'تعطير'], status: OrderStatus.ready, customerLocation: 'حي الملقا', time: 'أمس'), + AgentOrderModel(id: '4001', laundryType: LaundryType.ac, services: ['تنظيف فلاتر', 'تعبئة فريون'], status: OrderStatus.inProgress, customerLocation: 'حي النرجس', time: 'منذ ساعة'), + ]; + } + + List get _currentOrders => + _allOrders.where((o) => o.laundryType == widget.laundryType && o.status != OrderStatus.delivered).toList(); + + List get _previousOrders => + _allOrders.where((o) => o.laundryType == widget.laundryType && o.status == OrderStatus.delivered).toList(); + + Widget _buildStatCard(String title, String count, Color color, IconData icon) { return Expanded( - child: Card( - color: color, - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - children: [ - Text(title, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)), - const SizedBox(height: 8), - Text(count, style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)), - ], + child: Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [color.withValues(alpha: 0.8), color], + begin: Alignment.topLeft, + end: Alignment.bottomRight, ), + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow(color: color.withValues(alpha: 0.3), blurRadius: 10, offset: const Offset(0, 4)), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(icon, color: Colors.white.withValues(alpha: 0.8), size: 20), + const SizedBox(height: 12), + Text(count, style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)), + Text(title, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600, fontSize: 11), maxLines: 1, overflow: TextOverflow.ellipsis), + ], ), ), ); } - Widget _buildOrderRequestCard(BuildContext context) { - return Card( - margin: const EdgeInsets.only(bottom: 16), - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + Widget _buildServicesSection() { + final isArabic = LanguageController().isArabic; + List services = []; + switch (widget.laundryType) { + case LaundryType.clothes: services = isArabic ? ['غسيل', 'كوي', 'تنظيف جاف', 'غسيل مستعجل'] : ['Wash', 'Iron', 'Dry Clean', 'Express']; break; + case LaundryType.carsBikes: services = isArabic ? ['غسيل خارجي', 'غسيل داخلي', 'تلميع', 'غسيل مكينة'] : ['Exterior', 'Interior', 'Polishing', 'Engine']; break; + case LaundryType.carpets: services = isArabic ? ['غسيل عميق', 'تعطير', 'إزالة بقع صعبه'] : ['Deep Wash', 'Scenting', 'Stain Removal']; break; + case LaundryType.ac: services = isArabic ? ['تنظيف فلاتر', 'غسيل الوحدة الخارجية', 'تعبئة فريون'] : ['Filters', 'Outdoor Unit', 'Gas Refill']; break; + case LaundryType.tanks: services = isArabic ? ['تفريغ وتنظيف', 'تعقيم الأسطح', 'عزل وتسكير'] : ['Emptying', 'Sterilization', 'Insulation']; break; + case LaundryType.solarPanels: services = isArabic ? ['تنظيف جاف', 'غسيل بالمواصفات', 'فحص كفاءة'] : ['Dry Clean', 'Spec Wash', 'Efficiency Check']; break; + } + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( children: [ - const Row( + const Icon(Icons.star_outline, size: 20, color: AppColors.tertiary), + const SizedBox(width: 8), + Text(isArabic ? 'الخدمات التي تقدمها' : 'Your Services', style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), + ], + ), + const SizedBox(height: 12), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: services.map((s) { + final isDark = Theme.of(context).brightness == Brightness.dark; + return Container( + margin: const EdgeInsets.only(right: 8), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + decoration: BoxDecoration( + color: isDark ? Colors.white.withValues(alpha: 0.05) : AppColors.primary.withValues(alpha: 0.05), + borderRadius: BorderRadius.circular(12), + border: Border.all(color: isDark ? Colors.white10 : AppColors.primary.withValues(alpha: 0.1)), + ), + child: Text(s, style: TextStyle(color: isDark ? Colors.white : AppColors.primary, fontWeight: FontWeight.w600, fontSize: 13)), + ); + }).toList(), + ), + ), + ], + ); + } + + Widget _buildOrderRequestCard(BuildContext context, AgentOrderModel order, bool isArabic, {bool isReadOnly = false}) { + final theme = Theme.of(context); + final isDark = theme.brightness == Brightness.dark; + + return Container( + margin: const EdgeInsets.only(bottom: 20), + decoration: BoxDecoration( + color: theme.cardTheme.color, + borderRadius: BorderRadius.circular(24), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: isDark ? 0.4 : 0.06), + blurRadius: 20, offset: const Offset(0, 10), + ), + ], + border: Border.all(color: isDark ? Colors.white10 : Colors.black.withValues(alpha: 0.05)), + ), + child: Column( + children: [ + Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), + decoration: BoxDecoration( + color: isDark ? Colors.white.withValues(alpha: 0.03) : AppColors.primary.withValues(alpha: 0.03), + borderRadius: const BorderRadius.vertical(top: Radius.circular(24)), + ), + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('طلب رقم #1025', style: TextStyle(fontWeight: FontWeight.bold)), - Text('الآن', style: TextStyle(color: AppColors.error, fontWeight: FontWeight.bold)), + Row( + children: [ + Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + gradient: LinearGradient(colors: [AppColors.primary, AppColors.secondary]), + borderRadius: BorderRadius.circular(12), + ), + child: const Icon(Icons.receipt_long_rounded, color: Colors.white, size: 18), + ), + const SizedBox(width: 12), + Text((isArabic ? 'طلب #' : 'Order #') + order.id, style: const TextStyle(fontWeight: FontWeight.w800, fontSize: 17)), + ], + ), + Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + decoration: BoxDecoration(color: AppColors.error.withValues(alpha: 0.1), borderRadius: BorderRadius.circular(8)), + child: Text( + isArabic ? order.time : order.time.replaceAll('الآن', 'Now').replaceAll('منذ ساعتين', '2h ago').replaceAll('أمس', 'Yesterday').replaceAll('منذ ساعة', '1h ago'), + style: const TextStyle(color: AppColors.error, fontWeight: FontWeight.w700, fontSize: 12) + ), + ), ], ), - const SizedBox(height: 8), - const Text('غسيل ملابس - 10 قطع'), - const Text('التوصيل إلى: شارع الشيخ زايد'), - const SizedBox(height: 16), - Row( + ), + Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: ElevatedButton( - style: ElevatedButton.styleFrom(backgroundColor: AppColors.success), - onPressed: () => context.push('/agent_order_management/1025'), - child: const Text('قبول'), - ), + Text(isArabic ? 'الخدمات المطلوبة' : 'Requested Services', style: TextStyle(color: isDark ? Colors.white54 : Colors.grey.shade600, fontSize: 12, fontWeight: FontWeight.bold, letterSpacing: 0.5)), + const SizedBox(height: 12), + Wrap( + spacing: 10, runSpacing: 10, + children: order.services.map((service) { + IconData icon; + final s = service.toLowerCase(); + if (s.contains('كوي') || s.contains('iron')) { + icon = Icons.iron; + } else if (s.contains('غسيل') || s.contains('wash')) { + icon = Icons.local_laundry_service; + } else if (s.contains('تنظيف جاف') || s.contains('dry clean')) { + icon = Icons.dry_cleaning; + } else if (s.contains('تلميع') || s.contains('polish')) { + icon = Icons.auto_fix_high; + } else if (s.contains('تعطير') || s.contains('scent')) { + icon = Icons.spa; + } else { + icon = Icons.cleaning_services; + } + + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + decoration: BoxDecoration( + color: isDark ? Colors.white.withValues(alpha: 0.05) : AppColors.background, + borderRadius: BorderRadius.circular(12), + border: Border.all(color: isDark ? Colors.white10 : Colors.black.withValues(alpha: 0.05)), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(icon, size: 16, color: isDark ? AppColors.lightBlue : AppColors.tertiary), + const SizedBox(width: 8), + Text(isArabic ? service : _translateService(service), style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600)), + ], + ), + ); + }).toList(), + ), + const Padding( + padding: EdgeInsets.symmetric(vertical: 20), + child: Divider(height: 1, thickness: 1), ), - const SizedBox(width: 16), - Expanded( - child: OutlinedButton( - style: OutlinedButton.styleFrom(foregroundColor: AppColors.error), - onPressed: () {}, - child: const Text('رفض'), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Icon(Icons.location_on_rounded, size: 18, color: isDark ? AppColors.lightBlue : AppColors.tertiary), + const SizedBox(width: 8), + Text( + isArabic ? order.customerLocation : _translateLocation(order.customerLocation), + style: TextStyle(color: isDark ? Colors.white70 : Colors.grey.shade700, fontSize: 13, fontWeight: FontWeight.w500) + ), + ], + ), + Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration(color: order.status.color.withValues(alpha: 0.15), borderRadius: BorderRadius.circular(30)), + child: Text(isArabic ? order.status.title : order.status.englishTitle, style: TextStyle(color: order.status.color, fontWeight: FontWeight.w800, fontSize: 11)), + ), + ], + ), + const SizedBox(height: 24), + ElevatedButton( + onPressed: () async { + final newStatus = await context.push( + '/agent_order_management/${order.id}', + extra: { + 'status': order.status, + 'isReadOnly': isReadOnly, + }, + ); + if (newStatus != null && !isReadOnly) { + setState(() { + order.status = newStatus; + }); + } + }, + style: ElevatedButton.styleFrom( + backgroundColor: isReadOnly ? (isDark ? Colors.white10 : Colors.grey.shade100) : AppColors.primary, + foregroundColor: isReadOnly ? (isDark ? Colors.white : Colors.black87) : Colors.white, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + padding: const EdgeInsets.symmetric(vertical: 14), + elevation: isReadOnly ? 0 : 2, + ), + child: Center( + child: Text( + isReadOnly ? (isArabic ? 'عرض التفاصيل' : 'View Details') : (isArabic ? 'إدارة الطلب' : 'Manage Order'), + style: const TextStyle(fontWeight: FontWeight.bold) + ), ), ), ], ), - ], - ), + ), + ], ), ); } - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text('لوحة تحكم المغسلة')), - body: SingleChildScrollView( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Stats - Row( - children: [ - _buildStatCard('طلبات جديدة', '5', AppColors.primary), - const SizedBox(width: 8), - _buildStatCard('قيد المعالجة', '12', AppColors.tertiary), - const SizedBox(width: 8), - _buildStatCard('جاهز', '3', AppColors.success), - ], + Widget _buildHomeSection(List orders) { + final isArabic = LanguageController().isArabic; + return SingleChildScrollView( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(isArabic ? 'مرحباً بك مجدداً!' : 'Welcome Back!', style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w900, letterSpacing: -0.5)), + Text(isArabic ? 'إليك ملخص نشاطك اليوم' : 'Here is your activity summary', style: TextStyle(fontSize: 14, color: Colors.grey.shade600)), + const SizedBox(height: 24), + Row( + children: [ + _buildStatCard(isArabic ? 'طلبات استلمت' : 'Received', orders.where((o) => o.status == OrderStatus.received).length.toString(), AppColors.primary, Icons.download_rounded), + const SizedBox(width: 12), + _buildStatCard(isArabic ? 'قيد التنفيذ' : 'In Progress', orders.where((o) => o.status == OrderStatus.inProgress).length.toString(), AppColors.tertiary, Icons.sync_rounded), + const SizedBox(width: 12), + _buildStatCard(isArabic ? 'مكتمل' : 'Completed', _allOrders.where((o) => o.laundryType == widget.laundryType && (o.status == OrderStatus.ready || o.status == OrderStatus.delivered)).length.toString(), AppColors.success, Icons.check_circle_rounded), + ], + ), + const SizedBox(height: 32), + _buildServicesSection(), + const SizedBox(height: 32), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(isArabic ? 'الطلبات الجارية' : 'Current Orders', style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w800)), + TextButton(onPressed: () {}, child: Text(isArabic ? 'عرض الكل' : 'View All')), + ], + ), + const SizedBox(height: 12), + if (orders.isEmpty) _buildEmptyState(isArabic ? 'لا توجد طلبات جارية حالياً' : 'No current orders') + else ...orders.map((order) => _buildOrderRequestCard(context, order, isArabic)), + ], + ), + ); + } + + Widget _buildOrdersSection() { + final isArabic = LanguageController().isArabic; + final orders = _previousOrders; + return SingleChildScrollView( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(isArabic ? 'سجل الطلبات' : 'Order History', style: const TextStyle(fontSize: 22, fontWeight: FontWeight.w900)), + Text(isArabic ? 'مراجعة كافة الطلبات السابقة' : 'Review all previous orders', style: TextStyle(fontSize: 14, color: Colors.grey.shade600)), + const SizedBox(height: 24), + if (orders.isEmpty) _buildEmptyState(isArabic ? 'سجل الطلبات فارغ' : 'Order history is empty') + else ...orders.map((order) => _buildOrderRequestCard(context, order, isArabic, isReadOnly: true)), + ], + ), + ); + } + + Widget _buildSettingsSection() { + final langController = LanguageController(); + final isArabic = langController.isArabic; + final isDark = Theme.of(context).brightness == Brightness.dark; + + return ListView( + padding: const EdgeInsets.all(16), + children: [ + // الملف الشخصي + _buildSettingsHeader(isArabic ? 'الملف الشخصي' : 'Profile'), + _buildSettingsTile(Icons.person_outline, isArabic ? 'الاسم' : 'Name', _nameController.text, onTap: () => _showEditDialog(isArabic ? 'الاسم' : 'Name', _nameController)), + _buildSettingsTile(Icons.phone_outlined, isArabic ? 'رقم الهاتف' : 'Phone Number', _phoneController.text, onTap: () => _showEditDialog(isArabic ? 'رقم الهاتف' : 'Phone Number', _phoneController)), + _buildSettingsTile(Icons.email_outlined, isArabic ? 'البريد الإلكتروني' : 'Email', _emailController.text, onTap: () => _showEditDialog(isArabic ? 'البريد الإلكتروني' : 'Email', _emailController)), + + const SizedBox(height: 24), + + // التنبيهات + _buildSettingsHeader(isArabic ? 'إعدادات التنبيهات' : 'Notification Settings'), + _buildSwitchTile(isArabic ? 'تنبيهات الطلبات الجديدة' : 'New Order Alerts', _notifyOrders, (v) => setState(() => _notifyOrders = v)), + _buildSwitchTile(isArabic ? 'العروض الترويجية' : 'Promotions', _notifyPromotions, (v) => setState(() => _notifyPromotions = v)), + _buildSwitchTile(isArabic ? 'تنبيهات النظام' : 'System Alerts', _notifySystem, (v) => setState(() => _notifySystem = v)), + + const SizedBox(height: 24), + + // اللغة + _buildSettingsHeader(isArabic ? 'التفضيلات' : 'Preferences'), + ListTile( + leading: Icon(Icons.language, color: isDark ? Colors.white : AppColors.primary), + title: Text(isArabic ? 'لغة التطبيق' : 'App Language', style: const TextStyle(fontWeight: FontWeight.bold)), + trailing: Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + decoration: BoxDecoration( + color: isDark ? Colors.white10 : AppColors.primary.withValues(alpha: 0.1), + borderRadius: BorderRadius.circular(12), ), - const SizedBox(height: 24), - const Text('الطلبات الواردة', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), - const SizedBox(height: 16), - _buildOrderRequestCard(context), - _buildOrderRequestCard(context), - ], + child: Text( + isArabic ? 'العربية' : 'English', + style: TextStyle( + color: isDark ? Colors.white : AppColors.primary, + fontWeight: FontWeight.bold + ) + ), + ), + onTap: () { + setState(() { + langController.toggleLanguage(); + }); + }, + ), + + const Divider(height: 40), + _buildSettingsTile(Icons.logout, isArabic ? 'تسجيل الخروج' : 'Logout', isArabic ? 'تسجيل خروج من الحساب' : 'Logout from account', color: AppColors.error, onTap: () => context.go('/login')), + ], + ); + } + + Widget _buildSettingsHeader(String title) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Text(title, style: TextStyle(fontSize: 14, color: Colors.grey.shade600, fontWeight: FontWeight.bold)), + ); + } + + Widget _buildSwitchTile(String title, bool value, Function(bool) onChanged) { + return SwitchListTile( + secondary: Icon(value ? Icons.notifications_active : Icons.notifications_off, color: value ? AppColors.primary : Colors.grey), + title: Text(title, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600)), + value: value, + onChanged: onChanged, + activeTrackColor: AppColors.primary.withValues(alpha: 0.5), + activeThumbColor: AppColors.primary, + ); + } + + void _showEditDialog(String title, TextEditingController controller) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('تعديل $title'), + content: TextField( + controller: controller, + decoration: InputDecoration(hintText: 'أدخل $title الجديد'), ), + actions: [ + TextButton(onPressed: () => Navigator.pop(context), child: const Text('إلغاء')), + ElevatedButton(onPressed: () { + setState(() {}); + Navigator.pop(context); + }, child: const Text('حفظ')), + ], ), ); } + + Widget _buildSettingsTile(IconData icon, String title, String subtitle, {Color? color, VoidCallback? onTap}) { + return ListTile( + leading: Icon(icon, color: color ?? AppColors.primary), + title: Text(title, style: TextStyle(fontWeight: FontWeight.bold, color: color)), + subtitle: Text(subtitle, style: const TextStyle(fontSize: 12)), + trailing: const Icon(Icons.arrow_forward_ios, size: 14), + onTap: onTap, + ); + } + + Widget _buildEmptyState(String message) { + return Container( + width: double.infinity, padding: const EdgeInsets.all(40), + decoration: BoxDecoration(color: Colors.grey.withValues(alpha: 0.1), borderRadius: BorderRadius.circular(20)), + child: Column( + children: [ + const Icon(Icons.inbox_outlined, size: 60, color: Colors.grey), + const SizedBox(height: 16), + Text(message, style: TextStyle(color: Theme.of(context).brightness == Brightness.dark ? Colors.white70 : Colors.grey, fontSize: 16, fontWeight: FontWeight.bold)), + ], + ), + ); + } + + + String _translateService(String service) { + final Map translations = { + 'غسيل': 'Wash', + 'كوي': 'Iron', + 'تنظيف جاف': 'Dry Clean', + 'غسيل مستعجل': 'Express Wash', + 'غسيل خارجي': 'Exterior Wash', + 'غسيل داخلي': 'Interior Wash', + 'تلميع': 'Polishing', + 'غسيل مكينة': 'Engine Wash', + 'غسيل عميق': 'Deep Wash', + 'تعطير': 'Scenting', + 'إزالة بقع صعبه': 'Stain Removal', + 'تنظيف فلاتر': 'Filters Cleaning', + 'غسيل الوحدة الخارجية': 'Outdoor Unit Wash', + 'تعبئة فريون': 'Gas Refill', + 'تفريغ وتنظيف': 'Emptying & Cleaning', + 'تعقيم الأسطح': 'Surface Sterilization', + 'عزل وتسكير': 'Insulation', + 'غسيل بالمواصفات': 'Spec Wash', + 'فحص كفاءة': 'Efficiency Check', + 'ثوب': 'Thoob', + 'ثياب': 'Clothes', + 'ملابس': 'Clothes', + }; + + String translated = service; + translations.forEach((ar, en) { + if (translated.contains(ar)) { + translated = translated.replaceAll(ar, en); + } + }); + return translated; + } + + String _translateLocation(String location) { + final Map translations = { + 'شارع الشيخ زايد': 'Sheikh Zayed Rd', + 'حي الملك فهد': 'King Fahd District', + 'البرشاء': 'Al Barsha', + 'حي العليا': 'Al Olaya', + 'حي الملقا': 'Al Malqa', + 'حي النرجس': 'Al Narjis', + 'دبي': 'Dubai', + 'الرياض': 'Riyadh', + }; + + String translated = location; + translations.forEach((ar, en) { + if (translated.contains(ar)) { + translated = translated.replaceAll(ar, en); + } + }); + return translated; + } + + @override + Widget build(BuildContext context) { + final langController = LanguageController(); + + return ValueListenableBuilder( + valueListenable: langController.locale, + builder: (context, locale, _) { + final isArabic = locale.languageCode == 'ar'; + + return Scaffold( + appBar: AppBar( + title: Text(_selectedIndex == 0 + ? _nameController.text + : _selectedIndex == 1 + ? (isArabic ? 'الطلبات' : 'Orders') + : (isArabic ? 'الإعدادات' : 'Settings')), + actions: [ + AgentAppBarActions( + isLaundryOpen: _isLaundryOpen, + onAvailabilityChanged: (v) => setState(() => _isLaundryOpen = v), + onSettingsPressed: () => setState(() => _selectedIndex = 2), + ), + ], + ), + body: IndexedStack( + index: _selectedIndex, + children: [ + _buildHomeSection(_currentOrders), + _buildOrdersSection(), + _buildSettingsSection(), + ], + ), + bottomNavigationBar: BottomNavigationBar( + currentIndex: _selectedIndex, + onTap: (index) => setState(() => _selectedIndex = index), + selectedItemColor: Theme.of(context).brightness == Brightness.dark ? AppColors.lightBlue : AppColors.primary, + items: [ + BottomNavigationBarItem(icon: const Icon(Icons.home_filled), label: isArabic ? 'الرئيسية' : 'Home'), + BottomNavigationBarItem(icon: const Icon(Icons.history), label: isArabic ? 'الطلبات' : 'Orders'), + BottomNavigationBarItem(icon: const Icon(Icons.settings), label: isArabic ? 'الإعدادات' : 'Settings'), + ], + ), + ); + } + ); + } } diff --git a/brightcleanproject/lib/features/agent/presentation/agent_order_management_screen.dart b/brightcleanproject/lib/features/agent/presentation/agent_order_management_screen.dart index 638ea7d..ff9ae3d 100644 --- a/brightcleanproject/lib/features/agent/presentation/agent_order_management_screen.dart +++ b/brightcleanproject/lib/features/agent/presentation/agent_order_management_screen.dart @@ -1,92 +1,379 @@ import 'package:flutter/material.dart'; -//import '../../../../core/theme/app_colors.dart'; +import 'package:go_router/go_router.dart'; +import 'package:brightcleanprojet/core/enums/order_status.dart'; +import 'package:brightcleanprojet/core/theme/app_colors.dart'; +import 'package:brightcleanprojet/core/localization/language_controller.dart'; +import 'package:brightcleanprojet/features/agent/presentation/widgets/agent_app_bar_actions.dart'; class AgentOrderManagementScreen extends StatefulWidget { final String orderId; + final OrderStatus initialStatus; + final bool isReadOnly; - const AgentOrderManagementScreen({super.key, required this.orderId}); + const AgentOrderManagementScreen({ + super.key, + required this.orderId, + required this.initialStatus, + this.isReadOnly = false, + }); @override State createState() => _AgentOrderManagementScreenState(); } -class _AgentOrderManagementScreenState - extends State { - String _currentStatus = 'received'; // received, washing, ready +// نموذج بيانات للعنصر في الطلب +class OrderItemMock { + final String itemName; + final String serviceType; + final int quantity; + final IconData icon; + + OrderItemMock(this.itemName, this.serviceType, this.quantity, this.icon); +} + +class _AgentOrderManagementScreenState extends State { + late OrderStatus _currentStatus; + + @override + void initState() { + super.initState(); + _currentStatus = widget.initialStatus; + } + + // عناصر وهمية للطلب + final List _items = [ + OrderItemMock('ثوب', 'كوي', 5, Icons.iron), + OrderItemMock('تيشيرت', 'غسيل', 3, Icons.local_laundry_service), + OrderItemMock('شماغ', 'غسيل وكوي', 2, Icons.dry_cleaning), + ]; + + String _translateItem(String item) { + final Map translations = { + 'ثوب': 'Thoob', + 'تيشيرت': 'T-shirt', + 'شماغ': 'Shemagh', + }; + return translations[item] ?? item; + } + + String _translateService(String service) { + final Map translations = { + 'غسيل': 'Wash', + 'كوي': 'Iron', + 'غسيل وكوي': 'Wash & Iron', + 'تنظيف جاف': 'Dry Clean', + }; + return translations[service] ?? service; + } @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: Text('إدارة الطلب #${widget.orderId}')), - body: Padding( - padding: const EdgeInsets.all(24.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - const Text( - 'تفاصيل الطلب:', - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), - ), - const SizedBox(height: 8), - Card( - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: const [ - Text('العميل: أحمد محمد'), - Text('الخدمة: غسيل ملابس (كي فقط)'), - Text('الكمية: 10 قطع'), - Divider(), - Text( - 'الإجمالي: 100 درهم', - style: TextStyle(fontWeight: FontWeight.bold), + final theme = Theme.of(context); + final isDark = theme.brightness == Brightness.dark; + final langController = LanguageController(); + + return ValueListenableBuilder( + valueListenable: langController.locale, + builder: (context, locale, _) { + final isArabic = locale.languageCode == 'ar'; + + return Scaffold( + backgroundColor: isDark ? const Color(0xFF121212) : AppColors.background, + appBar: AppBar( + title: Text(isArabic ? 'إدارة الطلب #${widget.orderId}' : 'Manage Order #${widget.orderId}'), + elevation: 0, + actions: const [ + AgentAppBarActions(), + ], + ), + body: Column( + children: [ + // Premium Header / Status Banner + if (widget.isReadOnly) + Container( + width: double.infinity, + padding: const EdgeInsets.symmetric(vertical: 12), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [AppColors.success.withValues(alpha: 0.8), AppColors.success], ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(Icons.check_circle_outline, color: Colors.white, size: 20), + const SizedBox(width: 10), + Text( + isArabic ? 'هذا الطلب مكتمل ولا يمكن تعديله' : 'This order is finalized and cannot be modified', + style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 13), + ), + ], + ), + ), + + Expanded( + child: SingleChildScrollView( + padding: const EdgeInsets.all(24.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _buildSectionHeader(isArabic ? 'تفاصيل الطلب' : 'Order Details', theme), + const SizedBox(height: 16), + + // Modern Order Card + Container( + decoration: BoxDecoration( + color: theme.cardTheme.color, + borderRadius: BorderRadius.circular(24), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: isDark ? 0.4 : 0.06), + blurRadius: 20, + offset: const Offset(0, 10), + ), + ], + border: Border.all(color: isDark ? Colors.white10 : Colors.black.withValues(alpha: 0.05)), + ), + child: Column( + children: [ + // Card Header with Gradient + Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: isDark + ? [Colors.white.withValues(alpha: 0.05), Colors.white.withValues(alpha: 0.01)] + : [AppColors.primary.withValues(alpha: 0.05), Colors.transparent], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: const BorderRadius.vertical(top: Radius.circular(24)), + ), + child: Row( + children: [ + CircleAvatar( + radius: 24, + backgroundColor: isDark ? AppColors.lightBlue.withValues(alpha: 0.2) : AppColors.primary.withValues(alpha: 0.1), + child: Icon(Icons.person_rounded, size: 24, color: isDark ? AppColors.lightBlue : AppColors.primary) + ), + const SizedBox(width: 16), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(isArabic ? 'أحمد محمد' : 'Ahmed Mohamed', style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18)), + Text(isArabic ? 'عميل بريميوم' : 'Premium Customer', style: TextStyle(fontSize: 12, color: isDark ? Colors.white54 : Colors.grey.shade600, letterSpacing: 0.5)), + ], + ), + ), + _buildStatusBadge(_currentStatus, isArabic), + ], + ), + ), + + Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon(Icons.inventory_2_outlined, size: 16, color: isDark ? AppColors.lightBlue : AppColors.primary), + const SizedBox(width: 8), + Text(isArabic ? 'محتويات الطلب' : 'Order Contents', style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14)), + ], + ), + const SizedBox(height: 16), + ..._items.map((item) => _buildItemRow(item, isArabic, isDark)), + + const Padding( + padding: EdgeInsets.symmetric(vertical: 16), + child: Divider(height: 1, thickness: 1), + ), + + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(isArabic ? 'الإجمالي المتوقع' : 'Estimated Total', style: TextStyle(color: isDark ? Colors.white70 : Colors.grey.shade700, fontWeight: FontWeight.w500)), + Text( + isArabic ? '100 درهم' : '100 AED', + style: TextStyle( + color: isDark ? AppColors.lightBlue : AppColors.primary, + fontWeight: FontWeight.w900, + fontSize: 22, + letterSpacing: -0.5, + ) + ), + ], + ), + ], + ), + ), + ], + ), + ), + + const SizedBox(height: 32), + + if (!widget.isReadOnly) ...[ + _buildSectionHeader(isArabic ? 'تحديث حالة الطلب' : 'Update Order Status', theme), + const SizedBox(height: 16), + Wrap( + spacing: 10, + runSpacing: 10, + children: OrderStatus.values.map((status) { + final isSelected = _currentStatus == status; + return _buildStatusChip(status, isSelected, isArabic, isDark); + }).toList(), + ), + ], + ], + ), + ), + ), + + // Bottom Action Area + Container( + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + color: theme.scaffoldBackgroundColor, + boxShadow: [ + BoxShadow(color: Colors.black.withValues(alpha: 0.05), blurRadius: 10, offset: const Offset(0, -5)), ], ), + child: widget.isReadOnly + ? OutlinedButton( + onPressed: () => context.pop(), + style: OutlinedButton.styleFrom( + side: BorderSide(color: isDark ? Colors.white24 : Colors.grey.shade300), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + padding: const EdgeInsets.symmetric(vertical: 16), + ), + child: Text(isArabic ? 'العودة للخلف' : 'Go Back', style: TextStyle(color: isDark ? Colors.white : Colors.black87, fontWeight: FontWeight.bold)), + ) + : ElevatedButton( + onPressed: () { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(isArabic ? 'تم تحديث حالة الطلب بنجاح' : 'Order status updated successfully'), + backgroundColor: AppColors.success, + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + ), + ); + context.pop(_currentStatus); + }, + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.primary, + foregroundColor: Colors.white, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + padding: const EdgeInsets.symmetric(vertical: 16), + elevation: 4, + shadowColor: AppColors.primary.withValues(alpha: 0.4), + ), + child: Text(isArabic ? 'تأكيد وحفظ التغييرات' : 'Confirm & Save Changes', style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16)), + ), ), + ], + ), + ); + } + ); + } + + Widget _buildSectionHeader(String title, ThemeData theme) { + return Row( + children: [ + Container(width: 4, height: 18, decoration: BoxDecoration(color: AppColors.primary, borderRadius: BorderRadius.circular(2))), + const SizedBox(width: 10), + Text(title, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w800, letterSpacing: 0.5)), + ], + ); + } + + Widget _buildStatusBadge(OrderStatus status, bool isArabic) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + decoration: BoxDecoration( + color: status.color.withValues(alpha: 0.15), + borderRadius: BorderRadius.circular(30), + border: Border.all(color: status.color.withValues(alpha: 0.3), width: 1), + ), + child: Text( + isArabic ? status.title : status.englishTitle, + style: TextStyle(color: status.color, fontWeight: FontWeight.bold, fontSize: 11), + ), + ); + } + + Widget _buildItemRow(OrderItemMock item, bool isArabic, bool isDark) { + return Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: Row( + children: [ + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: isDark ? Colors.white.withValues(alpha: 0.05) : AppColors.background, + borderRadius: BorderRadius.circular(16), + border: Border.all(color: isDark ? Colors.white10 : Colors.black.withValues(alpha: 0.03)), ), - const SizedBox(height: 32), - const Text( - 'تحديث حالة الطلب:', - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + child: Icon(item.icon, color: isDark ? AppColors.lightBlue : AppColors.primary, size: 22), + ), + const SizedBox(width: 16), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(isArabic ? item.itemName : _translateItem(item.itemName), style: const TextStyle(fontWeight: FontWeight.w700, fontSize: 15)), + const SizedBox(height: 2), + Text(isArabic ? item.serviceType : _translateService(item.serviceType), style: TextStyle(fontSize: 12, color: isDark ? Colors.white54 : Colors.grey.shade600)), + ], ), - const SizedBox(height: 16), - RadioGroup( - groupValue: _currentStatus, - onChanged: (String? v) { - if (v != null) { - setState(() => _currentStatus = v); - } - }, - child: Column( - children: [ - RadioListTile( - title: const Text('تم الاستلام'), - value: 'received', - ), - RadioListTile( - title: const Text('قيد الغسيل / المعالجة'), - value: 'washing', - ), - RadioListTile( - title: const Text('جاهز للتسليم'), - value: 'ready', - ), - ], - ), + ), + Container( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), + decoration: BoxDecoration( + color: isDark ? AppColors.primary.withValues(alpha: 0.3) : AppColors.primary.withValues(alpha: 0.05), + borderRadius: BorderRadius.circular(12), ), - const Spacer(), - ElevatedButton( - onPressed: () { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('تم تحديث حالة الطلب بنجاح')), - ); - }, - child: const Text('حفظ التغييرات'), + child: Text( + '${item.quantity} ${isArabic ? 'قطع' : 'pcs'}', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: isDark ? Colors.white : AppColors.primary), ), - ], + ), + ], + ), + ); + } + + Widget _buildStatusChip(OrderStatus status, bool isSelected, bool isArabic, bool isDark) { + return InkWell( + onTap: () => setState(() => _currentStatus = status), + borderRadius: BorderRadius.circular(16), + child: AnimatedContainer( + duration: const Duration(milliseconds: 300), + curve: Curves.easeOutCubic, + padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 12), + decoration: BoxDecoration( + color: isSelected ? status.color : (isDark ? Colors.white.withValues(alpha: 0.05) : Colors.white), + borderRadius: BorderRadius.circular(16), + border: Border.all( + color: isSelected ? Colors.transparent : (isDark ? Colors.white10 : Colors.grey.shade200), + width: 1.5, + ), + boxShadow: isSelected + ? [BoxShadow(color: status.color.withValues(alpha: 0.4), blurRadius: 10, offset: const Offset(0, 4))] + : [], + ), + child: Text( + isArabic ? status.title : status.englishTitle, + style: TextStyle( + color: isSelected ? Colors.white : (isDark ? Colors.white70 : Colors.grey.shade700), + fontWeight: FontWeight.bold, + fontSize: 14, + ), ), ), ); diff --git a/brightcleanproject/lib/features/agent/presentation/widgets/agent_app_bar_actions.dart b/brightcleanproject/lib/features/agent/presentation/widgets/agent_app_bar_actions.dart new file mode 100644 index 0000000..ade0e86 --- /dev/null +++ b/brightcleanproject/lib/features/agent/presentation/widgets/agent_app_bar_actions.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; +import 'package:brightcleanprojet/core/theme/app_colors.dart'; +import 'package:brightcleanprojet/core/localization/language_controller.dart'; + +class AgentAppBarActions extends StatelessWidget { + final bool? isLaundryOpen; + final ValueChanged? onAvailabilityChanged; + final VoidCallback? onSettingsPressed; + + const AgentAppBarActions({ + super.key, + this.isLaundryOpen, + this.onAvailabilityChanged, + this.onSettingsPressed, + }); + + @override + Widget build(BuildContext context) { + final isArabic = LanguageController().isArabic; + // final isDark = Theme.of(context).brightness == Brightness.dark; + + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (isLaundryOpen != null) + Row( + children: [ + Text( + isLaundryOpen! + ? (isArabic ? 'مفتوح' : 'Open') + : (isArabic ? 'مغلق' : 'Closed'), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: isLaundryOpen! ? AppColors.success : AppColors.error, + ), + ), + Switch( + value: isLaundryOpen!, + onChanged: onAvailabilityChanged, + activeThumbColor: AppColors.success, + ), + ], + ), + IconButton( + icon: const Icon(Icons.notifications_outlined), + onPressed: () {}, + ), + if (onSettingsPressed != null) + IconButton( + icon: const Icon(Icons.settings_outlined), + onPressed: onSettingsPressed, + ), + const SizedBox(width: 8), + ], + ); + } +}