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,216 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../views/widgets/snackbar.dart';
|
||||
import 'firebase/notification_service.dart';
|
||||
|
||||
class NotificationController extends GetxController {
|
||||
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
final TextEditingController titleController = TextEditingController();
|
||||
final TextEditingController bodyController = TextEditingController();
|
||||
|
||||
// ألوان الثيم (متناسقة مع باقي الصفحات المحسنة)
|
||||
final Color _dialogColor = const Color(0xFF1A1F3A);
|
||||
final Color _inputColor = const Color(0xFF0A0E27);
|
||||
final Color _primaryAccent = const Color(0xFF6366F1);
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
titleController.dispose();
|
||||
bodyController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
/// تنظيف الحقول
|
||||
void _clearFields() {
|
||||
titleController.clear();
|
||||
bodyController.clear();
|
||||
}
|
||||
|
||||
/// إرسال إشعار للسائقين
|
||||
Future<void> sendNotificationDrivers() async {
|
||||
_clearFields();
|
||||
await _showCustomDialog(
|
||||
dialogTitle: 'إشعار للسائقين',
|
||||
targetAudience: 'drivers',
|
||||
icon: Icons.drive_eta_rounded,
|
||||
iconColor: Colors.orangeAccent,
|
||||
);
|
||||
}
|
||||
|
||||
/// إرسال إشعار للركاب
|
||||
Future<void> sendNotificationPassengers() async {
|
||||
_clearFields();
|
||||
await _showCustomDialog(
|
||||
dialogTitle: 'إشعار للركاب',
|
||||
targetAudience: 'passengers',
|
||||
icon: Icons.people_alt_rounded,
|
||||
iconColor: Colors.blueAccent,
|
||||
);
|
||||
}
|
||||
|
||||
/// دالة عامة لإظهار نافذة الإرسال بتصميم عصري
|
||||
Future<void> _showCustomDialog({
|
||||
required String dialogTitle,
|
||||
required String targetAudience,
|
||||
required IconData icon,
|
||||
required Color iconColor,
|
||||
}) {
|
||||
return Get.dialog(
|
||||
Dialog(
|
||||
backgroundColor: _dialogColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
elevation: 10,
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Form(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 1. أيقونة العنوان
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: iconColor.withOpacity(0.15),
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: iconColor.withOpacity(0.1),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(icon, color: iconColor, size: 32),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 2. العنوان
|
||||
Text(
|
||||
dialogTitle,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Segoe UI',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 3. حقول الإدخال
|
||||
_buildModernTextField(
|
||||
controller: titleController,
|
||||
hint: 'عنوان الإشعار',
|
||||
icon: Icons.title_rounded,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildModernTextField(
|
||||
controller: bodyController,
|
||||
hint: 'نص الرسالة',
|
||||
icon: Icons.message_rounded,
|
||||
maxLines: 3,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// 4. الأزرار
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Colors.white54,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
child: const Text('إلغاء'),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
if (titleController.text.trim().isEmpty ||
|
||||
bodyController.text.trim().isEmpty) {
|
||||
mySnackbarWarning("الرجاء تعبئة جميع الحقول");
|
||||
return;
|
||||
}
|
||||
|
||||
Get.back(); // إغلاق النافذة
|
||||
await _processSending(targetAudience);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _primaryAccent,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
elevation: 0,
|
||||
),
|
||||
child: const Text('إرسال'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
barrierColor: Colors.black.withOpacity(0.7), // تعتيم الخلفية
|
||||
);
|
||||
}
|
||||
|
||||
/// تنفيذ عملية الإرسال الفعلية
|
||||
Future<void> _processSending(String target) async {
|
||||
// إظهار تنبيه بدء العملية
|
||||
mySnackbarInfo("يتم إرسال الإشعار لـ $target...");
|
||||
|
||||
try {
|
||||
// استدعاء خدمة الإرسال
|
||||
await NotificationService.sendNotification(
|
||||
target: target,
|
||||
title: titleController.text,
|
||||
body: bodyController.text,
|
||||
isTopic: true,
|
||||
category: 'fromAdmin',
|
||||
);
|
||||
|
||||
mySnackbarSuccess("تم إرسال الإشعار بنجاح");
|
||||
} catch (e) {
|
||||
mySnackbarError("فشل إرسال الإشعار: $e");
|
||||
}
|
||||
}
|
||||
|
||||
/// تصميم حقل الإدخال المخصص (Dark Input Field)
|
||||
Widget _buildModernTextField({
|
||||
required TextEditingController controller,
|
||||
required String hint,
|
||||
required IconData icon,
|
||||
int maxLines = 1,
|
||||
}) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: _inputColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.1)),
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
maxLines: maxLines,
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
hintStyle:
|
||||
TextStyle(color: Colors.white.withOpacity(0.3), fontSize: 14),
|
||||
prefixIcon: Icon(icon, color: Colors.white38, size: 20),
|
||||
border: InputBorder.none,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user