feat(screenshots): real maize photo as hero variety, surfaced at top of inventory

This commit is contained in:
vjrj 2026-07-15 13:07:46 +02:00
parent 6ee61046c8
commit eed96b2a75
48 changed files with 27 additions and 14 deletions

View file

@ -1,4 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:commons_core/commons_core.dart';
import 'package:drift/drift.dart' show Value;
@ -149,10 +151,14 @@ Future<SeededInventory> seedShowcase(
final sow = monthsToMask(const [3, 4, 5]);
final harvest = monthsToMask(const [8, 9]);
// Varieties render with the app's default coloured-initial disc avatar —
// the on-brand default when no photo is set so no image decoding is needed.
Future<String> add(String label, String family) async {
final id = await repo.addQuickVariety(label: label, category: family);
// Most varieties use the app's default coloured-initial disc avatar; the hero
// (maize) carries a real photo (below).
Future<String> add(String label, String family, {Uint8List? photo}) async {
final id = await repo.addQuickVariety(
label: label,
category: family,
photoBytes: photo,
);
await (db.update(db.varieties)..where((v) => v.id.equals(id))).write(
VarietiesCompanion(
sowMonths: Value(sow),
@ -162,27 +168,34 @@ Future<SeededInventory> seedShowcase(
return id;
}
final tomato = await add('Cherry tomato', 'Solanaceae');
// A real photo of red & white flint corn is the hero variety, so the detail
// shot shows a genuine seed photo. Loaded from the committed test fixture
// (CWD is the package root under `flutter test`).
final maizePhoto = await File(
'test/screenshots/fixtures/maize.jpg',
).readAsBytes();
final maize = await add('Painted flint corn', 'Poaceae', photo: maizePhoto);
await repo.addLot(
varietyId: tomato,
varietyId: maize,
harvestYear: 2024,
quantity: const Quantity(kind: QuantityKind.handful),
quantity: const Quantity(kind: QuantityKind.cob, count: 6),
originName: 'Community seed swap',
abundance: Abundance.plentyToShare,
offerStatus: OfferStatus.shared,
);
await repo.addLot(
varietyId: tomato,
varietyId: maize,
harvestYear: 2023,
quantity: const Quantity(kind: QuantityKind.packet, count: 1),
offerStatus: OfferStatus.exchange,
);
await add('Climbing bean', 'Fabaceae');
await add('Sunflower', 'Asteraceae');
await add('Sweet basil', 'Lamiaceae');
await add('Rainbow chard', 'Amaranthaceae');
await add('Purple carrot', 'Apiaceae');
// The rest sit in families that sort at/after Poaceae, so the maize (and its
// photo) stays the first, top-of-list group in the inventory shot.
await add('Common buckwheat', 'Polygonaceae');
await add('Alpine strawberry', 'Rosaceae');
await add('Cherry tomato', 'Solanaceae');
await add('Sweet pepper', 'Solanaceae');
return SeededInventory(tomato);
return SeededInventory(maize);
}