FEATURE move button to the scanner page

This commit is contained in:
konrad.lys@eu.equinix.com
2023-06-05 20:07:38 +02:00
parent dc552dc4a7
commit bf0351f23f
6 changed files with 142 additions and 82 deletions

View File

@@ -5,9 +5,13 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/service/file_service.dart';
import 'package:paperless_mobile/features/notifications/services/local_notification_service.dart';
class DocumentScannerCubit extends Cubit<List<File>> {
DocumentScannerCubit() : super(const []);
final LocalNotificationService _notificationService;
DocumentScannerCubit(this._notificationService) : super(const []);
void addScan(File file) => emit([...state, file]);
@@ -36,4 +40,15 @@ class DocumentScannerCubit extends Cubit<List<File>> {
throw const PaperlessServerException(ErrorCode.scanRemoveFailed);
}
}
Future<void> saveLocally(
Uint8List bytes, String fileName, String preferredLocaleSubtag) async {
var file = await FileService.saveToFile(bytes, fileName);
_notificationService.notifyFileSaved(
filename: fileName,
filePath: file.path,
finished: true,
locale: preferredLocaleSubtag,
);
}
}