Update: 2026-05-11 01:09:54
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:get/get.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import '../../../core/services/upload_progress_service.dart';
|
||||
import '../../../core/utils/logger.dart';
|
||||
import '../../../core/utils/app_snackbar.dart';
|
||||
@@ -91,6 +92,11 @@ class ScannerController extends GetxController {
|
||||
capturedImages.add(originalFile);
|
||||
int index = capturedImages.length - 1;
|
||||
|
||||
if (imagePath.toLowerCase().endsWith('.pdf')) {
|
||||
AppLogger.print('Added PDF file, skipping image processing: $imagePath');
|
||||
return;
|
||||
}
|
||||
|
||||
ImageProcessingService.processInvoiceImage(originalFile)
|
||||
.then((processedFile) {
|
||||
if (processedFile != null && index < capturedImages.length) {
|
||||
@@ -102,6 +108,28 @@ class ScannerController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> pickPdfFile() async {
|
||||
try {
|
||||
FilePickerResult? result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['pdf'],
|
||||
allowMultiple: true,
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
for (var file in result.files) {
|
||||
if (file.path != null) {
|
||||
addImage(file.path!);
|
||||
}
|
||||
}
|
||||
AppSnackbar.showSuccess('تمت الإضافة', 'تم استيراد ملفات الفواتير بنجاح');
|
||||
}
|
||||
} catch (e) {
|
||||
AppLogger.error('Failed to pick PDF', e);
|
||||
AppSnackbar.showError('خطأ', 'تعذر استيراد الملفات');
|
||||
}
|
||||
}
|
||||
|
||||
void removeImage(int index) {
|
||||
if (index >= 0 && index < capturedImages.length) {
|
||||
capturedImages.removeAt(index);
|
||||
|
||||
@@ -119,6 +119,18 @@ class ScannerView extends GetView<ScannerController> {
|
||||
state: state,
|
||||
children: [
|
||||
AwesomeFlashButton(state: state),
|
||||
const SizedBox(width: 16),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black45,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: () => controller.pickPdfFile(),
|
||||
icon: const Icon(Icons.picture_as_pdf, color: Colors.white),
|
||||
tooltip: 'استيراد PDF',
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
TextButton.icon(
|
||||
onPressed: () => Get.back(),
|
||||
|
||||
@@ -353,6 +353,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.1"
|
||||
file_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_picker
|
||||
sha256: ab13ae8ef5580a411c458d6207b6774a6c237d77ac37011b13994879f68a8810
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.3.7"
|
||||
file_selector_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -31,6 +31,7 @@ dependencies:
|
||||
camerawesome: ^2.0.0
|
||||
cunning_document_scanner: ^1.2.3
|
||||
image_picker: ^1.0.7
|
||||
file_picker: ^8.1.2
|
||||
|
||||
# ─── Image Processing ───────────────────────────────
|
||||
image: ^4.1.7
|
||||
|
||||
Reference in New Issue
Block a user