설계서대로 구현. flutter_gemma 실제 통합은 OQ-1 (모델 URL+SHA) 확정 후.
v1은 LlmService 추상 + ModelLifecycle (다운로드/SHA/purge) + Riverpod
providers + 다이얼로그 + Settings 화면까지. main.dart 가 MockLlmService 를
override 해 모든 경로가 graceful (suggest 결과는 빈 리스트).
추가:
- lib/data/ai/{llm_service,gemma_llm_service,model_lifecycle}.dart
- lib/domain/ai/{frame_candidate,few_shot_builder,parse_response,suggest_frame}.dart
- lib/state/ai_providers.dart (aiSettings + modelAvailability + frameSuggestions)
- lib/ui/screens/settings_screen.dart (opt-in 토글 + 모델 상태 표시)
- lib/ui/widgets/frame_suggestion_dialog.dart (후보 3개 카드 + 다시 시도)
- HabitCreateScreen: "AI 제안" 버튼 (opt-in + ready 일 때만 노출)
- MetaDao.remove(key) 추가 (purge 용)
테스트 31개 신규 추가 (총 62개 통과):
- test/domain/ai/{suggest_frame, few_shot_builder, parse_response}_test.dart
- test/data/ai/model_lifecycle_test.dart (download/SHA/purge/availability)
flutter analyze 0 issue, flutter build apk --debug 통과.
Refs #215
87 lines
2.8 KiB
Dart
87 lines
2.8 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 'settings_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('습관'),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.settings),
|
|
tooltip: '설정',
|
|
onPressed: () {
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
builder: (_) => const SettingsScreen(),
|
|
));
|
|
},
|
|
),
|
|
],
|
|
),
|
|
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),
|
|
),
|
|
);
|
|
}
|
|
}
|