feat: implement multi-step mood logging wizard

Adds sleep/energy/positivity/self-worth tracking columns to the database
(schema v2 migration), a new 5-option StepScale widget, per-answer chips
at the top of the screen, a 2×2 activity grid chip, and a full step-by-step
wizard flow: mood → sleep (first entry today only) → energy → positivity →
self-worth → activities → review+save.
This commit is contained in:
2026-04-26 12:14:45 +10:00
parent 59597c7a4f
commit 6f3fb74e7e
10 changed files with 1142 additions and 129 deletions
@@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/database/app_database.dart';
import '../../../core/providers/activity_provider.dart';
/// 60 px chip showing selected activities:
/// - 0 selected : nothing (caller should not render)
/// - 1 selected : single Material icon centred
/// - 24 selected: 2×2 mini grid of 16 px icons
/// - 5+ selected : icon + count badge
class ActivitiesChip extends ConsumerWidget {
final Color backgroundColor;
final VoidCallback? onTap;
const ActivitiesChip({
super.key,
required this.backgroundColor,
this.onTap,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final activitiesAsync = ref.watch(activitiesProvider);
final selected = ref.watch(selectedActivitiesProvider);
return activitiesAsync.when(
loading: () => _shell(backgroundColor, onTap,
const CircularProgressIndicator(strokeWidth: 2)),
error: (_, __) => const SizedBox.shrink(),
data: (all) {
final picked =
all.where((a) => selected.contains(a.id)).toList();
if (picked.isEmpty) return const SizedBox(width: 60, height: 60);
return _shell(
backgroundColor,
onTap,
_iconContent(picked),
);
},
);
}
Widget _shell(Color bg, VoidCallback? tap, Widget child) {
return GestureDetector(
onTap: tap,
child: Container(
width: 60,
height: 60,
decoration: BoxDecoration(color: bg, shape: BoxShape.circle),
child: Center(child: child),
),
);
}
Widget _iconContent(List<Activity> picked) {
if (picked.length == 1) {
return Text(
String.fromCharCode(picked[0].iconCodepoint),
style: const TextStyle(
fontFamily: 'MaterialIcons',
fontSize: 24,
color: Colors.white,
),
);
}
final show = picked.take(4).toList();
return Wrap(
spacing: 2,
runSpacing: 2,
children: show
.map(
(a) => Text(
String.fromCharCode(a.iconCodepoint),
style: const TextStyle(
fontFamily: 'MaterialIcons',
fontSize: 16,
color: Colors.white,
),
),
)
.toList(),
);
}
}
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
/// A single 60 px circular answer chip showing either an emoji or short text.
class AnswerChip extends StatelessWidget {
final String label;
final Color backgroundColor;
final VoidCallback? onTap;
const AnswerChip({
super.key,
required this.label,
required this.backgroundColor,
this.onTap,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: AnimatedContainer(
duration: const Duration(milliseconds: 250),
curve: Curves.easeOut,
width: 60,
height: 60,
decoration: BoxDecoration(
color: backgroundColor,
shape: BoxShape.circle,
boxShadow: onTap != null
? [
BoxShadow(
color: backgroundColor.withValues(alpha: 0.4),
blurRadius: 8,
offset: const Offset(0, 2),
)
]
: null,
),
child: Center(
child: Text(
label,
style: const TextStyle(fontSize: 22),
textAlign: TextAlign.center,
),
),
),
);
}
}
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
/// Reusable 5-option emoji scale used for Energy, Positivity, Self-worth steps.
/// Tapping an option immediately calls [onSelected].
class StepScale extends StatelessWidget {
final List<String> emojis;
final List<String> labels;
final List<Color> colors;
final int? selected; // 15, null = nothing selected yet
final ValueChanged<int> onSelected;
const StepScale({
super.key,
required this.emojis,
required this.labels,
required this.colors,
required this.selected,
required this.onSelected,
});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: List.generate(5, (i) {
final level = i + 1;
final isSelected = selected == level;
final color = colors[i];
return GestureDetector(
onTap: () => onSelected(level),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeOut,
width: isSelected ? 64 : 52,
height: isSelected ? 64 : 52,
decoration: BoxDecoration(
color: isSelected
? color.withValues(alpha: 0.15)
: Colors.transparent,
shape: BoxShape.circle,
border: Border.all(
color: isSelected ? color : Colors.transparent,
width: 2,
),
),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
emojis[i],
style: TextStyle(fontSize: isSelected ? 30 : 24),
),
if (isSelected)
Text(
labels[i],
style: TextStyle(
fontSize: 9,
color: color,
fontWeight: FontWeight.w600,
),
overflow: TextOverflow.ellipsis,
),
],
),
),
),
);
}),
);
}
}