added categories, import export, settings

This commit is contained in:
davmar
2026-08-29 16:45:27 +02:00
parent 2a5a922aab
commit 732a0dc14a
30 changed files with 3700 additions and 167 deletions
+48 -1
View File
@@ -8,6 +8,11 @@ class Product {
required this.lastPrice,
required this.timesSeen,
required this.updatedAt,
this.favourite = false,
this.imagePath,
this.supermarket,
this.notes,
this.category,
});
final int id;
@@ -15,14 +20,56 @@ class Product {
final double lastPrice;
final int timesSeen;
final DateTime updatedAt;
final bool favourite;
final String? imagePath;
final String? supermarket;
final String? notes;
final String? category;
factory Product.fromMap(Map<String, Object?> map) {
return Product(
id: map['id']! as int,
name: map['name']! as String,
lastPrice: (map['last_price']! as num).toDouble(),
lastPrice: (map['display_price'] as num? ?? map['last_price']! as num)
.toDouble(),
timesSeen: map['times_seen']! as int,
updatedAt: DateTime.parse(map['updated_at']! as String),
favourite: (map['favourite'] as int? ?? 0) == 1,
imagePath: map['image_path'] as String?,
supermarket: map['supermarket'] as String?,
notes: map['notes'] as String?,
category: map['category'] as String?,
);
}
Product copyWith({
String? name,
double? lastPrice,
int? timesSeen,
DateTime? updatedAt,
bool? favourite,
String? imagePath,
String? supermarket,
String? notes,
String? category,
bool clearImage = false,
bool clearSupermarket = false,
bool clearNotes = false,
bool clearCategory = false,
}) {
return Product(
id: id,
name: name ?? this.name,
lastPrice: lastPrice ?? this.lastPrice,
timesSeen: timesSeen ?? this.timesSeen,
updatedAt: updatedAt ?? this.updatedAt,
favourite: favourite ?? this.favourite,
imagePath: clearImage ? null : (imagePath ?? this.imagePath),
supermarket: clearSupermarket ? null : (supermarket ?? this.supermarket),
notes: clearNotes ? null : (notes ?? this.notes),
category: clearCategory ? null : (category ?? this.category),
);
}
}
enum ProductSort { name, preferred }