import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import '../../../../core/services/auth_service.dart'; import '../../../../core/routing/app_router.dart'; /// Profile section with user info and achievements class ProfileSectionWidget extends StatelessWidget { const ProfileSectionWidget({super.key}); @override Widget build(BuildContext context) { final user = AuthService.currentUser; final userName = user?.displayName ?? 'Estudante'; final userEmail = user?.email ?? ''; return Container( margin: const EdgeInsets.only(top: 24), padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(16), border: Border.all( color: Theme.of(context).colorScheme.outline.withOpacity(0.2), ), boxShadow: [ BoxShadow( color: Theme.of(context).colorScheme.shadow.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 4), ), ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Profile Header Row( children: [ Container( width: 48, height: 48, decoration: BoxDecoration( gradient: LinearGradient( colors: [ Theme.of(context).colorScheme.primary, Theme.of( context, ).colorScheme.primary.withOpacity(0.8), ], ), borderRadius: BorderRadius.circular(24), ), child: const Icon( Icons.person, color: Colors.white, size: 24, ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( userName, style: TextStyle( color: Theme.of(context).colorScheme.onSurface, fontSize: 18, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 2), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( mainAxisSize: MainAxisSize.min, children: [ Text( userEmail, style: TextStyle( color: Theme.of( context, ).colorScheme.onSurfaceVariant, fontSize: 14, ), ), if (userEmail.length > 20) ...[ const SizedBox(width: 8), Icon( Icons.more_horiz, color: Theme.of( context, ).colorScheme.onSurfaceVariant, size: 16, ), ], ], ), ), ], ), ), GestureDetector( onTap: () { AppRouter.goToSettings(context); }, child: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: Theme.of( context, ).colorScheme.secondary.withOpacity(0.1), borderRadius: BorderRadius.circular(8), ), child: Icon( Icons.settings, color: Theme.of(context).colorScheme.secondary, size: 20, ), ), ), ], ), const SizedBox(height: 20), // Achievements Row( children: [ Icon( Icons.emoji_events, color: Theme.of(context).colorScheme.secondary, size: 20, ), const SizedBox(width: 8), Text( 'Conquistas', style: TextStyle( color: Theme.of(context).colorScheme.onSurface, fontSize: 16, fontWeight: FontWeight.bold, ), ), ], ), const SizedBox(height: 12), // Achievement Badges Row( children: [ _buildAchievementBadge( icon: Icons.local_fire_department, label: '7 dias', color: Theme.of(context).colorScheme.secondary, ), const SizedBox(width: 12), _buildAchievementBadge( icon: Icons.school, label: '3 conceitos', color: Theme.of(context).colorScheme.primary, ), const SizedBox(width: 12), _buildAchievementBadge( icon: Icons.speed, label: 'Rápido', color: Theme.of( context, ).colorScheme.primary.withOpacity(0.8), ), const SizedBox(width: 12), _buildAchievementBadge( icon: Icons.star, label: '100%', color: Theme.of(context).colorScheme.tertiary, ), ], ), const SizedBox(height: 20), // Recent Activity Summary Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: Theme.of(context).brightness == Brightness.dark ? Theme.of(context).colorScheme.surfaceContainerHighest : Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(12), border: Border.all( color: Theme.of( context, ).colorScheme.outline.withOpacity(0.2), ), ), child: Row( children: [ Icon( Icons.trending_up, color: Theme.of(context).colorScheme.primary, size: 20, ), const SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Ótimo progresso!', style: TextStyle( color: Theme.of(context).colorScheme.onSurface, fontSize: 14, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 2), Text( 'Você está 15% acima da média esta semana', style: TextStyle( color: Theme.of( context, ).colorScheme.onSurfaceVariant, fontSize: 12, ), ), ], ), ), ], ), ), ], ), ) .animate() .slideY( duration: const Duration(milliseconds: 800), curve: Curves.easeOut, ) .then(delay: const Duration(milliseconds: 400)); } Widget _buildAchievementBadge({ required IconData icon, required String label, required Color color, }) { return Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6), decoration: BoxDecoration( color: color.withOpacity(0.1), borderRadius: BorderRadius.circular(12), border: Border.all(color: color.withOpacity(0.3), width: 1), ), child: Column( children: [ Icon(icon, color: color, size: 16), const SizedBox(height: 4), Text( label, style: TextStyle( color: color, fontSize: 10, fontWeight: FontWeight.bold, ), ), ], ), ); } }