Refactoring + Checkpoint
This commit is contained in:
105
lib/presentation/widgets/cards/statistics_section_card.dart
Normal file
105
lib/presentation/widgets/cards/statistics_section_card.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../../core/constants/colors.dart';
|
||||
import '../../../../../domain/entities/user.dart';
|
||||
import '../stat_tile.dart';
|
||||
|
||||
/// [StatisticsSectionCard] affiche les statistiques principales de l'utilisateur avec des animations.
|
||||
/// Ce composant est optimisé pour une expérience interactive et une traçabilité complète des actions via les logs.
|
||||
class StatisticsSectionCard extends StatelessWidget {
|
||||
final User user;
|
||||
|
||||
const StatisticsSectionCard({Key? key, required this.user}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("[LOG] Initialisation de StatisticsSectionCard pour l'utilisateur : ${user.userFirstName} ${user.userLastName}");
|
||||
|
||||
return Card(
|
||||
color: AppColors.cardColor.withOpacity(0.95),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
||||
elevation: 5,
|
||||
shadowColor: AppColors.darkPrimary.withOpacity(0.4),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Statistiques Personnelles',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// Liste des statistiques avec animations
|
||||
_buildAnimatedStatTile(
|
||||
icon: Icons.event,
|
||||
label: 'Événements Participés',
|
||||
value: '${user.eventsCount}',
|
||||
logMessage: "Affichage des événements participés : ${user.eventsCount}",
|
||||
),
|
||||
_buildDivider(),
|
||||
_buildAnimatedStatTile(
|
||||
icon: Icons.place,
|
||||
label: 'Établissements Visités',
|
||||
value: '${user.visitedPlacesCount}',
|
||||
logMessage: "Affichage des établissements visités : ${user.visitedPlacesCount}",
|
||||
),
|
||||
_buildDivider(),
|
||||
_buildAnimatedStatTile(
|
||||
icon: Icons.post_add,
|
||||
label: 'Publications',
|
||||
value: '${user.postsCount}',
|
||||
logMessage: "Affichage des publications : ${user.postsCount}",
|
||||
),
|
||||
_buildDivider(),
|
||||
_buildAnimatedStatTile(
|
||||
icon: Icons.group,
|
||||
label: 'Amis/Followers',
|
||||
value: '${user.friendsCount}',
|
||||
logMessage: "Affichage des amis/followers : ${user.friendsCount}",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Construit chaque `StatTile` avec une animation de transition en fondu et logue chaque statistique.
|
||||
Widget _buildAnimatedStatTile({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required String value,
|
||||
required String logMessage,
|
||||
}) {
|
||||
debugPrint("[LOG] $logMessage");
|
||||
|
||||
return TweenAnimationBuilder<double>(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
tween: Tween<double>(begin: 0, end: 1),
|
||||
curve: Curves.easeOut,
|
||||
builder: (context, opacity, child) {
|
||||
return Opacity(
|
||||
opacity: opacity,
|
||||
child: StatTile(
|
||||
icon: icon,
|
||||
label: label,
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Construit un séparateur visuel entre chaque statistique.
|
||||
Widget _buildDivider() {
|
||||
return Divider(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
height: 1,
|
||||
indent: 16,
|
||||
endIndent: 16,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user