Lower the bulk-digitization cliff with two more routes on top of the already-landed CSV import and "save and add another": - Photo-first drafts (capture now, catalogue later): burst-capture photos (camera or multi-gallery) into unnamed draft varieties, shown in a "to catalogue" tray, hidden from the main list until named. Adds Variety.isDraft (schema), addDraftVariety/watchDrafts/nameDraft, the triage sheet and the inventory banner. - On-device OCR label suggestion (Tesseract, offline, no Google): a "Suggest name from photo" button in the naming dialog behind a LabelTextExtractor interface (Tesseract on Android/iOS, no-op elsewhere). Reads the largest print via hOCR bounding boxes, drops boilerplate/low-confidence noise, preprocesses (grayscale, contrast, upscale) and sweeps rotations (0-315 deg) so tilted packets still read. Bundles tessdata_fast eng+spa; validated on-device against real packets. The photo is written to a temp file deleted immediately in a finally block (the plugin needs a path) - a bounded, documented exception to no-plaintext-at-rest. This commit also carries the co-developed schema evolution v5 to v8 that shares these files (organic flag, species viability years, crop calendar, lot provenance/abundance/preservation format, condition checks) plus their exports/migrations and i18n. Tests: CSV/draft/OCR unit + widget + migration green in isolation. Note: the full widget suite currently hangs (>10 min) - under investigation.
41 lines
1.7 KiB
Dart
41 lines
1.7 KiB
Dart
/// Viability status of a seed lot, derived purely from its age versus the
|
|
/// species' typical seed longevity (bundled reference data). Turns passive
|
|
/// storage into active stewardship: it surfaces which lots to sow or regenerate
|
|
/// before they lapse, instead of just accumulating them.
|
|
enum SeedViability {
|
|
/// Comfortably within the species' typical viability window.
|
|
fresh,
|
|
|
|
/// In the final year of the window — sow or reproduce this season.
|
|
expiringSoon,
|
|
|
|
/// Past the typical viability window — germination is likely dropping fast.
|
|
expired,
|
|
|
|
/// Not enough data to judge (no harvest year, or no reference figure).
|
|
unknown,
|
|
}
|
|
|
|
/// Computes the viability status of a seed lot harvested in [harvestYear] for a
|
|
/// species whose typical longevity is [viabilityYears], as of [currentYear].
|
|
///
|
|
/// A conservative, age-based signal: the bundled figure is a single number, not
|
|
/// a decay curve, so this only distinguishes "fine / use soon / past it".
|
|
/// [expiringSoon] flags the last year of the window so the grower can prioritise
|
|
/// what to reproduce before it lapses. Any actual [GerminationTest] a grower
|
|
/// records remains the ground truth and is shown alongside this estimate.
|
|
SeedViability seedViability({
|
|
required int? harvestYear,
|
|
required int? viabilityYears,
|
|
required int currentYear,
|
|
}) {
|
|
if (harvestYear == null || viabilityYears == null || viabilityYears <= 0) {
|
|
return SeedViability.unknown;
|
|
}
|
|
final age = currentYear - harvestYear;
|
|
// A harvest stamped in the future is treated as fresh, not expired.
|
|
if (age < 0) return SeedViability.fresh;
|
|
if (age >= viabilityYears) return SeedViability.expired;
|
|
if (age >= viabilityYears - 1) return SeedViability.expiringSoon;
|
|
return SeedViability.fresh;
|
|
}
|