[03-Developer] #226 Catalog Gallery 구현
- Drift schema v2: Protocols.category CHECK 6→7 (light_circadian/sleep/movement/
nutrition/focus_cognition/recovery_stress/emotion_relationship). schemaVersion
1→2 + onUpgrade migrateV1ToV2 (DROP+CREATE+reseed flag 클리어).
- protocols.json 34 항목 v2 재분류 (1차 효과 기준). emotion_relationship 0 매핑.
- 도메인: DisplayCategory enum (8) + CatalogItem sealed (Protocol/Break/Diet).
- 데이터: CatalogRepository.all/byId/referencesByIds (3 source 통합).
- 상태: catalog_providers.dart (catalogItems / groupedByCategory / refsByIds).
- UI: ProtocolGalleryScreen (카테고리 칩 + 카드 그리드) + ProtocolPreviewScreen
(모든 필드 + reference 펼치기 + "내 습관으로" disabled placeholder) +
CatalogCard / CategoryChipRow / ReferenceExpandCard. HabitListScreen 빈
상태 CTA + AppBar 액션.
- 테스트: migration_v1_to_v2 3건 + display_category 5건 + catalog_repository
9건 + gallery widget 3건 + preview widget 3건 = 23 신규. 기존 88 회귀 0,
flutter analyze 0 issues. 110 passed / 1 skipped.
설계서: docs/design/226-catalog-gallery/{README, fn-catalog_repository,
fn-migration_v1_to_v2}.md + ADR-0004.
Refs #226
This commit is contained in:
@@ -7,7 +7,7 @@ const _protocols = '''
|
||||
[
|
||||
{
|
||||
"id": "morning_sunlight",
|
||||
"category": "health",
|
||||
"category": "light_circadian",
|
||||
"title": "아침 햇빛",
|
||||
"what": "기상 후 햇빛.",
|
||||
"when": "기상 후 30~60분.",
|
||||
|
||||
126
app/test/data/seed/test_seeds.dart
Normal file
126
app/test/data/seed/test_seeds.dart
Normal file
@@ -0,0 +1,126 @@
|
||||
// Stub seed loader used by both seed_importer_test and catalog_repository_test.
|
||||
// 1 row per catalog (minimal but schema-valid).
|
||||
|
||||
const protocolsStub = '''
|
||||
[
|
||||
{
|
||||
"id": "morning_sunlight",
|
||||
"category": "light_circadian",
|
||||
"title": "아침 햇빛",
|
||||
"what": "기상 후 햇빛.",
|
||||
"when": "기상 후 30~60분.",
|
||||
"dose": "5~10분.",
|
||||
"why": "ipRGC 자극.",
|
||||
"how": ["나간다", "쳐다본다"],
|
||||
"check": "60분 이내 외출",
|
||||
"reference_ids": ["ref_x"],
|
||||
"source_doc": "huberman-protocols.md"
|
||||
}
|
||||
]
|
||||
''';
|
||||
|
||||
const breakProtocolsStub = '''
|
||||
[
|
||||
{
|
||||
"id": "alcohol",
|
||||
"category": "alcohol",
|
||||
"title": "음주",
|
||||
"huberman_summary": "ep 86",
|
||||
"phases": [{"week": 1, "what": "환경 정리"}],
|
||||
"default_common_frames": ["dopamine_reset"]
|
||||
}
|
||||
]
|
||||
''';
|
||||
|
||||
const commonFramesStub = '''
|
||||
[
|
||||
{
|
||||
"id": "dopamine_reset",
|
||||
"title": "도파민 리셋",
|
||||
"what": "30일 절제",
|
||||
"why": "수용체 회복",
|
||||
"check": "30일 무자극"
|
||||
}
|
||||
]
|
||||
''';
|
||||
|
||||
const methodologiesStub = '''
|
||||
[
|
||||
{
|
||||
"id": "atomic_habits",
|
||||
"name": "Atomic Habits",
|
||||
"originator": "James Clear",
|
||||
"one_line_definition": "1% 개선",
|
||||
"core_unit": "1회 행동",
|
||||
"huberman_fit_score": 5,
|
||||
"is_core_engine": true
|
||||
}
|
||||
]
|
||||
''';
|
||||
|
||||
const framePatternsStub = '''
|
||||
[
|
||||
{
|
||||
"id": "fp_alcohol",
|
||||
"domain": "drink",
|
||||
"avoidance_keyword": "술 끊기",
|
||||
"l0_example": "술 끊기",
|
||||
"l2_suggestion": "저녁엔 무알콜",
|
||||
"l3_identity": "맑은 정신 추구"
|
||||
}
|
||||
]
|
||||
''';
|
||||
|
||||
const rewardMenuItemsStub = '''
|
||||
[
|
||||
{
|
||||
"id": "rmi_walk",
|
||||
"tier_recommended": "T1",
|
||||
"title": "산책 30분"
|
||||
}
|
||||
]
|
||||
''';
|
||||
|
||||
const referencesStub = '''
|
||||
[
|
||||
{
|
||||
"id": "ref_x",
|
||||
"kind": "url",
|
||||
"title": "Sample",
|
||||
"url": "https://example.com"
|
||||
}
|
||||
]
|
||||
''';
|
||||
|
||||
const dietPatternsStub = '''
|
||||
[
|
||||
{
|
||||
"id": "med",
|
||||
"name": "지중해 식단",
|
||||
"core": "올리브유 + 채소 + 생선 위주의 전통 식단.",
|
||||
"evidence_strength": "strong"
|
||||
}
|
||||
]
|
||||
''';
|
||||
|
||||
Future<String> testStubLoader(String path) async {
|
||||
switch (path) {
|
||||
case 'assets/seed/protocols.json':
|
||||
return protocolsStub;
|
||||
case 'assets/seed/break_protocols.json':
|
||||
return breakProtocolsStub;
|
||||
case 'assets/seed/common_frames.json':
|
||||
return commonFramesStub;
|
||||
case 'assets/seed/methodologies.json':
|
||||
return methodologiesStub;
|
||||
case 'assets/seed/frame_patterns.json':
|
||||
return framePatternsStub;
|
||||
case 'assets/seed/reward_menu_items.json':
|
||||
return rewardMenuItemsStub;
|
||||
case 'assets/seed/references.json':
|
||||
return referencesStub;
|
||||
case 'assets/seed/diet_patterns.json':
|
||||
return dietPatternsStub;
|
||||
}
|
||||
throw StateError('unexpected asset: $path');
|
||||
}
|
||||
Reference in New Issue
Block a user