dev v0.4.2 위 hotfix. v0.4.1 단말 테스트에서 발견된 raw 식별자 노출 P0 3 + P1 2. - ui/labels.dart 신규 — habitTypeLabel(FromDb) / rewardTierLabel. domain enum 의 한국어 라벨 단일 지점 (domain layer 분리). - habit_list 부제: 'build · L3 · …' → '만들기 · …'. FrameLevel 노출 제거 (시스템 규약). - streak: 'T0' / 'T1' raw → '🌱 새싹' / '🥉 3회 도전' …, 영문 'Never miss twice' → '이틀 연속 빠졌어요. 한 단계 강등됐습니다', 현재 스트릭을 displayLarge hero 로 위계 강조. - habit_create 드롭다운: '만들기 (build)' → '만들기'. - 설계서 docs/design/342-v042-hotfix/README.md — A/B/C 11 AC. - CHANGELOG v0.4.2 에 UX round 1 섹션 추가. 167 tests passed, analyze clean. APK 재빌드 보류 (사용자 결정). Refs #342
122 lines
4.3 KiB
Dart
122 lines
4.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../core/time.dart';
|
|
import '../../domain/models/tracker_entry.dart';
|
|
import '../../domain/streak/compute_streak.dart';
|
|
import '../../state/providers.dart';
|
|
import '../labels.dart';
|
|
|
|
class StreakScreen extends ConsumerWidget {
|
|
final String habitId;
|
|
const StreakScreen({super.key, required this.habitId});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final db = ref.watch(appDatabaseProvider);
|
|
final habitFuture = (db.select(db.habits)
|
|
..where((t) => t.id.equals(habitId)))
|
|
.getSingle();
|
|
final entriesFuture = ref.read(trackerDaoProvider).entriesForHabit(habitId);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('스트릭')),
|
|
body: FutureBuilder(
|
|
future: Future.wait([habitFuture, entriesFuture]),
|
|
builder: (context, snap) {
|
|
if (!snap.hasData) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
if (snap.hasError) {
|
|
return Center(child: Text('실패: ${snap.error}'));
|
|
}
|
|
final habit = snap.data![0] as dynamic;
|
|
final entryRows = snap.data![1] as List;
|
|
final entries = entryRows.map((r) {
|
|
return TrackerEntryModel(
|
|
id: r.id as String,
|
|
habitId: r.habitId as String,
|
|
date: r.date as String,
|
|
value: (r.value as String) == 'done'
|
|
? TrackerValue.done
|
|
: TrackerValue.blank,
|
|
variantId: r.variantId as String?,
|
|
ctxLocation: r.ctxLocation as String?,
|
|
ctxCondition: r.ctxCondition as String?,
|
|
note: r.note as String?,
|
|
loggedAt: r.loggedAt as String?,
|
|
);
|
|
}).toList();
|
|
final state = computeStreak(
|
|
entries: entries,
|
|
asOf: nowKst(),
|
|
habitStartedAt: habit.startedAt as String,
|
|
);
|
|
final theme = Theme.of(context);
|
|
return Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(habit.title as String,
|
|
style: theme.textTheme.titleLarge),
|
|
const SizedBox(height: 24),
|
|
// Hero — 핵심 동기 지표. 큰 숫자 + 티어 emoji 라벨로 위계 강조.
|
|
Center(
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
'${state.currentStreak}',
|
|
style: theme.textTheme.displayLarge?.copyWith(
|
|
fontWeight: FontWeight.w700,
|
|
color: theme.colorScheme.primary,
|
|
),
|
|
),
|
|
Text('일 연속 (현재 스트릭)',
|
|
style: theme.textTheme.bodyMedium),
|
|
const SizedBox(height: 4),
|
|
Text(rewardTierLabel(state.currentTier),
|
|
style: theme.textTheme.titleMedium),
|
|
],
|
|
),
|
|
),
|
|
const Divider(height: 40),
|
|
_Row('최장 스트릭', '${state.longestStreak}일'),
|
|
_Row('최근 30일 / 완료', '${state.doneCountInWindow30}회'),
|
|
_Row('Phase 42일 / 완료', '${state.doneCountInPhase42}회'),
|
|
if (state.neverMissTwiceBroken)
|
|
const Padding(
|
|
padding: EdgeInsets.only(top: 12),
|
|
child: Text(
|
|
'⚠ 이틀 연속 빠졌어요. 한 단계 강등됐습니다.',
|
|
style: TextStyle(color: Colors.redAccent),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Row extends StatelessWidget {
|
|
final String label;
|
|
final String value;
|
|
const _Row(this.label, this.value);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
|
child: Row(
|
|
children: [
|
|
Expanded(child: Text(label)),
|
|
Text(value, style: const TextStyle(fontWeight: FontWeight.w600)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|