Deploy: 2026-05-24 23:27:32
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../data/models/plan_model.dart';
|
||||
|
||||
class BillingView extends StatelessWidget {
|
||||
final List<PlanModel> plans;
|
||||
|
||||
const BillingView({
|
||||
super.key,
|
||||
required this.plans,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'💳 الباقات والاشتراكات',
|
||||
style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'اختر الباقة المناسبة لاحتياجات شركتك لتفعيل ميزات الردود التلقائية غير المحدودة.',
|
||||
style: TextStyle(color: Colors.white60, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// English: Render list of subscription plan cards.
|
||||
// Arabic: عرض قائمة ببطاقات خطط الاشتراك المتاحة.
|
||||
if (plans.isEmpty)
|
||||
const Center(
|
||||
child: Text(
|
||||
'لا توجد باقات متاحة حالياً.',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
)
|
||||
else
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: plans.length,
|
||||
itemBuilder: (context, index) {
|
||||
final plan = plans[index];
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF15102A),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
plan.name,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
'الدفع شهرياً - إلغاء في أي وقت',
|
||||
style: TextStyle(color: Colors.white60, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'\$${plan.price.toStringAsFixed(2)}',
|
||||
style: const TextStyle(
|
||||
color: Colors.purpleAccent,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'/شهرياً',
|
||||
style: TextStyle(color: Colors.white60, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../data/models/chatbot_rule_model.dart';
|
||||
|
||||
class ChatbotView extends StatelessWidget {
|
||||
final List<ChatbotRuleModel> rules;
|
||||
|
||||
const ChatbotView({
|
||||
super.key,
|
||||
required this.rules,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'🤖 قواعد الرد الآلي للدردشة',
|
||||
style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'إدارة قواعد الذكاء الاصطناعي والكلمات المفتاحية المخصصة لتلقي ومعالجة المحادثات الواردة.',
|
||||
style: TextStyle(color: Colors.white60, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// English: Render list of chatbot rule cards.
|
||||
// Arabic: عرض قائمة ببطاقات قواعد روبوت الدردشة المكونة.
|
||||
if (rules.isEmpty)
|
||||
const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 40.0),
|
||||
child: Text(
|
||||
'لم يتم تكوين قواعد رد آلي بعد.',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: rules.length,
|
||||
itemBuilder: (context, index) {
|
||||
final rule = rules[index];
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF15102A),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildTriggerBadge(rule.triggerType),
|
||||
_buildStatusBadge(rule.isActive),
|
||||
],
|
||||
),
|
||||
const Divider(color: Colors.white10, height: 24),
|
||||
if (rule.triggerType == 'keyword' && rule.keyword != null) ...[
|
||||
const Text(
|
||||
'الكلمة المفتاحية للمشغل:',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
rule.keyword!,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
const Text(
|
||||
'رد الروبوت أو تعليمات موجه الذكاء الاصطناعي (AI Prompt):',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
rule.aiPrompt ?? 'لا توجد تعليمات',
|
||||
style: TextStyle(color: Colors.white.withOpacity(0.8), fontSize: 13, height: 1.4),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTriggerBadge(String type) {
|
||||
final isAi = type == 'gemini_ai';
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: isAi ? Colors.purpleAccent.withOpacity(0.2) : Colors.blue.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: isAi ? Colors.purpleAccent : Colors.blue),
|
||||
),
|
||||
child: Text(
|
||||
isAi ? '🧠 ذكاء اصطناعي (Gemini)' : '⌨️ كلمات مفتاحية',
|
||||
style: TextStyle(color: isAi ? Colors.purpleAccent : Colors.blue, fontSize: 11, fontWeight: FontWeight.bold),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusBadge(bool isActive) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: isActive ? Colors.green.withOpacity(0.2) : Colors.grey.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: isActive ? Colors.green : Colors.grey),
|
||||
),
|
||||
child: Text(
|
||||
isActive ? 'نشط' : 'غير نشط',
|
||||
style: TextStyle(color: isActive ? Colors.green : Colors.grey, fontSize: 10, fontWeight: FontWeight.bold),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/models/contact_model.dart';
|
||||
import '../cubit/dashboard_cubit.dart';
|
||||
import '../screens/add_contact_screen.dart';
|
||||
|
||||
class ContactsView extends StatelessWidget {
|
||||
final List<ContactModel> contacts;
|
||||
|
||||
const ContactsView({
|
||||
super.key,
|
||||
required this.contacts,
|
||||
});
|
||||
|
||||
// English: Show alert confirmation dialog before navigating.
|
||||
// Arabic: عرض مربع حوار تأكيدي قبل الانتقال إلى الشاشة التالية.
|
||||
void _showNavigationDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
backgroundColor: const Color(0xFF15102A),
|
||||
title: const Text('إضافة جهة اتصال جديدة', style: TextStyle(color: Colors.white)),
|
||||
content: const Text(
|
||||
'هل تريد الانتقال لصفحة إضافة جهة اتصال جديدة لتعبئة البيانات؟',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: const Text('إلغاء', style: TextStyle(color: Colors.white60)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// English: Pop dialog window first.
|
||||
// Arabic: إغلاق مربع الحوار أولاً.
|
||||
Navigator.pop(dialogContext);
|
||||
|
||||
// English: Push AddContactScreen, sharing the existing Cubit instance.
|
||||
// Arabic: الانتقال إلى شاشة إضافة جهة اتصال ومشاركة نفس الكيوبيت الحالي.
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BlocProvider.value(
|
||||
value: context.read<DashboardCubit>(),
|
||||
child: const AddContactScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('نعم، انتقل', style: TextStyle(color: Colors.purpleAccent)),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'👥 دليل جهات الاتصال',
|
||||
style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.purpleAccent,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
),
|
||||
icon: const Icon(Icons.add, color: Colors.white, size: 16),
|
||||
label: const Text(
|
||||
'إضافة جهة',
|
||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||
),
|
||||
onPressed: () => _showNavigationDialog(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'عرض وإدارة دليل العملاء والجهات التي تواصلت مع النظام الآلي.',
|
||||
style: TextStyle(color: Colors.white60, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// English: Render list of parsed contacts in custom list view.
|
||||
// Arabic: عرض قائمة بجهات الاتصال المحللة في طريقة عرض القائمة المخصصة.
|
||||
if (contacts.isEmpty)
|
||||
const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 40.0),
|
||||
child: Text(
|
||||
'دليل جهات الاتصال فارغ حالياً.',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: contacts.length,
|
||||
itemBuilder: (context, index) {
|
||||
final contact = contacts[index];
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF15102A),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.purpleAccent.withOpacity(0.1),
|
||||
),
|
||||
child: const Icon(Icons.person, color: Colors.purpleAccent),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
contact.name,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
contact.phone,
|
||||
style: const TextStyle(color: Colors.purpleAccent, fontSize: 13),
|
||||
),
|
||||
if (contact.notes != null && contact.notes!.isNotEmpty) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
contact.notes!,
|
||||
style: TextStyle(color: Colors.white.withOpacity(0.5), fontSize: 12),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SimplePlaceholderView extends StatelessWidget {
|
||||
final String title;
|
||||
final String description;
|
||||
final IconData icon;
|
||||
|
||||
const SimplePlaceholderView({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// English: Placeholders mimic undeveloped features in standard premium dark cards.
|
||||
// Arabic: تحاكي شاشات الحجز الميزات التي لم يتم تطويرها في بطاقات داكنة مميزة قياسية.
|
||||
return Center(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(20),
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF15102A),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 64, color: Colors.purpleAccent),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
description,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.6),
|
||||
fontSize: 14,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/models/super_admin_stats_model.dart';
|
||||
import '../cubit/dashboard_cubit.dart';
|
||||
|
||||
class SuperAdminView extends StatelessWidget {
|
||||
final SuperAdminStatsModel? stats;
|
||||
|
||||
const SuperAdminView({
|
||||
super.key,
|
||||
required this.stats,
|
||||
});
|
||||
|
||||
// English: Show a confirmation dialog before approving company billing subscription.
|
||||
// Arabic: عرض مربع حوار تأكيدي للموافقة على ترقية الفوترة والاشتراك.
|
||||
void _showApproveDialog(BuildContext context, int companyId, String companyName) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
backgroundColor: const Color(0xFF15102A),
|
||||
title: const Text('الموافقة على الاشتراك', style: TextStyle(color: Colors.white)),
|
||||
content: Text(
|
||||
'هل أنت متأكد من تفعيل اشتراك شركة "$companyName"؟ سيتم ترقية حسابهم على الفور.',
|
||||
style: const TextStyle(color: Colors.white70),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: const Text('إلغاء', style: TextStyle(color: Colors.white60)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(dialogContext);
|
||||
// English: Dispatch approveBilling command to DashboardCubit.
|
||||
// Arabic: استدعاء أمر الموافقة على الاشتراك في الكيوبيت.
|
||||
context.read<DashboardCubit>().approveBilling(companyId);
|
||||
},
|
||||
child: const Text('نعم، وافق', style: TextStyle(color: Colors.green)),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final model = stats;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'👑 لوحة تحكم المشرف العام',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'مراقبة إحصائيات منصة نبيه بالكامل وإدارة تراخيص الشركات وطلبات الترقية.',
|
||||
style: TextStyle(color: Colors.white60, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (model == null)
|
||||
const Center(
|
||||
child: Text(
|
||||
'فشل تحميل إحصائيات المشرف العام.',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
)
|
||||
else ...[
|
||||
// English: Stats widgets mirroring the web interface dashboard indicators.
|
||||
// Arabic: أدوات إحصائية تحاكي مؤشرات لوحة معلومات واجهة الويب.
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildMetricCard(
|
||||
'الشركات المسجلة',
|
||||
model.totalCompanies.toString(),
|
||||
Icons.business,
|
||||
Colors.purpleAccent,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildMetricCard(
|
||||
'جلسات الواتساب',
|
||||
'${model.connectedSessions}/${model.totalSessions}',
|
||||
Icons.phone_android,
|
||||
Colors.green,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// English: Display pending billing approval requests.
|
||||
// Arabic: عرض طلبات الموافقة على ترقية الباقات المعلقة.
|
||||
const Text(
|
||||
'طلبات الترقية المعلقة للموافقة',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
if (model.pendingApprovals.isEmpty)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.02),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.white12),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'لا توجد طلبات ترقية معلقة حالياً.',
|
||||
style: TextStyle(color: Colors.white60, fontSize: 13),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: model.pendingApprovals.length,
|
||||
itemBuilder: (context, index) {
|
||||
final company =
|
||||
model.pendingApprovals[index] as Map<String, dynamic>;
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1E1446),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.purpleAccent.withOpacity(0.3)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
company['name'] as String? ?? 'شركة غير معروفة',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'الباقة المطلوبة: ${company['plan_name'] ?? 'لا يوجد'}',
|
||||
style: const TextStyle(
|
||||
color: Colors.purpleAccent, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.green,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8)),
|
||||
),
|
||||
child: const Text('موافقة',
|
||||
style: TextStyle(fontSize: 12)),
|
||||
onPressed: () {
|
||||
_showApproveDialog(
|
||||
context,
|
||||
company['id'] as int? ?? 0,
|
||||
company['name'] as String? ?? 'الشركة',
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// English: Display list of SaaS Companies.
|
||||
// Arabic: عرض قائمة الشركات المسجلة وتفاصيل استخداماتها.
|
||||
const Text(
|
||||
'الشركات والعملاء المشتركين',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: model.companies.length,
|
||||
itemBuilder: (context, index) {
|
||||
final company = model.companies[index] as Map<String, dynamic>;
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF15102A),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
company['name'] as String? ?? 'شركة',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
_buildSubBadge(
|
||||
company['sub_status'] as String? ?? 'expired',
|
||||
company['plan_name'] as String?),
|
||||
],
|
||||
),
|
||||
const Divider(color: Colors.white10, height: 24),
|
||||
_buildDetailRow('الجلسات النشطة',
|
||||
'${company['active_sessions'] ?? 0}/${company['sessions_count'] ?? 0}'),
|
||||
const SizedBox(height: 8),
|
||||
// English: Display SaaS resource usages metrics (Requests, Voice, OCR).
|
||||
// Arabic: عرض مقاييس استخدام موارد النظام (الطلبات، الصوت، تحليل الصور).
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildUsageText('الطلبات',
|
||||
(company['request_usage'] ?? 0).toString()),
|
||||
_buildUsageText('الصوت',
|
||||
(company['voice_usage'] ?? 0).toString()),
|
||||
_buildUsageText(
|
||||
'OCR', (company['ocr_usage'] ?? 0).toString()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMetricCard(
|
||||
String title, String value, IconData icon, Color color) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF15102A),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(icon, color: color, size: 24),
|
||||
const SizedBox(height: 12),
|
||||
Text(title,
|
||||
style: const TextStyle(color: Colors.white60, fontSize: 12)),
|
||||
const SizedBox(height: 4),
|
||||
Text(value,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSubBadge(String status, String? planName) {
|
||||
final name = planName ?? 'لا توجد باقة';
|
||||
Color color = Colors.grey;
|
||||
if (status == 'active') {
|
||||
color = Colors.green;
|
||||
} else if (status == 'trialing') {
|
||||
color = Colors.blue;
|
||||
}
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: color),
|
||||
),
|
||||
child: Text(
|
||||
name,
|
||||
style:
|
||||
TextStyle(color: color, fontSize: 11, fontWeight: FontWeight.bold),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(String label, String value) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(label,
|
||||
style: const TextStyle(color: Colors.white60, fontSize: 13)),
|
||||
Text(value,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUsageText(String label, String value) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label,
|
||||
style: const TextStyle(color: Colors.white54, fontSize: 11)),
|
||||
const SizedBox(height: 2),
|
||||
Text(value,
|
||||
style: const TextStyle(
|
||||
color: Colors.purpleAccent,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/models/whatsapp_status_model.dart';
|
||||
import '../cubit/dashboard_cubit.dart';
|
||||
|
||||
class WhatsAppView extends StatelessWidget {
|
||||
final WhatsAppStatusModel? status;
|
||||
final VoidCallback onRefresh;
|
||||
|
||||
const WhatsAppView({
|
||||
super.key,
|
||||
required this.status,
|
||||
required this.onRefresh,
|
||||
});
|
||||
|
||||
// English: Show a confirmation dialog before disconnecting.
|
||||
// Arabic: عرض مربع حوار تأكيدي قبل قطع الاتصال لتجنب الإجراء المفاجئ.
|
||||
void _showDisconnectDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
backgroundColor: const Color(0xFF15102A),
|
||||
title: const Text('قطع اتصال الواتساب', style: TextStyle(color: Colors.white)),
|
||||
content: const Text(
|
||||
'هل أنت متأكد من رغبتك في قطع الاتصال؟ سيؤدي ذلك إلى تعطيل روبوت خدمة العملاء والردود التلقائية.',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: const Text('إلغاء', style: TextStyle(color: Colors.white60)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(dialogContext);
|
||||
// English: Dispatch disconnectWhatsApp command to DashboardCubit.
|
||||
// Arabic: استدعاء أمر قطع اتصال الواتساب في الكيوبيت.
|
||||
context.read<DashboardCubit>().disconnectWhatsApp();
|
||||
},
|
||||
child: const Text('نعم، اقطع الاتصال', style: TextStyle(color: Colors.redAccent)),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final session = status;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'📱 إعدادات اتصال الواتساب',
|
||||
style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'اربط حسابك مع بوابة واتساب التابعة لنظام نبيه لتفعيل الردود التلقائية والتحقق.',
|
||||
style: TextStyle(color: Colors.white60, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// English: Display WhatsApp connection card containing session and status.
|
||||
// Arabic: عرض بطاقة اتصال الواتساب التي تحتوي على الجلسة والحالة.
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF15102A),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'حالة الجلسة الحالية',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 14),
|
||||
),
|
||||
_buildStatusBadge(session?.status ?? 'disconnected'),
|
||||
],
|
||||
),
|
||||
const Divider(color: Colors.white10, height: 24),
|
||||
_buildRow('اسم الجلسة', session?.name ?? 'WhatsApp Team'),
|
||||
_buildRow('مفتاح التعريف', session?.sessionKey ?? 'لا يوجد'),
|
||||
if (session?.phone != null) _buildRow('رقم الهاتف المرتبط', session!.phone!),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// English: Render different elements depending on connection status.
|
||||
// Arabic: عرض عناصر مختلفة حسب حالة الاتصال.
|
||||
if (session == null || session.status == 'disconnected') ...[
|
||||
const Text(
|
||||
'⚠️ الحساب غير متصل. يرجى توليد رمز الاستجابة السريعة (QR Code) ومسحه ضوئياً لتفعيل الاتصال.',
|
||||
style: TextStyle(color: Colors.orangeAccent, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.purpleAccent,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 24),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
icon: const Icon(Icons.qr_code_scanner),
|
||||
label: const Text('توليد رمز الاستجابة QR'),
|
||||
onPressed: () {
|
||||
// English: Dispatch requestWhatsAppQr command to DashboardCubit.
|
||||
// Arabic: استدعاء أمر طلب رمز الاستجابة في الكيوبيت.
|
||||
context.read<DashboardCubit>().requestWhatsAppQr();
|
||||
},
|
||||
),
|
||||
] else if (session.status == 'waiting_qr') ...[
|
||||
const Text(
|
||||
'🔍 رمز الاستجابة جاهز للمسح. يرجى فتح الواتساب في هاتفك واختيار "الأجهزة المرتبطة" ثم مسح الرمز أدناه:',
|
||||
style: TextStyle(color: Colors.yellowAccent, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(Icons.qr_code_2, size: 200, color: Colors.black),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
] else if (session.status == 'connected') ...[
|
||||
const Text(
|
||||
'✅ الحساب متصل وجاهز للعمل. الردود التلقائية وروبوت خدمة العملاء نشطان الآن.',
|
||||
style: TextStyle(color: Colors.greenAccent, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
OutlinedButton.icon(
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.redAccent,
|
||||
side: const BorderSide(color: Colors.redAccent),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 24),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
icon: const Icon(Icons.link_off),
|
||||
label: const Text('قطع الاتصال'),
|
||||
onPressed: () => _showDisconnectDialog(context),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(label, style: const TextStyle(color: Colors.white70, fontSize: 13)),
|
||||
Text(value, style: const TextStyle(color: Colors.white, fontSize: 13, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusBadge(String status) {
|
||||
Color color;
|
||||
String text;
|
||||
switch (status) {
|
||||
case 'connected':
|
||||
color = Colors.green;
|
||||
text = 'متصل';
|
||||
break;
|
||||
case 'waiting_qr':
|
||||
color = Colors.orange;
|
||||
text = 'بانتظار المسح';
|
||||
break;
|
||||
case 'connecting':
|
||||
color = Colors.blue;
|
||||
text = 'جاري الاتصال';
|
||||
break;
|
||||
default:
|
||||
color = Colors.red;
|
||||
text = 'غير متصل';
|
||||
break;
|
||||
}
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: color),
|
||||
),
|
||||
child: Text(text, style: TextStyle(color: color, fontSize: 11, fontWeight: FontWeight.bold)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user