feat(block1): inventory walking skeleton + first quick-add slice
Stand up the Tanemaki monorepo and the first end-to-end vertical slice of Block 1 (offline, encrypted inventory): add a seed → see it in a categorized, searchable list → it persists → reopen and it's still there. Architecture (state management like G1nkgo, adapted to Tane's reality): - flutter_bloc (Cubit-first), but the encrypted Drift DB is the single source of truth; cubits stream from repositories (no hydrated_bloc/Hive, which would write plaintext at rest). - get_it composition root; go_router; slang i18n (ES/EN, Weblate-friendly JSON). Workspace & core: - pub workspace: packages/commons_core (pure Dart) + apps/app_seeds (Flutter). - commons_core primitives: UUIDv7 IdGen, Hybrid Logical Clock, Quantity value type (+ plant-aware QuantityKind), IdentityService root-seed stub. Data & security: - Drift schemaVersion=1 with all 10 Block-1 tables + common CRDT columns (HLC updated_at, last_author, tombstones); Movement append-only. - SQLCipher via an injectable executor that refuses to open a plaintext DB; DB key + root seed in the OS keystore (separate secrets). - Exported drift_schema_v1.json + migration scaffold. Tests (near-TDD; nothing merges without tests): - commons_core units (24), Drift migration test, "no plaintext at rest" security guard (runs where SQLCipher is present, skips otherwise), repository, widget, full quick-add flow, file-reopen persistence, and a no-hardcoded-strings i18n guard. GitLab CI: format + analyze + test + coverage. Follow-on Block-1 stories (item detail/edit, species catalog, germination UI) and all of Block 2 remain out of scope.
This commit is contained in:
parent
57c0eeadaf
commit
040f15a898
131 changed files with 19855 additions and 20 deletions
67
packages/commons_core/lib/src/value/quantity.dart
Normal file
67
packages/commons_core/lib/src/value/quantity.dart
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Coarse groups used by the UI to suggest relevant [QuantityKind]s for a
|
||||
/// species/family. Purely presentational — never forces a choice.
|
||||
enum QuantityGroup { informal, plantForm, precise }
|
||||
|
||||
/// A stable, extensible, i18n vocabulary for *rough, human* seed amounts.
|
||||
///
|
||||
/// Values go deliberately beyond kitchen measures: seeds are counted in the
|
||||
/// forms the plant gives them (a cob, a pod, a flower head…). The display label
|
||||
/// is localized from [name] — so the enum name is the stable storage key and
|
||||
/// must never be renumbered or reused (see data-model §5 migration rules).
|
||||
enum QuantityKind {
|
||||
// Informal / generic
|
||||
aFew(QuantityGroup.informal),
|
||||
some(QuantityGroup.informal),
|
||||
plenty(QuantityGroup.informal),
|
||||
handful(QuantityGroup.informal),
|
||||
pinch(QuantityGroup.informal),
|
||||
jar(QuantityGroup.informal),
|
||||
packet(QuantityGroup.informal),
|
||||
// Plant-form natural units
|
||||
cob(QuantityGroup.plantForm),
|
||||
head(QuantityGroup.plantForm),
|
||||
pod(QuantityGroup.plantForm),
|
||||
ear(QuantityGroup.plantForm),
|
||||
fruit(QuantityGroup.plantForm),
|
||||
bulb(QuantityGroup.plantForm),
|
||||
tuber(QuantityGroup.plantForm),
|
||||
seedHead(QuantityGroup.plantForm),
|
||||
bunch(QuantityGroup.plantForm),
|
||||
// Precise
|
||||
grams(QuantityGroup.precise),
|
||||
count(QuantityGroup.precise);
|
||||
|
||||
const QuantityKind(this.group);
|
||||
|
||||
final QuantityGroup group;
|
||||
}
|
||||
|
||||
/// A quantity held or moved: a qualitative [kind], plus an optional [precise]
|
||||
/// amount (grams / seed count) and an optional free-text [label] for rough
|
||||
/// amounts no [kind] captures. Shared value type used by both Lot and Movement.
|
||||
class Quantity extends Equatable {
|
||||
const Quantity({required this.kind, this.precise, this.label});
|
||||
|
||||
final QuantityKind kind;
|
||||
|
||||
/// Optional precise amount, meaningful for [QuantityGroup.precise] kinds.
|
||||
final double? precise;
|
||||
|
||||
/// Optional free text ("half a jam jar") when no [kind] fits well.
|
||||
final String? label;
|
||||
|
||||
bool get isPrecise => precise != null;
|
||||
|
||||
Quantity copyWith({QuantityKind? kind, double? precise, String? label}) {
|
||||
return Quantity(
|
||||
kind: kind ?? this.kind,
|
||||
precise: precise ?? this.precise,
|
||||
label: label ?? this.label,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [kind, precise, label];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue