Phase 2 du MVP Flutter : vérification PIN locale, application des règles par famille, suivi des mouvements et correction avec plancher à 0. Co-authored-by: Cursor <cursoragent@cursor.com>
103 lines
3.5 KiB
Dart
103 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/theme/app_theme.dart';
|
|
import '../../../data/database/app_database.dart';
|
|
|
|
class ChildSelector extends StatelessWidget {
|
|
const ChildSelector({
|
|
super.key,
|
|
required this.children,
|
|
required this.selectedId,
|
|
required this.onSelected,
|
|
});
|
|
|
|
final List<Enfant> children;
|
|
final int selectedId;
|
|
final ValueChanged<int> onSelected;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
children: children.map((child) {
|
|
final selected = child.id == selectedId;
|
|
final color = AppTheme.parseColor(child.couleur);
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.only(right: 12),
|
|
child: InkWell(
|
|
onTap: () => onSelected(child.id),
|
|
borderRadius: BorderRadius.circular(16),
|
|
child: AnimatedContainer(
|
|
duration: const Duration(milliseconds: 150),
|
|
padding: const EdgeInsets.all(4),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(
|
|
color: selected ? color : Colors.transparent,
|
|
width: 3,
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
CircleAvatar(
|
|
radius: 32,
|
|
backgroundColor: color,
|
|
child: Text(
|
|
child.prenom[0].toUpperCase(),
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
right: -4,
|
|
bottom: -4,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 6,
|
|
vertical: 2,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: color),
|
|
),
|
|
child: Text(
|
|
'${child.score}',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: color,
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
child.prenom,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
fontWeight:
|
|
selected ? FontWeight.bold : FontWeight.normal,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
);
|
|
}
|
|
}
|