fixes before build 2

This commit is contained in:
gitea
2026-08-31 17:05:22 +02:00
parent 14fcb9a533
commit b0708101b0
20 changed files with 72 additions and 61 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ class _CropReceiptScreenState extends State<CropReceiptScreen> {
Future<void> _saveAndPop(Uint8List bytes) async {
try {
final file = File(
'${Directory.systemTemp.path}/receipity_crop_${DateTime.now().millisecondsSinceEpoch}.jpg',
'${Directory.systemTemp.path}/groci_crop_${DateTime.now().millisecondsSinceEpoch}.jpg',
);
await file.writeAsBytes(bytes, flush: true);
if (!mounted) return;
+5 -5
View File
@@ -13,20 +13,20 @@ import 'utils/constants.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await ReceiptParser.loadConfig();
runApp(ReceipityApp());
runApp(GrociApp());
}
class ReceipityApp extends StatefulWidget {
ReceipityApp({super.key, ProductRepository? repository})
class GrociApp extends StatefulWidget {
GrociApp({super.key, ProductRepository? repository})
: repository = repository ?? ProductRepository();
final ProductRepository repository;
@override
State<ReceipityApp> createState() => _ReceipityAppState();
State<GrociApp> createState() => _GrociAppState();
}
class _ReceipityAppState extends State<ReceipityApp> {
class _GrociAppState extends State<GrociApp> {
late final AppSettings _settings;
@override
+1 -1
View File
@@ -69,7 +69,7 @@ class _ScanScreenState extends State<ScanScreen> {
try {
final data = await rootBundle.load(kSampleReceiptAsset);
final file = File(
'${Directory.systemTemp.path}/receipity_sample_receipt.jpeg',
'${Directory.systemTemp.path}/groci_sample_receipt.jpeg',
);
await file.writeAsBytes(data.buffer.asUint8List(), flush: true);
if (!mounted) return;
+7 -3
View File
@@ -5,6 +5,9 @@ import 'dart:convert';
const int kBackupVersion = 3;
const String kBackupFormat = 'groci-backup';
const String kLegacyBackupFormat = 'receipity-backup';
class BackupDocument {
const BackupDocument({
required this.version,
@@ -33,7 +36,7 @@ class BackupDocument {
final Map<String, String> images;
Map<String, Object?> toJson() => {
'format': 'receipity-backup',
'format': kBackupFormat,
'version': version,
'exportedAt': exportedAt,
'darkMode': darkMode,
@@ -54,8 +57,9 @@ class BackupDocument {
if (decoded is! Map<String, dynamic>) {
throw const FormatException('Backup is not a JSON object.');
}
if (decoded['format'] != 'receipity-backup') {
throw const FormatException('This file is not a Receipity backup.');
final format = decoded['format'];
if (format != kBackupFormat && format != kLegacyBackupFormat) {
throw const FormatException('This file is not a Groci backup.');
}
final version = decoded['version'];
if (version is! int || version < 1 || version > kBackupVersion) {
+6 -6
View File
@@ -1,4 +1,4 @@
/// Build, share, and restore a Receipity JSON backup.
/// Build, share, and restore a Groci JSON backup.
library;
import 'dart:convert';
@@ -68,11 +68,11 @@ class BackupService {
final document = await buildBackup();
final bytes = Uint8List.fromList(utf8.encode(document.encode()));
final stamp = DateTime.now().toIso8601String().split('T').first;
final fileName = 'receipity-backup-$stamp.json';
final fileName = 'groci-backup-$stamp.json';
try {
final saved = await FilePicker.saveFile(
dialogTitle: 'Save Receipity backup',
dialogTitle: 'Save Groci backup',
fileName: fileName,
bytes: bytes,
mimeType: 'application/json',
@@ -90,8 +90,8 @@ class BackupService {
final result = await SharePlus.instance.share(
ShareParams(
files: [XFile(file.path, mimeType: 'application/json')],
subject: 'Receipity backup',
text: 'Receipity backup $stamp',
subject: 'Groci backup',
text: 'Groci backup $stamp',
),
);
return result.status != ShareResultStatus.dismissed;
@@ -99,7 +99,7 @@ class BackupService {
Future<bool> importBackup() async {
final picked = await FilePicker.pickFile(
dialogTitle: 'Import Receipity backup',
dialogTitle: 'Import Groci backup',
type: FileType.custom,
allowedExtensions: const ['json'],
);
+11 -3
View File
@@ -31,10 +31,18 @@ class ProductRepository extends ChangeNotifier {
return _opening!;
}
Future<String> _defaultDatabasePath() async {
final dir = (await getApplicationDocumentsDirectory()).path;
final groci = p.join(dir, 'groci.db');
final legacy = p.join(dir, 'receipity.db');
if (!File(groci).existsSync() && File(legacy).existsSync()) {
await File(legacy).rename(groci);
}
return groci;
}
Future<Database> _open() async {
final path =
databasePath ??
p.join((await getApplicationDocumentsDirectory()).path, 'receipity.db');
final path = databasePath ?? await _defaultDatabasePath();
return openDatabase(
path,
version: 9,
+1 -1
View File
@@ -1,7 +1,7 @@
/// Shared strings used across the app.
library;
const String kAppName = 'Receipity';
const String kAppName = 'Groci';
/// Bundled Jumbo receipt used to test OCR without the camera.
const String kSampleReceiptAsset = 'assets/receipt.jpeg';