Update: 2026-05-07 18:56:48

This commit is contained in:
Hamza-Ayed
2026-05-07 18:56:48 +03:00
parent 528b3ca247
commit d8820efa24
4 changed files with 438 additions and 57 deletions

View File

@@ -401,6 +401,9 @@ class DashboardController extends GetxController {
case 'open_scanner':
Get.toNamed(AppRoutes.SCANNER);
break;
case 'check_quota':
_showQuotaResult(execution);
break;
case 'navigate':
final screen = params['screen']?.toString().toLowerCase();
if (screen == 'settings') {
@@ -411,7 +414,6 @@ class DashboardController extends GetxController {
Get.toNamed(AppRoutes.MAIN);
}
break;
case 'check_quota':
case 'check_status':
case 'get_report':
case 'export_pdf':
@@ -455,6 +457,145 @@ class DashboardController extends GetxController {
AppSnackbar.showSuccess('الفواتير', 'تم عرض الفواتير $label$suffix');
}
void _showQuotaResult(Map<String, dynamic> execution) {
final data = _asStringMap(execution['data']);
if (data.isEmpty) {
AppSnackbar.showWarning('الاشتراك', 'لم تصل تفاصيل الاشتراك من الخادم');
return;
}
final planName = (data['plan_name'] ?? 'غير معروف').toString();
final status = _subscriptionStatusLabel(data['status']);
final days = data['days_remaining'];
Get.bottomSheet(
Container(
padding: const EdgeInsets.fromLTRB(20, 16, 20, 24),
decoration: BoxDecoration(
color: Get.isDarkMode ? const Color(0xFF1E1E2E) : Colors.white,
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
),
child: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
width: 40,
height: 4,
decoration: BoxDecoration(
color: Colors.grey.withValues(alpha: 0.35),
borderRadius: BorderRadius.circular(2),
),
),
),
const SizedBox(height: 18),
Row(
children: [
const Icon(Icons.workspace_premium_rounded,
color: Color(0xFFD4AF37)),
const SizedBox(width: 10),
Expanded(
child: Text(
'اشتراكك الحالي',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w800,
color: Get.isDarkMode
? Colors.white
: const Color(0xFF0F172A),
),
),
),
],
),
const SizedBox(height: 14),
Text(
'$planName$status${days == null ? '' : '$days يوم متبقي'}',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color:
Get.isDarkMode ? Colors.white70 : const Color(0xFF334155),
),
),
const SizedBox(height: 18),
_buildQuotaRow('الفواتير', data['invoices'], Icons.receipt_long),
const SizedBox(height: 12),
_buildQuotaRow('الشركات', data['companies'], Icons.business),
const SizedBox(height: 12),
_buildQuotaRow('المستخدمين', data['users'], Icons.people),
],
),
),
),
isScrollControlled: true,
);
}
Widget _buildQuotaRow(String label, dynamic raw, IconData icon) {
final item = _asStringMap(raw);
final used = item['used'] ?? 0;
final limit = item['limit'] ?? 0;
final percent = ((item['percent'] as num?) ?? 0).clamp(0, 100).toDouble();
final warning = item['warning'] == true;
final color = warning ? const Color(0xFFDC2626) : const Color(0xFF0F4C81);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(icon, size: 18, color: color),
const SizedBox(width: 8),
Expanded(
child: Text(
label,
style: const TextStyle(fontWeight: FontWeight.w700),
),
),
Text(
'$used / $limit',
style: TextStyle(
fontWeight: FontWeight.w700,
color: color,
fontFamily: 'monospace',
),
),
],
),
const SizedBox(height: 8),
ClipRRect(
borderRadius: BorderRadius.circular(4),
child: LinearProgressIndicator(
value: percent / 100,
minHeight: 7,
color: color,
backgroundColor:
Get.isDarkMode ? Colors.white10 : const Color(0xFFE2E8F0),
),
),
],
);
}
String _subscriptionStatusLabel(dynamic status) {
switch (status?.toString()) {
case 'trial':
return 'تجريبي';
case 'active':
return 'فعّال';
case 'past_due':
return 'متأخر الدفع';
case 'cancelled':
return 'ملغي';
default:
return 'غير معروف';
}
}
void _resetVoiceState() {
_recordTimer?.cancel();
isVoiceRecording.value = false;