78 lines
2.8 KiB
Dart
78 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../core/date_keys.dart';
|
|
import '../models/app_state.dart';
|
|
import 'section_label.dart';
|
|
import 'seed_card.dart';
|
|
|
|
class WeeklyProgress extends StatelessWidget {
|
|
const WeeklyProgress({required this.state, super.key});
|
|
|
|
final AppState state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final days = lastSevenDateKeys();
|
|
return SeedCard(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const SectionLabel(
|
|
icon: Icons.insights_outlined,
|
|
text: '7-day pulse',
|
|
),
|
|
const SizedBox(height: 14),
|
|
Row(
|
|
children:
|
|
days.map((day) {
|
|
final minutes = minutesForDate(state.sessions, day);
|
|
final habits =
|
|
state.habits
|
|
.where((habit) => habit.completedDates.contains(day))
|
|
.length;
|
|
final hasReflection = state.reflections.any(
|
|
(reflection) => reflection.dateKey == day,
|
|
);
|
|
final score =
|
|
(minutes > 0 ? 1 : 0) +
|
|
(habits > 0 ? 1 : 0) +
|
|
(hasReflection ? 1 : 0);
|
|
return Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 3),
|
|
child: Column(
|
|
children: [
|
|
AnimatedContainer(
|
|
duration: const Duration(milliseconds: 180),
|
|
height: 48 + (score * 8),
|
|
decoration: BoxDecoration(
|
|
color:
|
|
score == 0
|
|
? Theme.of(
|
|
context,
|
|
).colorScheme.surfaceContainerHighest
|
|
: Theme.of(
|
|
context,
|
|
).colorScheme.primary.withValues(
|
|
alpha: 0.35 + score * 0.15,
|
|
),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
),
|
|
const SizedBox(height: 6),
|
|
Text(
|
|
day.substring(5),
|
|
style: Theme.of(context).textTheme.labelSmall,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|