feat: make server owner of tabs

This commit is contained in:
2026-10-20 16:15:14 +02:00
parent 5754ae742d
commit 93acfe15a9
26 changed files with 3654 additions and 389 deletions
+13 -34
View File
@@ -2,7 +2,6 @@ import 'dart:io';
import 'package:flutter/material.dart';
import '../../l10n/app_localizations.dart';
import '../../models/product.dart';
class ProductTile extends StatelessWidget {
@@ -24,8 +23,6 @@ class ProductTile extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final l10n = AppLocalizations.of(context);
final outOfStock = product.isOutOfStock;
final lowStock = !outOfStock && product.isLowStock;
@@ -50,13 +47,14 @@ class ProductTile extends StatelessWidget {
child: Material(
color: theme.cardTheme.color ?? scheme.surface,
child: InkWell(
onTap: enabled && !outOfStock ? onTap : null,
// Never blocked by stock: the count may simply be off
onTap: enabled ? onTap : null,
onLongPress: onLongPress,
child: Stack(
fit: StackFit.expand,
children: [
Opacity(
opacity: outOfStock ? 0.35 : (enabled ? 1 : 0.4),
opacity: enabled ? 1 : 0.4,
child: hasImage
? Image.file(
File(product.imagePath!),
@@ -90,28 +88,6 @@ class ProductTile extends StatelessWidget {
right: 10,
child: _StockBadge(product: product),
),
if (outOfStock)
Center(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 6,
),
decoration: BoxDecoration(
color: scheme.error.withValues(alpha: 0.9),
borderRadius: BorderRadius.circular(999),
),
child: Text(
l10n.outOfStock,
style: TextStyle(
color: scheme.onError,
fontWeight: FontWeight.w800,
fontSize: 12,
),
),
),
),
],
),
),
@@ -140,16 +116,15 @@ class _StockBadge extends StatelessWidget {
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
if (product.isOutOfStock) {
return const SizedBox.shrink();
}
final low = product.isLowStock;
final out = product.isOutOfStock;
final low = !out && product.isLowStock;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: low
color: out
? scheme.error.withValues(alpha: 0.9)
: low
? Colors.amber.withValues(alpha: 0.9)
: scheme.primary.withValues(alpha: 0.85),
borderRadius: BorderRadius.circular(999),
@@ -159,7 +134,11 @@ class _StockBadge extends StatelessWidget {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w800,
color: low ? Colors.black : scheme.onPrimary,
color: out
? scheme.onError
: low
? Colors.black
: scheme.onPrimary,
),
),
);