Files

54 lines
1.5 KiB
Dart
Raw Permalink Normal View History

import 'package:flutter/material.dart';
class MoodSelector extends StatelessWidget {
final int selected;
final List<String> emojis;
final List<String> labels;
final List<Color> colors;
final ValueChanged<int> onChanged;
const MoodSelector({
super.key,
required this.selected,
required this.emojis,
required this.labels,
required this.colors,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: List.generate(5, (i) {
final level = i + 1;
final isSelected = selected == level;
return GestureDetector(
onTap: () => onChanged(level),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeOut,
width: isSelected ? 64 : 52,
height: isSelected ? 64 : 52,
decoration: BoxDecoration(
color:
isSelected ? colors[i].withOpacity(0.15) : Colors.transparent,
shape: BoxShape.circle,
border: Border.all(
color: isSelected ? colors[i] : Colors.transparent,
width: 2,
),
),
child: Center(
child: Text(
emojis[i],
style: TextStyle(fontSize: isSelected ? 36 : 28),
),
),
),
);
}),
);
}
}