Files
dailyou/lib/features/log_mood/widgets/step_scale.dart
T
stefwill 6f3fb74e7e 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.
2026-04-26 12:14:45 +10:00

73 lines
2.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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,
),
],
),
),
),
);
}),
);
}
}