feat(block1): bundled species catalog + autocomplete link
Add a small curated catalog of Iberian horticultural species and let a variety be linked to it from the edit sheet. - assets/catalog/species.json: 14 species with botanical family and ES/EN common names (wikidata_qid/gbif_key deferred to the varilla enrichment). - SpeciesRepository: idempotent seedBundled (is_bundled rows, keyed by scientific name) + search by scientific/common name with a locale-best label. Seeded on startup from DI. - VarietyRepository.linkSpecies: sets species_id and prefills category from the species' family when empty (never overwrites an existing category). VarietyDetail now carries the scientific name. - Edit sheet gains a live species-search field; the detail view shows the scientific name (italic). i18n strings added (ES/EN). Tests: catalog parse, idempotent seeding, search by scientific/common name, linkSpecies prefill semantics, and a widget test for the autocomplete → link → scientific-name-shown flow. Full suite: 32 passing, 0 skipped.
This commit is contained in:
parent
7ff4e38a15
commit
4e8b8293e0
22 changed files with 700 additions and 47 deletions
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tane/data/species_repository.dart';
|
||||
import 'package:tane/data/variety_repository.dart';
|
||||
import 'package:tane/db/database.dart';
|
||||
import 'package:tane/i18n/strings.g.dart';
|
||||
|
|
@ -29,6 +30,9 @@ VarietyRepository newTestRepository(
|
|||
String nodeId = 'test-node',
|
||||
}) => VarietyRepository(db, idGen: IdGen(), nodeId: nodeId);
|
||||
|
||||
SpeciesRepository newTestSpeciesRepository(AppDatabase db) =>
|
||||
SpeciesRepository(db, idGen: IdGen());
|
||||
|
||||
/// Wraps [child] with the providers a screen expects (repository, inventory
|
||||
/// cubit) plus i18n and Material localizations, pinned to [locale].
|
||||
Widget wrapScreen({
|
||||
|
|
@ -61,12 +65,16 @@ Widget wrapScreen({
|
|||
Widget wrapDetail({
|
||||
required VarietyRepository repository,
|
||||
required String varietyId,
|
||||
SpeciesRepository? species,
|
||||
AppLocale locale = AppLocale.en,
|
||||
}) {
|
||||
LocaleSettings.setLocaleSync(locale);
|
||||
return TranslationProvider(
|
||||
child: RepositoryProvider.value(
|
||||
value: repository,
|
||||
child: MultiRepositoryProvider(
|
||||
providers: [
|
||||
RepositoryProvider.value(value: repository),
|
||||
if (species != null) RepositoryProvider.value(value: species),
|
||||
],
|
||||
child: BlocProvider(
|
||||
create: (_) => VarietyDetailCubit(repository, varietyId),
|
||||
child: MaterialApp(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue