- Drift 21 tables (8 catalog + 11 user + habit_dose_variants + meta_kv) with R1~R10 CHECK constraints and 19 indexes - 8 hand-crafted seed JSON catalogs in app/assets/seed/ (refs 84, protocols 34, methodologies 21, frame_patterns 30, reward_menu_items 30, break_protocols 8, common_frames 5, diet_patterns 5) - 6 domain functions: recommend_variant, compute_streak, validate_frame_level, active_habit_quota, weekly_minimum_ratio, seed_importer (transactional, idempotent) - 4 vertical-slice Riverpod screens: HabitList, HabitCreate, CheckIn, Streak - 31 unit tests passing; flutter analyze clean - OQ-5 streak semantics: missing entry ≠ explicit blank (missing = end of history; only TrackerValue.blank triggers Never-miss-twice) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
73 lines
2.5 KiB
Dart
73 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../state/providers.dart';
|
|
import 'check_in_screen.dart';
|
|
import 'habit_create_screen.dart';
|
|
import 'streak_screen.dart';
|
|
|
|
class HabitListScreen extends ConsumerWidget {
|
|
const HabitListScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final boot = ref.watch(bootstrapProvider);
|
|
final habitsAsync = ref.watch(activeHabitsProvider);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('습관')),
|
|
body: boot.when(
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
error: (e, st) => Center(child: Text('초기화 실패: $e')),
|
|
data: (_) => habitsAsync.when(
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
error: (e, st) => Center(child: Text('로드 실패: $e')),
|
|
data: (habits) {
|
|
if (habits.isEmpty) {
|
|
return const Center(
|
|
child: Text('아직 습관이 없습니다. + 버튼으로 추가하세요.'),
|
|
);
|
|
}
|
|
return ListView.separated(
|
|
itemCount: habits.length,
|
|
separatorBuilder: (_, _) => const Divider(height: 1),
|
|
itemBuilder: (context, i) {
|
|
final h = habits[i];
|
|
return ListTile(
|
|
title: Text(h.title),
|
|
subtitle: Text(
|
|
'${h.type} · ${h.frameLevel} · ${h.frameFramedText}',
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
trailing: IconButton(
|
|
icon: const Icon(Icons.show_chart),
|
|
onPressed: () {
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
builder: (_) => StreakScreen(habitId: h.id),
|
|
));
|
|
},
|
|
),
|
|
onTap: () {
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
builder: (_) => CheckInScreen(habitId: h.id),
|
|
));
|
|
},
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
floatingActionButton: FloatingActionButton(
|
|
onPressed: () {
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
builder: (_) => const HabitCreateScreen(),
|
|
));
|
|
},
|
|
child: const Icon(Icons.add),
|
|
),
|
|
);
|
|
}
|
|
}
|