new plus button

This commit is contained in:
davmar
2026-08-31 09:40:38 +02:00
parent 3b698a3667
commit 92581e6d55
17 changed files with 1336 additions and 152 deletions
+27 -2
View File
@@ -8,22 +8,47 @@ class Shop {
required this.shoppedAt,
required this.total,
required this.itemCount,
this.name,
this.receiptImagePath,
this.tags = const [],
});
final int id;
final String supermarket;
final String? name;
final DateTime shoppedAt;
final double total;
final int itemCount;
final String? receiptImagePath;
final List<String> tags;
String get displayName {
final tripName = name?.trim();
if (tripName != null && tripName.isNotEmpty) return tripName;
return supermarket;
}
Shop copyWith({String? name, bool clearName = false, List<String>? tags}) {
return Shop(
id: id,
supermarket: supermarket,
shoppedAt: shoppedAt,
total: total,
itemCount: itemCount,
receiptImagePath: receiptImagePath,
name: clearName ? null : (name ?? this.name),
tags: tags ?? this.tags,
);
}
factory Shop.fromMap(Map<String, Object?> map) {
final rawName = (map['name'] as String?)?.trim();
return Shop(
id: map['id']! as int,
supermarket: map['supermarket']! as String,
name: (rawName == null || rawName.isEmpty) ? null : rawName,
shoppedAt: DateTime.parse(map['shopped_at']! as String),
total: (map['total']! as num).toDouble(),
total: (map['total'] as num).toDouble(),
itemCount: (map['item_count'] as num?)?.toInt() ?? 0,
receiptImagePath: map['receipt_image_path'] as String?,
);
@@ -55,7 +80,7 @@ class ShopItem {
shopId: map['shop_id']! as int,
productId: map['product_id']! as int,
name: map['name']! as String,
price: (map['price']! as num).toDouble(),
price: (map['price'] as num).toDouble(),
quantity: map['quantity'] as int?,
unitPrice: (map['unit_price'] as num?)?.toDouble(),
);