From 98861133610a71dfabafc88e7c36233e60404382 Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 11 Mar 2026 19:24:34 +0000 Subject: [PATCH] Eliminar creche_app/lib/features/children/children_list_screen.dart --- .../children/children_list_screen.dart | 241 ------------------ 1 file changed, 241 deletions(-) delete mode 100644 creche_app/lib/features/children/children_list_screen.dart diff --git a/creche_app/lib/features/children/children_list_screen.dart b/creche_app/lib/features/children/children_list_screen.dart deleted file mode 100644 index 18b129d..0000000 --- a/creche_app/lib/features/children/children_list_screen.dart +++ /dev/null @@ -1,241 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:go_router/go_router.dart'; -import '/core/supabase_client.dart'; -import '/models/child.dart'; - -class ChildrenListScreen extends ConsumerStatefulWidget { - const ChildrenListScreen({super.key}); - - @override - ConsumerState createState() => _ChildrenListScreenState(); -} - -class _ChildrenListScreenState extends ConsumerState { - String _searchQuery = ''; - String? _selectedClass; - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xFF1A1A2E), - appBar: AppBar( - backgroundColor: const Color(0xFF16213E), - title: const Text('Lista de Crianças', - style: TextStyle(color: Color(0xFF4FC3F7))), - actions: [ - IconButton( - icon: const Icon(Icons.add, color: Color(0xFF4FC3F7)), - onPressed: () => context.go('/child/new'), - ), - ], - ), - body: Column( - children: [ - // Barra de pesquisa + filtro - Padding( - padding: const EdgeInsets.all(12), - child: Row( - children: [ - Expanded( - child: TextField( - onChanged: (v) => - setState(() => _searchQuery = v.toLowerCase()), - style: const TextStyle(color: Colors.white), - decoration: InputDecoration( - hintText: 'Buscar por nome...', - hintStyle: const TextStyle(color: Color(0xFF888888)), - prefixIcon: const Icon(Icons.search, - color: Color(0xFF4FC3F7)), - filled: true, - fillColor: const Color(0xFF16213E), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: - const BorderSide(color: Color(0xFF333366)), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: const BorderSide( - color: Color(0xFF4FC3F7), width: 2), - ), - ), - ), - ), - const SizedBox(width: 8), - Container( - padding: const EdgeInsets.symmetric(horizontal: 8), - decoration: BoxDecoration( - color: const Color(0xFF16213E), - borderRadius: BorderRadius.circular(12), - border: Border.all(color: const Color(0xFF333366)), - ), - child: DropdownButton( - hint: const Text('Turma', - style: TextStyle(color: Color(0xFF888888))), - value: _selectedClass, - dropdownColor: const Color(0xFF16213E), - style: const TextStyle(color: Colors.white), - underline: const SizedBox(), - items: const [ - DropdownMenuItem( - value: null, - child: Text('Todas', - style: TextStyle(color: Color(0xFF888888)))), - DropdownMenuItem( - value: 'bercario1', child: Text('Berçário 1')), - DropdownMenuItem( - value: 'jardim2', child: Text('Jardim 2')), - ], - onChanged: (v) => setState(() => _selectedClass = v), - ), - ), - ], - ), - ), - - // Lista de crianças via stream - Expanded( - child: StreamBuilder>>( - stream: ref - .read(supabaseProvider) - .from('children') - .stream(primaryKey: ['id']), - builder: (context, snapshot) { - if (snapshot.hasError) { - return Center( - child: Text('Erro: ${snapshot.error}', - style: const TextStyle(color: Colors.red))); - } - if (!snapshot.hasData) { - return const Center( - child: CircularProgressIndicator( - color: Color(0xFF4FC3F7))); - } - - final children = snapshot.data! - .map(Child.fromMap) - .where((c) => - c.fullName.toLowerCase().contains(_searchQuery) && - (_selectedClass == null || - c.classId == _selectedClass)) - .toList(); - - if (children.isEmpty) { - return const Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(Icons.child_care, - size: 64, color: Color(0xFF333366)), - SizedBox(height: 16), - Text('Nenhuma criança encontrada', - style: TextStyle(color: Color(0xFF888888))), - ], - ), - ); - } - - return ListView.builder( - padding: const EdgeInsets.symmetric(horizontal: 12), - itemCount: children.length, - itemBuilder: (context, index) { - final child = children[index]; - return _ChildListCard( - child: child, - onTap: () => context.go('/child/${child.id}'), - ); - }, - ); - }, - ), - ), - ], - ), - ); - } -} - -class _ChildListCard extends StatelessWidget { - final Child child; - final VoidCallback onTap; - const _ChildListCard({required this.child, required this.onTap}); - - String get _moodEmoji { - switch (child.mood) { - case 'happy': return '😊'; - case 'sad': return '😟'; - case 'sick': return '🤒'; - case 'excited': return '😃'; - default: return '😐'; - } - } - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: onTap, - child: Container( - margin: const EdgeInsets.only(bottom: 10), - padding: const EdgeInsets.all(14), - decoration: BoxDecoration( - color: const Color(0xFF16213E), - borderRadius: BorderRadius.circular(16), - border: Border.all(color: const Color(0xFF333366)), - ), - child: Row( - children: [ - // Avatar - CircleAvatar( - radius: 30, - backgroundImage: child.photoUrl != null - ? NetworkImage(child.photoUrl!) - : null, - backgroundColor: const Color(0xFF4FC3F7).withOpacity(0.2), - child: child.photoUrl == null - ? const Icon(Icons.child_care, - color: Color(0xFF4FC3F7), size: 30) - : null, - ), - const SizedBox(width: 14), - // Info - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(child.fullName, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15)), - const SizedBox(height: 4), - Row( - children: [ - const Icon(Icons.cake, - size: 12, color: Color(0xFF888888)), - const SizedBox(width: 4), - Text('${child.age} anos', - style: const TextStyle( - color: Color(0xFF888888), fontSize: 12)), - const SizedBox(width: 12), - const Icon(Icons.school, - size: 12, color: Color(0xFF888888)), - const SizedBox(width: 4), - Text(child.classId, - style: const TextStyle( - color: Color(0xFF888888), fontSize: 12)), - ], - ), - ], - ), - ), - // Emoji humor - Text(_moodEmoji, style: const TextStyle(fontSize: 26)), - const SizedBox(width: 6), - const Icon(Icons.chevron_right, color: Color(0xFF888888)), - ], - ), - ), - ); - } -}