إصلاح توافق فلاتر مع Theme الجديد
This commit is contained in:
@@ -3,23 +3,20 @@ import 'package:get/get.dart';
|
||||
import '../../../controller/admin/staff_controller.dart';
|
||||
|
||||
class AddStaffPage extends StatelessWidget {
|
||||
final String role; // 'admin' or 'service'
|
||||
final String role;
|
||||
const AddStaffPage({super.key, required this.role});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = Get.put(StaffController());
|
||||
controller.selectedRole = role;
|
||||
|
||||
const Color bgColor = Color(0xFF0D1117);
|
||||
const Color inputColor = Color(0xFF161B22);
|
||||
const Color accentColor = Color(0xFF00D4AA);
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: bgColor,
|
||||
backgroundColor: cs.surface,
|
||||
appBar: AppBar(
|
||||
title: Text(role == 'admin' ? "إضافة مدير جديد" : "إضافة موظف خدمة عملاء"),
|
||||
backgroundColor: bgColor,
|
||||
backgroundColor: cs.surface,
|
||||
elevation: 0,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
@@ -29,20 +26,20 @@ class AddStaffPage extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildSectionTitle("المعلومات الأساسية"),
|
||||
_buildSectionTitle("المعلومات الأساسية", cs),
|
||||
const SizedBox(height: 16),
|
||||
_buildTextField(
|
||||
controller: controller.nameController,
|
||||
label: "الاسم الكامل",
|
||||
icon: Icons.person_outline,
|
||||
fillColor: inputColor,
|
||||
cs: cs,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTextField(
|
||||
controller: controller.phoneController,
|
||||
label: "رقم الهاتف",
|
||||
icon: Icons.phone_android_outlined,
|
||||
fillColor: inputColor,
|
||||
cs: cs,
|
||||
keyboardType: TextInputType.phone,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -50,7 +47,7 @@ class AddStaffPage extends StatelessWidget {
|
||||
controller: controller.emailController,
|
||||
label: "البريد الإلكتروني",
|
||||
icon: Icons.email_outlined,
|
||||
fillColor: inputColor,
|
||||
cs: cs,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -58,11 +55,11 @@ class AddStaffPage extends StatelessWidget {
|
||||
controller: controller.passwordController,
|
||||
label: "كلمة المرور",
|
||||
icon: Icons.lock_outline,
|
||||
fillColor: inputColor,
|
||||
cs: cs,
|
||||
obscureText: true,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
_buildSectionTitle("معلومات إضافية"),
|
||||
_buildSectionTitle("معلومات إضافية", cs),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
@@ -72,7 +69,7 @@ class AddStaffPage extends StatelessWidget {
|
||||
value: controller.selectedGender,
|
||||
items: ['Male', 'Female'],
|
||||
onChanged: (val) => controller.selectedGender = val!,
|
||||
fillColor: inputColor,
|
||||
cs: cs,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
@@ -81,7 +78,7 @@ class AddStaffPage extends StatelessWidget {
|
||||
controller: controller.birthdateController,
|
||||
label: "تاريخ الميلاد",
|
||||
icon: Icons.calendar_today_outlined,
|
||||
fillColor: inputColor,
|
||||
cs: cs,
|
||||
hint: "YYYY-MM-DD",
|
||||
),
|
||||
),
|
||||
@@ -93,7 +90,7 @@ class AddStaffPage extends StatelessWidget {
|
||||
value: controller.selectedCountry,
|
||||
items: const ['Jordan', 'Syria', 'Egypt'],
|
||||
onChanged: (val) => controller.selectedCountry = val!,
|
||||
fillColor: inputColor,
|
||||
cs: cs,
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
GetBuilder<StaffController>(
|
||||
@@ -103,17 +100,17 @@ class AddStaffPage extends StatelessWidget {
|
||||
child: ElevatedButton(
|
||||
onPressed: controller.isLoading ? null : () => controller.registerStaff(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: accentColor,
|
||||
backgroundColor: cs.primary,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
child: controller.isLoading
|
||||
? const CircularProgressIndicator(color: Colors.white)
|
||||
? CircularProgressIndicator(color: cs.onPrimary)
|
||||
: Text(
|
||||
"حفظ البيانات",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: bgColor,
|
||||
color: cs.onPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -126,11 +123,11 @@ class AddStaffPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
Widget _buildSectionTitle(String title, ColorScheme cs) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF7D8590),
|
||||
style: TextStyle(
|
||||
color: cs.onSurfaceVariant,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 1.2,
|
||||
@@ -142,28 +139,28 @@ class AddStaffPage extends StatelessWidget {
|
||||
required TextEditingController controller,
|
||||
required String label,
|
||||
required IconData icon,
|
||||
required Color fillColor,
|
||||
required ColorScheme cs,
|
||||
String? hint,
|
||||
bool obscureText = false,
|
||||
TextInputType keyboardType = TextInputType.text,
|
||||
}) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: fillColor,
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
border: Border.all(color: cs.outline.withValues(alpha: 0.1)),
|
||||
),
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
obscureText: obscureText,
|
||||
keyboardType: keyboardType,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
style: TextStyle(color: cs.onSurface),
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
hintText: hint,
|
||||
hintStyle: const TextStyle(color: Colors.white24),
|
||||
labelStyle: const TextStyle(color: Colors.white54),
|
||||
prefixIcon: Icon(icon, color: Colors.white38),
|
||||
hintStyle: TextStyle(color: cs.onSurface.withValues(alpha: 0.24)),
|
||||
labelStyle: TextStyle(color: cs.onSurfaceVariant),
|
||||
prefixIcon: Icon(icon, color: cs.onSurfaceVariant),
|
||||
border: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
),
|
||||
@@ -177,22 +174,22 @@ class AddStaffPage extends StatelessWidget {
|
||||
required String value,
|
||||
required List<String> items,
|
||||
required Function(String?) onChanged,
|
||||
required Color fillColor,
|
||||
required ColorScheme cs,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: fillColor,
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
border: Border.all(color: cs.outline.withValues(alpha: 0.1)),
|
||||
),
|
||||
child: DropdownButtonFormField<String>(
|
||||
initialValue: value,
|
||||
dropdownColor: fillColor,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
dropdownColor: cs.surfaceContainerHighest,
|
||||
style: TextStyle(color: cs.onSurface),
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
labelStyle: const TextStyle(color: Colors.white54),
|
||||
labelStyle: TextStyle(color: cs.onSurfaceVariant),
|
||||
border: InputBorder.none,
|
||||
),
|
||||
items: items.map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(),
|
||||
|
||||
@@ -50,7 +50,7 @@ class _PendingAdminsPageState extends State<PendingAdminsPage> {
|
||||
);
|
||||
if (response != 'failure') {
|
||||
mySnackbarSuccess('تم تنفيذ الإجراء بنجاح');
|
||||
_fetchPendingAdmins(); // تحديث القائمة
|
||||
_fetchPendingAdmins();
|
||||
}
|
||||
} catch (e) {
|
||||
mySnackbarError('حدث خطأ: $e');
|
||||
@@ -59,35 +59,37 @@ class _PendingAdminsPageState extends State<PendingAdminsPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF0A0D14),
|
||||
backgroundColor: cs.surface,
|
||||
appBar: AppBar(
|
||||
title: const Text('طلبات الانضمام المعلقة', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
backgroundColor: const Color(0xFF161D2E),
|
||||
backgroundColor: cs.surfaceContainerHighest,
|
||||
elevation: 0,
|
||||
),
|
||||
body: _isLoading
|
||||
? const Center(child: CircularProgressIndicator(color: Color(0xFF00E5FF)))
|
||||
? Center(child: CircularProgressIndicator(color: cs.primary))
|
||||
: _pendingAdmins.isEmpty
|
||||
? _buildEmptyState()
|
||||
: _buildList(),
|
||||
? _buildEmptyState(cs)
|
||||
: _buildList(cs),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmptyState() {
|
||||
Widget _buildEmptyState(ColorScheme cs) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.person_search_rounded, size: 80, color: Colors.grey[800]),
|
||||
Icon(Icons.person_search_rounded, size: 80, color: cs.outline),
|
||||
const SizedBox(height: 16),
|
||||
const Text('لا توجد طلبات معلقة حالياً', style: TextStyle(color: Colors.grey)),
|
||||
Text('لا توجد طلبات معلقة حالياً', style: TextStyle(color: cs.onSurfaceVariant)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildList() {
|
||||
Widget _buildList(ColorScheme cs) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: _pendingAdmins.length,
|
||||
@@ -97,40 +99,40 @@ class _PendingAdminsPageState extends State<PendingAdminsPage> {
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF161D2E),
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: const Color(0xFF1F2D4A)),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const CircleAvatar(
|
||||
backgroundColor: Color(0xFF1F2D4A),
|
||||
child: Icon(Icons.person, color: Color(0xFF00E5FF)),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: cs.outline,
|
||||
child: Icon(Icons.person, color: cs.primary),
|
||||
),
|
||||
title: Text(admin['name'] ?? 'بدون اسم', style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||
subtitle: Text(admin['phone'] ?? 'بدون رقم', style: const TextStyle(color: Colors.grey)),
|
||||
title: Text(admin['name'] ?? 'بدون اسم', style: TextStyle(color: cs.onSurface, fontWeight: FontWeight.bold)),
|
||||
subtitle: Text(admin['phone'] ?? 'بدون رقم', style: TextStyle(color: cs.onSurfaceVariant)),
|
||||
trailing: Text(
|
||||
admin['created_at']?.split(' ')[0] ?? '',
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 12),
|
||||
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 12),
|
||||
),
|
||||
),
|
||||
const Divider(color: Color(0xFF1F2D4A), height: 24),
|
||||
Divider(color: cs.outline, height: 24),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => _handleAction(admin['id'], 'rejected'),
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.redAccent),
|
||||
style: TextButton.styleFrom(foregroundColor: cs.error),
|
||||
child: const Text('رفض'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ElevatedButton(
|
||||
onPressed: () => _handleAction(admin['id'], 'approved'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF00E5FF),
|
||||
foregroundColor: Colors.black,
|
||||
backgroundColor: cs.primary,
|
||||
foregroundColor: cs.onPrimary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user