chore: استيراد أولي من سيرو (ecfe7568) — بلا أي تعديل
نسخة كاملة من مستودع سيرو عند ecfe7568 لتكون أساس تطبيق «انطلق». نُسخ المتعقَّب في git فقط (12,509 ملفاً / 302 م.ب) بـ git archive، لا `cp -r` — فاستُثنيت تلقائياً مخلفات البناء (build · node_modules · .dart_tool · .gradle · Pods ≈ 10.7 غ.ب) وكل ما يستثنيه .gitignore. هذا الكوميت **بلا أي تعديل عمداً** حتى يكون كل ما يليه فرقاً مقروءاً مقابل سيرو الأصلي. سيرو نفسه لم يُمسّ. ⚠️ لا يبني بعد: `.env` و`lib/env/env.g.dart` غير متعقَّبين في سيرو (وهذا صحيح — أسرار لكل مستأجر). كل تطبيق فلاتر هنا يحتاج .env خاصاً بانطلق ثم توليد env.g.dart عبر build_runner. لا تُنسخ أسرار سيرو. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,328 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../controller/admin/complaint_controller.dart';
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
import '../../widgets/my_textField.dart';
|
||||
|
||||
class ComplaintListPage extends StatelessWidget {
|
||||
ComplaintListPage({super.key});
|
||||
|
||||
final ComplaintController controller = Get.put(ComplaintController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: cs.surface,
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(16, 50, 16, 16),
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.back(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: Icon(Icons.arrow_back_ios_new_rounded,
|
||||
color: cs.onSurfaceVariant, size: 16),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text('إدارة الشكاوى'.tr,
|
||||
style: TextStyle(
|
||||
color: cs.onSurface,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Obx(() {
|
||||
if (controller.delayedComplaints.isNotEmpty) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.error.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: cs.error.withValues(alpha: 0.3)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.warning_amber_rounded, color: cs.error),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'هناك ${controller.delayedComplaints.length} شكاوى لم يتم حلها منذ أكثر من أسبوع!',
|
||||
style: GoogleFonts.inter(color: cs.error, fontSize: 14, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Obx(() => MyElevatedButton(
|
||||
title: controller.showOnlyDelayed.value ? 'عرض جميع الشكاوى' : 'عرض الشكاوى المتأخرة فقط',
|
||||
onPressed: () => controller.showOnlyDelayed.toggle(),
|
||||
kolor: cs.error,
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
}),
|
||||
Expanded(
|
||||
child: Obx(() {
|
||||
final list = controller.showOnlyDelayed.value ? controller.delayedComplaints : controller.complaintList;
|
||||
if (controller.isLoading.value && list.isEmpty) {
|
||||
return Center(child: CircularProgressIndicator(color: cs.primary));
|
||||
}
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => controller.getComplaints(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 80),
|
||||
itemCount: list.length,
|
||||
itemBuilder: (context, index) {
|
||||
final complaint = list[index];
|
||||
return _buildComplaintCard(context, complaint);
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildComplaintCard(BuildContext context, dynamic c) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
Color statusColor = _getStatusColor(c['statusComplaint'], cs);
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: ExpansionTile(
|
||||
tilePadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
leading: _buildStatusIndicator(c['statusComplaint'], statusColor, cs),
|
||||
title: Text(
|
||||
c['description']?.toString() ?? 'بدون وصف',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.inter(fontWeight: FontWeight.w600, color: cs.onSurface),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'النوع: ${c['complaint_type'] ?? 'عام'} | الرحلة: ${c['ride_id']}',
|
||||
style: GoogleFonts.inter(color: cs.onSurfaceVariant, fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.person_rounded, size: 12, color: cs.onSurfaceVariant),
|
||||
const SizedBox(width: 4),
|
||||
Text(c['passengerName'] ?? 'غير معروف', style: GoogleFonts.inter(color: cs.onSurfaceVariant, fontSize: 12)),
|
||||
const SizedBox(width: 12),
|
||||
Icon(Icons.drive_eta_rounded, size: 12, color: cs.onSurfaceVariant),
|
||||
const SizedBox(width: 4),
|
||||
Text(c['driverName'] ?? 'غير معروف', style: GoogleFonts.inter(color: cs.onSurfaceVariant, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Divider(color: cs.outline),
|
||||
_buildInfoRow('الوصف', c['description'] ?? 'لا يوجد وصف', cs),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow('الحل الحالي', c['resolution'] ?? 'لم يتم الحل بعد', cs),
|
||||
const SizedBox(height: 12),
|
||||
_buildRideDetails(c, cs),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: MyElevatedButton(
|
||||
title: 'تحديث الحالة / حل الشكوى',
|
||||
onPressed: () => _showResolveDialog(context, c),
|
||||
kolor: cs.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusIndicator(String? status, Color color, ColorScheme cs) {
|
||||
return Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.12),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: color.withValues(alpha: 0.25)),
|
||||
),
|
||||
child: Icon(
|
||||
status == 'Resolved' ? Icons.check_circle_rounded : Icons.pending_rounded,
|
||||
color: color,
|
||||
size: 20,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow(String label, String value, ColorScheme cs) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label, style: GoogleFonts.inter(color: cs.primary, fontSize: 12)),
|
||||
const SizedBox(height: 4),
|
||||
Text(value, style: GoogleFonts.inter(color: cs.onSurface, fontSize: 14)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRideDetails(dynamic c, ColorScheme cs) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildSmallStat('السعر', '${c['priceOfRide']} ل.س', cs),
|
||||
_buildSmallStat('التقييم', '${c['avgRatingDriverFromPassengers'] ?? 0}★', cs),
|
||||
_buildSmallStat('النوع', c['ascarType'] ?? 'N/A', cs),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSmallStat(String label, String value, ColorScheme cs) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(label, style: GoogleFonts.inter(color: cs.onSurfaceVariant, fontSize: 10)),
|
||||
const SizedBox(height: 2),
|
||||
Text(value, style: GoogleFonts.jetBrainsMono(fontWeight: FontWeight.bold, fontSize: 12, color: cs.onSurface)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Color _getStatusColor(String? status, ColorScheme cs) {
|
||||
switch (status) {
|
||||
case 'Open': return cs.error;
|
||||
case 'In Progress': return cs.tertiary;
|
||||
case 'Resolved': return const Color(0xFF10B981);
|
||||
default: return cs.onSurfaceVariant;
|
||||
}
|
||||
}
|
||||
|
||||
void _showResolveDialog(BuildContext context, dynamic c) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
final TextEditingController resController = TextEditingController(text: c['resolution']);
|
||||
String selectedStatus = c['statusComplaint'] ?? 'Open';
|
||||
|
||||
Get.bottomSheet(
|
||||
StatefulBuilder(
|
||||
builder: (context, setModalState) => Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text('تحديث حالة الشكوى', style: GoogleFonts.cairo(fontWeight: FontWeight.bold, color: cs.onSurface, fontSize: 18)),
|
||||
const SizedBox(height: 20),
|
||||
_buildStatusDropdown(selectedStatus, cs, (val) {
|
||||
setModalState(() => selectedStatus = val!);
|
||||
}),
|
||||
const SizedBox(height: 20),
|
||||
MyTextForm(
|
||||
controller: resController,
|
||||
label: 'قرار الحل / الملاحظات',
|
||||
hint: 'اكتب تفاصيل الحل هنا...',
|
||||
type: TextInputType.multiline,
|
||||
prefixIcon: Icons.gavel_rounded,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
MyElevatedButton(
|
||||
title: 'حفظ التحديث',
|
||||
onPressed: () async {
|
||||
bool success = await controller.updateComplaintStatus(
|
||||
c['id'].toString(),
|
||||
selectedStatus,
|
||||
resController.text
|
||||
);
|
||||
if (success) Get.back();
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
isScrollControlled: true,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusDropdown(String current, ColorScheme cs, Function(String?) onChanged) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
value: current,
|
||||
isExpanded: true,
|
||||
dropdownColor: cs.surfaceContainerHighest,
|
||||
items: ['Open', 'In Progress', 'Resolved']
|
||||
.map((s) => DropdownMenuItem(value: s, child: Text(s.tr, style: GoogleFonts.inter(color: cs.onSurface, fontSize: 14))))
|
||||
.toList(),
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user