Update: 2026-05-07 01:14:37
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:camerawesome/camerawesome_plugin.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../core/utils/app_snackbar.dart';
|
||||
import '../controllers/scanner_controller.dart';
|
||||
|
||||
class ScannerView extends GetView<ScannerController> {
|
||||
@@ -138,8 +139,19 @@ class ScannerView extends GetView<ScannerController> {
|
||||
: ElevatedButton.icon(
|
||||
onPressed: controller.isProcessing.value
|
||||
? null
|
||||
// TODO: Get actual company_id from user selection
|
||||
: () => controller.uploadBatch('mock_company_id_123'),
|
||||
: () {
|
||||
if (controller.companies.isEmpty) {
|
||||
AppSnackbar.showError(
|
||||
'خطأ', 'لا توجد شركات مسجلة في حسابك');
|
||||
return;
|
||||
}
|
||||
if (controller.companies.length == 1) {
|
||||
controller
|
||||
.uploadBatch(controller.companies[0]['id']);
|
||||
return;
|
||||
}
|
||||
_showCompanySelectionDialog(context);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF0F4C81),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
@@ -170,4 +182,35 @@ class ScannerView extends GetView<ScannerController> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showCompanySelectionDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('اختر الشركة',
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(fontFamily: 'El Messiri')),
|
||||
content: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: controller.companies.length,
|
||||
itemBuilder: (context, index) {
|
||||
final company = controller.companies[index];
|
||||
return ListTile(
|
||||
title: Text(company['name'] ?? '', textAlign: TextAlign.right),
|
||||
subtitle: Text(company['tax_identification_number'] ?? '',
|
||||
textAlign: TextAlign.right),
|
||||
leading: const Icon(Icons.business, color: Color(0xFF0F4C81)),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
controller.uploadBatch(company['id']);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user