إصلاح توافق فلاتر مع Theme الجديد

This commit is contained in:
Hamza-Ayed
2026-07-26 11:33:20 +03:00
parent 7830efead7
commit 3af99cc18a
31 changed files with 4256 additions and 2833 deletions
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:siro_admin/constant/links.dart';
import 'package:siro_admin/controller/employee_controller/employee_controller.dart';
import 'package:siro_admin/controller/functions/upload_image copy.dart'; // تأكد من مسار الملف الصحيح
import 'package:siro_admin/controller/functions/upload_image copy.dart';
import 'package:url_launcher/url_launcher.dart';
class EmployeePage extends StatelessWidget {
@@ -10,27 +10,21 @@ class EmployeePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
// حقن الكنترولر
Get.put(EmployeeController());
// ألوان الثيم
const Color bgColor = Color(0xFF0A0E27);
const Color cardColor = Color(0xFF1A1F3A);
const Color primaryAccent = Color(0xFF6366F1);
final cs = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: bgColor,
backgroundColor: cs.surface,
body: GetBuilder<EmployeeController>(
builder: (controller) {
return CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: [
// 1. App Bar
SliverAppBar(
expandedHeight: 100,
floating: true,
pinned: true,
backgroundColor: bgColor,
backgroundColor: cs.surface,
elevation: 0,
flexibleSpace: FlexibleSpaceBar(
titlePadding: const EdgeInsets.only(bottom: 16),
@@ -40,19 +34,19 @@ class EmployeePage extends StatelessWidget {
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: primaryAccent.withOpacity(0.2),
color: cs.primary.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(Icons.badge_rounded,
color: Colors.white, size: 18),
child: Icon(Icons.badge_rounded,
color: cs.onSurface, size: 18),
),
const SizedBox(width: 10),
const Text(
Text(
'الموظفون',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
color: Colors.white,
color: cs.onSurface,
fontFamily: 'Segoe UI',
),
),
@@ -65,8 +59,8 @@ class EmployeePage extends StatelessWidget {
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
primaryAccent.withOpacity(0.15),
bgColor,
cs.primary.withValues(alpha: 0.15),
cs.surface,
],
),
),
@@ -74,18 +68,17 @@ class EmployeePage extends StatelessWidget {
),
),
// 2. قائمة الموظفين
if (controller.employee.isEmpty)
const SliverFillRemaining(
SliverFillRemaining(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.people_outline,
size: 60, color: Colors.white24),
SizedBox(height: 16),
size: 60, color: cs.onSurface.withValues(alpha: 0.24)),
const SizedBox(height: 16),
Text("لا يوجد موظفين حالياً",
style: TextStyle(color: Colors.white54)),
style: TextStyle(color: cs.onSurfaceVariant)),
],
),
),
@@ -100,8 +93,7 @@ class EmployeePage extends StatelessWidget {
return _EmployeeCard(
employee: employee,
index: index,
cardColor: cardColor,
primaryAccent: primaryAccent,
cs: cs,
);
},
childCount: controller.employee.length,
@@ -118,25 +110,22 @@ class EmployeePage extends StatelessWidget {
controller.id = controller.generateRandomId(8);
Get.to(() => _EmployeeFormScreen(controller: controller));
},
backgroundColor: primaryAccent,
child: const Icon(Icons.person_add_rounded, color: Colors.white),
backgroundColor: cs.primary,
child: Icon(Icons.person_add_rounded, color: cs.onPrimary),
),
);
}
}
// === بطاقة الموظف (تصميم جديد ومحسن) ===
class _EmployeeCard extends StatelessWidget {
final Map<String, dynamic> employee;
final int index;
final Color cardColor;
final Color primaryAccent;
final ColorScheme cs;
const _EmployeeCard({
required this.employee,
required this.index,
required this.cardColor,
required this.primaryAccent,
required this.cs,
});
@override
@@ -147,12 +136,12 @@ class _EmployeeCard extends StatelessWidget {
return Container(
margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: cardColor,
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.white.withOpacity(0.05)),
border: Border.all(color: cs.outline.withValues(alpha: 0.1)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 10,
offset: const Offset(0, 4),
),
@@ -168,28 +157,27 @@ class _EmployeeCard extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// الصف العلوي: الحالة + أيقونة
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.05),
color: cs.outline.withValues(alpha: 0.1),
shape: BoxShape.circle,
),
child: Icon(Icons.person,
color: Colors.white.withOpacity(0.7), size: 20),
color: cs.onSurface.withValues(alpha: 0.7), size: 20),
),
Flexible(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 6),
decoration: BoxDecoration(
color: statusColor.withOpacity(0.1),
color: statusColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
border:
Border.all(color: statusColor.withOpacity(0.3)),
Border.all(color: statusColor.withValues(alpha: 0.3)),
),
child: Text(
employee['status'] ?? 'Unknown',
@@ -208,23 +196,21 @@ class _EmployeeCard extends StatelessWidget {
const SizedBox(height: 12),
// الاسم في سطر كامل ومميز
Text(
employee['name'] ?? 'Unknown',
style: const TextStyle(
color: Colors.white,
style: TextStyle(
color: cs.onSurface,
fontSize: 18,
fontWeight: FontWeight.bold,
height: 1.3,
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 12),
child: Divider(height: 1, color: Colors.white10),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Divider(height: 1, color: cs.outline.withValues(alpha: 0.1)),
),
// تفاصيل التعليم والهاتف والموقع (مع دعم تعدد الأسطر)
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@@ -233,23 +219,22 @@ class _EmployeeCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildInfoRow(Icons.phone_iphone_rounded,
employee['phone'] ?? '', Colors.white54),
const SizedBox(height: 12), // مسافة أكبر بين العناصر
employee['phone'] ?? '', cs.onSurfaceVariant, cs),
const SizedBox(height: 12),
_buildInfoRow(
Icons.school_outlined,
employee['education'] ?? 'غير محدد',
primaryAccent),
const SizedBox(height: 12), // مسافة أكبر
cs.primary, cs),
const SizedBox(height: 12),
_buildInfoRow(Icons.location_on_outlined,
employee['site'] ?? 'غير محدد', Colors.blueGrey),
employee['site'] ?? 'غير محدد', Colors.blueGrey, cs),
],
),
),
// زر الاتصال الجانبي
const SizedBox(width: 16),
Material(
color: Colors.green.withOpacity(0.1),
color: const Color(0xFF10B981).withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
child: InkWell(
onTap: () =>
@@ -258,7 +243,7 @@ class _EmployeeCard extends StatelessWidget {
child: Container(
padding: const EdgeInsets.all(14),
child: const Icon(Icons.call,
color: Colors.green, size: 24),
color: Color(0xFF10B981), size: 24),
),
),
),
@@ -272,25 +257,23 @@ class _EmployeeCard extends StatelessWidget {
);
}
Widget _buildInfoRow(IconData icon, String text, Color iconColor) {
Widget _buildInfoRow(IconData icon, String text, Color iconColor, ColorScheme cs) {
return Row(
crossAxisAlignment:
CrossAxisAlignment.start, // محاذاة الأيقونة مع بداية النص
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 2), // ضبط بسيط لموقع الأيقونة
child: Icon(icon, size: 16, color: iconColor.withOpacity(0.8)),
padding: const EdgeInsets.only(top: 2),
child: Icon(icon, size: 16, color: iconColor.withValues(alpha: 0.8)),
),
const SizedBox(width: 10),
Expanded(
child: Text(
text,
style: TextStyle(
color: Colors.white.withOpacity(0.7),
color: cs.onSurface.withValues(alpha: 0.7),
fontSize: 13,
height: 1.5, // تباعد الأسطر لسهولة القراءة
height: 1.5,
),
// تم إزالة maxLines و overflow للسماح بالنص بالنزول لأسطر متعددة
),
),
],
@@ -305,25 +288,23 @@ class _EmployeeCard extends StatelessWidget {
}
}
// === شاشة إضافة موظف ===
class _EmployeeFormScreen extends StatelessWidget {
final EmployeeController controller;
const _EmployeeFormScreen({required this.controller});
@override
Widget build(BuildContext context) {
const Color bgColor = Color(0xFF0A0E27);
const Color inputColor = Color(0xFF1A1F3A);
final cs = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: bgColor,
backgroundColor: cs.surface,
appBar: AppBar(
title: const Text("إضافة موظف جديد",
style: TextStyle(color: Colors.white)),
backgroundColor: bgColor,
title: Text("إضافة موظف جديد",
style: TextStyle(color: cs.onSurface)),
backgroundColor: cs.surface,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.white),
icon: Icon(Icons.arrow_back, color: cs.onSurface),
onPressed: () => Get.back(),
),
),
@@ -339,6 +320,7 @@ class _EmployeeFormScreen extends StatelessWidget {
child: _UploadButton(
title: "الهوية (أمام)",
icon: Icons.credit_card,
cs: cs,
onPressed: () async {
await ImageController().choosImage(AppLink.uploadEgypt,
'idFrontEmployee', controller.id);
@@ -350,6 +332,7 @@ class _EmployeeFormScreen extends StatelessWidget {
child: _UploadButton(
title: "الهوية (خلف)",
icon: Icons.credit_card_outlined,
cs: cs,
onPressed: () async {
await ImageController().choosImage(AppLink.uploadEgypt,
'idbackEmployee', controller.id);
@@ -360,20 +343,20 @@ class _EmployeeFormScreen extends StatelessWidget {
),
const SizedBox(height: 24),
_buildModernTextField(
controller.name, "الاسم الكامل", Icons.person, inputColor),
controller.name, "الاسم الكامل", Icons.person, cs),
const SizedBox(height: 16),
_buildModernTextField(
controller.phone, "رقم الهاتف", Icons.phone, inputColor,
controller.phone, "رقم الهاتف", Icons.phone, cs,
type: TextInputType.phone),
const SizedBox(height: 16),
_buildModernTextField(controller.education, "التعليم / الملاحظات",
Icons.school, inputColor),
Icons.school, cs),
const SizedBox(height: 16),
_buildModernTextField(controller.site, "الموقع / العنوان",
Icons.location_on, inputColor),
Icons.location_on, cs),
const SizedBox(height: 16),
_buildModernTextField(controller.status, "الحالة (مثال: ممتاز)",
Icons.star, inputColor),
Icons.star, cs),
const SizedBox(height: 32),
SizedBox(
width: double.infinity,
@@ -385,14 +368,14 @@ class _EmployeeFormScreen extends StatelessWidget {
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF6366F1),
backgroundColor: cs.primary,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
),
child: const Text("حفظ البيانات",
child: Text("حفظ البيانات",
style: TextStyle(
color: Colors.white,
color: cs.onPrimary,
fontSize: 16,
fontWeight: FontWeight.bold)),
),
@@ -405,23 +388,23 @@ class _EmployeeFormScreen extends StatelessWidget {
}
Widget _buildModernTextField(TextEditingController controller, String hint,
IconData icon, Color fillColor,
IconData icon, ColorScheme cs,
{TextInputType type = TextInputType.text}) {
return Container(
decoration: BoxDecoration(
color: fillColor,
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.white.withOpacity(0.1)),
border: Border.all(color: cs.outline.withValues(alpha: 0.1)),
),
child: TextFormField(
controller: controller,
keyboardType: type,
style: const TextStyle(color: Colors.white),
maxLines: null, // السماح بتعدد الأسطر عند الإدخال أيضاً
style: TextStyle(color: cs.onSurface),
maxLines: null,
decoration: InputDecoration(
labelText: hint,
labelStyle: TextStyle(color: Colors.white.withOpacity(0.5)),
prefixIcon: Icon(icon, color: Colors.white38, size: 20),
labelStyle: TextStyle(color: cs.onSurface.withValues(alpha: 0.5)),
prefixIcon: Icon(icon, color: cs.onSurfaceVariant, size: 20),
border: InputBorder.none,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
@@ -437,9 +420,10 @@ class _UploadButton extends StatelessWidget {
final String title;
final IconData icon;
final VoidCallback onPressed;
final ColorScheme cs;
const _UploadButton(
{required this.title, required this.icon, required this.onPressed});
{required this.title, required this.icon, required this.onPressed, required this.cs});
@override
Widget build(BuildContext context) {
@@ -449,21 +433,21 @@ class _UploadButton extends StatelessWidget {
child: Container(
padding: const EdgeInsets.symmetric(vertical: 20),
decoration: BoxDecoration(
color: const Color(0xFF1A1F3A),
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: const Color(0xFF6366F1).withOpacity(0.3),
color: cs.primary.withValues(alpha: 0.3),
style: BorderStyle.solid),
),
child: Column(
children: [
Icon(icon, color: const Color(0xFF6366F1), size: 30),
Icon(icon, color: cs.primary, size: 30),
const SizedBox(height: 8),
Text(title,
style: const TextStyle(color: Colors.white70, fontSize: 12)),
style: TextStyle(color: cs.onSurface.withValues(alpha: 0.7), fontSize: 12)),
const SizedBox(height: 4),
const Text("اضغط للرفع",
style: TextStyle(color: Colors.white38, fontSize: 10)),
Text("اضغط للرفع",
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 10)),
],
),
),
@@ -471,22 +455,21 @@ class _UploadButton extends StatelessWidget {
}
}
// === شاشة التفاصيل ===
class EmployeeDetails extends StatelessWidget {
final int index;
const EmployeeDetails({super.key, required this.index});
@override
Widget build(BuildContext context) {
const Color bgColor = Color(0xFF0A0E27);
final cs = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: bgColor,
backgroundColor: cs.surface,
appBar: AppBar(
title:
const Text('تفاصيل الموظف', style: TextStyle(color: Colors.white)),
backgroundColor: bgColor,
iconTheme: const IconThemeData(color: Colors.white),
Text('تفاصيل الموظف', style: TextStyle(color: cs.onSurface)),
backgroundColor: cs.surface,
iconTheme: IconThemeData(color: cs.onSurface),
elevation: 0,
),
body: GetBuilder<EmployeeController>(
@@ -497,24 +480,26 @@ class EmployeeDetails extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text("الهوية الأمامية",
Text("الهوية الأمامية",
style: TextStyle(
color: Colors.white,
color: cs.onSurface,
fontSize: 16,
fontWeight: FontWeight.bold)),
const SizedBox(height: 10),
_buildImageViewer(
'${AppLink.server}/card_image/idFrontEmployee-$employeeId.jpg',
cs,
),
const SizedBox(height: 30),
const Text("الهوية الخلفية",
Text("الهوية الخلفية",
style: TextStyle(
color: Colors.white,
color: cs.onSurface,
fontSize: 16,
fontWeight: FontWeight.bold)),
const SizedBox(height: 10),
_buildImageViewer(
'${AppLink.server}/card_image/idbackEmployee-$employeeId.jpg',
cs,
),
],
),
@@ -524,14 +509,14 @@ class EmployeeDetails extends StatelessWidget {
);
}
Widget _buildImageViewer(String url) {
Widget _buildImageViewer(String url, ColorScheme cs) {
return Container(
width: double.infinity,
height: 220,
decoration: BoxDecoration(
color: const Color(0xFF1A1F3A),
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.white.withOpacity(0.1)),
border: Border.all(color: cs.outline.withValues(alpha: 0.1)),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
@@ -539,23 +524,23 @@ class EmployeeDetails extends StatelessWidget {
url,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return const Center(
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.broken_image_rounded,
color: Colors.white24, size: 50),
SizedBox(height: 8),
color: cs.onSurface.withValues(alpha: 0.24), size: 50),
const SizedBox(height: 8),
Text("فشل تحميل الصورة",
style: TextStyle(color: Colors.white24)),
style: TextStyle(color: cs.onSurface.withValues(alpha: 0.24))),
],
),
);
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return const Center(
child: CircularProgressIndicator(color: Color(0xFF6366F1)));
return Center(
child: CircularProgressIndicator(color: cs.primary));
},
),
),