Can disable dates extraction
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/expenses.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/prefs.dart';
|
||||
import 'package:moneymgr_mobile/utils/ocr_utils.dart';
|
||||
import 'package:moneymgr_mobile/utils/pdf_utils.dart';
|
||||
import 'package:moneymgr_mobile/widgets/expense_editor.dart';
|
||||
@@ -14,9 +15,14 @@ part 'scan_screen.g.dart';
|
||||
/// Scan a document & return generated PDF as byte file
|
||||
@riverpod
|
||||
Future<(Uint8List?, BaseExpenseInfo?)> _scanDocument(Ref ref) async {
|
||||
final prefs = ref.watch(prefsProvider).requireValue;
|
||||
|
||||
final pdf = await scanDocAsPDF();
|
||||
final img = await renderPdf(pdfBytes: pdf);
|
||||
final amount = await extractInfoFromBill(img);
|
||||
final amount = await extractInfoFromBill(
|
||||
imgBuff: img,
|
||||
extractDates: !prefs.disableExtractDates(),
|
||||
);
|
||||
return (pdf, amount);
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,11 @@ class SettingsScreen extends ConsumerWidget {
|
||||
ref.invalidate(prefsProvider);
|
||||
}
|
||||
|
||||
handleToggleDisableExtractDate(v) async {
|
||||
await prefs.setDisableExtractDates(v);
|
||||
ref.invalidate(prefsProvider);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Settings')),
|
||||
body: ListView(
|
||||
@@ -40,6 +45,14 @@ class SettingsScreen extends ConsumerWidget {
|
||||
"Do not start camera automatically on application startup",
|
||||
),
|
||||
),
|
||||
SwitchListTile(
|
||||
value: prefs.disableExtractDates(),
|
||||
onChanged: handleToggleDisableExtractDate,
|
||||
title: Text("Do not extract dates"),
|
||||
subtitle: Text(
|
||||
"Do not attempt to extract dates from scanned expenses",
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.info_outline),
|
||||
|
Reference in New Issue
Block a user