import 'package:flutter/material.dart';

class Childrensidebarwidget extends StatelessWidget{
  final void Function(String childId) onChildSelected;

  const Childrensidebarwidget({
    Key? key,
    required this.onChildSelected,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final children = [
      {'id': '1', 'name': 'Léna', 'photo': null, 'status': 'Actif'},
      {'id': '2', 'name': 'Noé', 'photo': null, 'status': 'Inactif'},
    ];

    return Container(
      color: const Color(0xFFF7F7F7),
      padding: const EdgeInsets.all(16),
      child: Column(
        children: [
          // Avatar parent + bouton
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              const CircleAvatar(radius: 24, child: Icon(Icons.person)),
              IconButton(
                icon: const Icon(Icons.add),
                onPressed: () {
                  // Naviguer vers ajout d'enfant
                },
              )
            ],
          ),
          const SizedBox(height: 16),
          const Text("Mes enfants", style: TextStyle(fontWeight: FontWeight.bold)),

          const SizedBox(height: 16),
          // Liste des enfants
          ...children.map((child) {
            return GestureDetector(
              onTap: () => onChildSelected(child['id']!),
              child: Card(
                color: child['status'] == 'Actif' ? Colors.teal.shade50 : Colors.white,
                child: ListTile(
                  leading: const CircleAvatar(child: Icon(Icons.child_care)),
                  title: Text(child['name']!),
                  subtitle: Text(child['status']!),
                ),
              ),
            );
          }).toList()
        ],
      ),
    );
  }
}