Update: 2026-05-07 18:41:16
This commit is contained in:
@@ -13,6 +13,8 @@ import '../../../core/services/voice_assistant_service.dart';
|
||||
import '../../../core/utils/app_snackbar.dart';
|
||||
import '../../../core/utils/logger.dart';
|
||||
import '../../../app/routes/app_pages.dart';
|
||||
import '../../invoices/controllers/invoices_controller.dart';
|
||||
import '../../main_shell/controllers/main_shell_controller.dart';
|
||||
|
||||
class DashboardController extends GetxController {
|
||||
final SecureStorage _storage = SecureStorage();
|
||||
@@ -339,9 +341,7 @@ class DashboardController extends GetxController {
|
||||
);
|
||||
|
||||
final action = (intent['action'] ?? '').toString();
|
||||
final params = Map<String, dynamic>.from(
|
||||
(intent['params'] as Map?) ?? <String, dynamic>{},
|
||||
);
|
||||
final params = _asStringMap(intent['params']);
|
||||
final confirmation = (intent['confirmation'] ??
|
||||
execution['message'] ??
|
||||
'تم تنفيذ الأمر الصوتي')
|
||||
@@ -356,7 +356,7 @@ class DashboardController extends GetxController {
|
||||
(execution['message'] ?? 'تعذر تنفيذ الأمر داخليًا').toString(),
|
||||
);
|
||||
} else {
|
||||
_executeAction(action, params);
|
||||
_executeAction(action, params, execution);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
AppLogger.error('Voice upload error', e.response?.data ?? e.message);
|
||||
@@ -381,20 +381,28 @@ class DashboardController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void _executeAction(String action, dynamic params) {
|
||||
Map<String, dynamic> _asStringMap(dynamic value) {
|
||||
if (value is Map) {
|
||||
return Map<String, dynamic>.from(value);
|
||||
}
|
||||
return <String, dynamic>{};
|
||||
}
|
||||
|
||||
void _executeAction(
|
||||
String action,
|
||||
Map<String, dynamic> params,
|
||||
Map<String, dynamic> execution,
|
||||
) {
|
||||
switch (action) {
|
||||
case 'list_invoices':
|
||||
case 'search_invoice':
|
||||
Get.toNamed(AppRoutes.MAIN);
|
||||
AppSnackbar.showWarning(
|
||||
'معلومة', 'تم فتح الواجهة الرئيسية؛ عرض نتائج تفصيلي قادم');
|
||||
_openInvoicesFromVoice(params, execution);
|
||||
break;
|
||||
case 'open_scanner':
|
||||
Get.toNamed(AppRoutes.SCANNER);
|
||||
break;
|
||||
case 'navigate':
|
||||
final screen =
|
||||
(params is Map ? params['screen'] : null)?.toString().toLowerCase();
|
||||
final screen = params['screen']?.toString().toLowerCase();
|
||||
if (screen == 'settings') {
|
||||
Get.toNamed(AppRoutes.MAIN);
|
||||
} else if (screen == 'scanner') {
|
||||
@@ -418,6 +426,35 @@ class DashboardController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void _openInvoicesFromVoice(
|
||||
Map<String, dynamic> params,
|
||||
Map<String, dynamic> execution,
|
||||
) {
|
||||
final invoicesController = Get.isRegistered<InvoicesController>()
|
||||
? Get.find<InvoicesController>()
|
||||
: Get.put(InvoicesController());
|
||||
|
||||
invoicesController.applyVoiceFilters(params);
|
||||
|
||||
if (Get.isRegistered<MainShellController>()) {
|
||||
Get.find<MainShellController>().selectTab(1);
|
||||
} else {
|
||||
Get.offAllNamed(AppRoutes.MAIN);
|
||||
}
|
||||
|
||||
final data = execution['data'];
|
||||
final count = data is Map ? data['count'] : null;
|
||||
final status = params['status']?.toString();
|
||||
final suffix = count == null ? '' : ' ($count)';
|
||||
final label = status == 'approved'
|
||||
? 'المعتمدة'
|
||||
: status == 'extracted'
|
||||
? 'الجاهزة'
|
||||
: 'المطابقة';
|
||||
|
||||
AppSnackbar.showSuccess('الفواتير', 'تم عرض الفواتير $label$suffix');
|
||||
}
|
||||
|
||||
void _resetVoiceState() {
|
||||
_recordTimer?.cancel();
|
||||
isVoiceRecording.value = false;
|
||||
|
||||
Reference in New Issue
Block a user