feat: add equality operators, make history screen paginated, random performance updates

This commit is contained in:
2026-07-29 18:10:46 +02:00
parent da5588cd1c
commit 031a618220
22 changed files with 702 additions and 79 deletions
+22 -22
View File
@@ -7,6 +7,7 @@ class ProductTile extends StatelessWidget {
final Product product;
final bool enabled;
final VoidCallback onTap;
static const _tileImageSize = 280.0;
const ProductTile({
required this.product,
@@ -14,16 +15,6 @@ class ProductTile extends StatelessWidget {
required this.onTap,
});
bool get _hasImage {
final imagePath = product.imagePath;
if (imagePath == null || imagePath.isEmpty) {
return false;
}
return File(imagePath).existsSync();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
@@ -32,7 +23,10 @@ class ProductTile extends StatelessWidget {
final outOfStock = product.stockQuantity <= 0;
final lowStock =
product.stockQuantity > 0 &&
product.stockQuantity <= product.lowStockThreshold; // adjust name
product.stockQuantity <= product.lowStockThreshold;
final hasImage = product.imagePath != null &&
product.imagePath!.isNotEmpty;
final borderColor = outOfStock
? scheme.error.withValues(alpha: 0.7)
@@ -59,21 +53,18 @@ class ProductTile extends StatelessWidget {
children: [
Opacity(
opacity: outOfStock ? 0.35 : (enabled ? 1 : 0.4),
child: _hasImage
child: hasImage
? Image.file(
File(product.imagePath!),
fit: BoxFit.scaleDown,
cacheWidth: _tileImageSize.toInt(),
errorBuilder:
(context, error, stackTrace) => _noImage(scheme),
)
: Center(
child: Icon(
Icons.image_not_supported_outlined,
size: 34,
color: scheme.onSurface.withValues(alpha: 0.3),
),
),
: _noImage(scheme),
),
if (_hasImage)
if (hasImage)
Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
@@ -126,6 +117,16 @@ class ProductTile extends StatelessWidget {
),
);
}
Widget _noImage(ColorScheme scheme) {
return Center(
child: Icon(
Icons.image_not_supported_outlined,
size: 34,
color: scheme.onSurface.withValues(alpha: 0.3),
),
);
}
}
class _StockBadge extends StatelessWidget {
@@ -141,8 +142,7 @@ class _StockBadge extends StatelessWidget {
return const SizedBox.shrink();
}
final low =
product.stockQuantity <= product.lowStockThreshold; // adjust name
final low = product.stockQuantity <= product.lowStockThreshold;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),