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
+80
View File
@@ -0,0 +1,80 @@
/// Thumbnail or letter avatar for a product.
library;
import 'dart:io';
import 'package:flutter/material.dart';
class ProductImage extends StatelessWidget {
const ProductImage({
super.key,
required this.name,
this.path,
this.size = 48,
});
final String name;
final String? path;
final double size;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final file = path == null ? null : File(path!);
final hasFile = file != null && file.existsSync();
return ClipRRect(
borderRadius: BorderRadius.circular(size / 4),
child: SizedBox(
width: size,
height: size,
child: hasFile
? Image.file(
file,
fit: BoxFit.cover,
cacheWidth: (size * 3).round(),
errorBuilder: (_, _, _) => _LetterAvatar(
name: name,
size: size,
colorScheme: theme.colorScheme,
),
)
: _LetterAvatar(
name: name,
size: size,
colorScheme: theme.colorScheme,
),
),
);
}
}
class _LetterAvatar extends StatelessWidget {
const _LetterAvatar({
required this.name,
required this.size,
required this.colorScheme,
});
final String name;
final double size;
final ColorScheme colorScheme;
@override
Widget build(BuildContext context) {
final trimmed = name.trim();
final letter = trimmed.isEmpty ? '?' : trimmed.substring(0, 1).toUpperCase();
return ColoredBox(
color: colorScheme.secondaryContainer,
child: Center(
child: Text(
letter,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: colorScheme.onSecondaryContainer,
fontSize: size * 0.4,
),
),
),
);
}
}