Files
unionflow-client-quarkus-pr…/unionflow-mobile-apps/lib/features/dashboard/presentation/widgets/quick_actions_grid.dart
2025-08-20 21:00:35 +00:00

214 lines
6.4 KiB
Dart

import 'package:flutter/material.dart';
import '../../../../shared/theme/app_theme.dart';
import '../../../../core/utils/responsive_utils.dart';
class QuickActionsGrid extends StatelessWidget {
const QuickActionsGrid({super.key});
@override
Widget build(BuildContext context) {
ResponsiveUtils.init(context);
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 15,
offset: const Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.all(20),
child: Text(
'Actions rapides',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: AppTheme.textPrimary,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
child: GridView.count(
crossAxisCount: 2,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisSpacing: 16,
mainAxisSpacing: 16,
childAspectRatio: 1.2,
children: _getQuickActions(context),
),
),
],
),
);
}
List<Widget> _getQuickActions(BuildContext context) {
final actions = [
QuickAction(
title: 'Nouveau membre',
description: 'Ajouter un membre',
icon: Icons.person_add,
color: AppTheme.primaryColor,
onTap: () => _showAction(context, 'Nouveau membre'),
),
QuickAction(
title: 'Créer événement',
description: 'Organiser un événement',
icon: Icons.event_available,
color: AppTheme.secondaryColor,
onTap: () => _showAction(context, 'Créer événement'),
),
QuickAction(
title: 'Suivi cotisations',
description: 'Gérer les cotisations',
icon: Icons.payment,
color: AppTheme.accentColor,
onTap: () => _showAction(context, 'Suivi cotisations'),
),
QuickAction(
title: 'Rapports',
description: 'Générer des rapports',
icon: Icons.analytics,
color: AppTheme.infoColor,
onTap: () => _showAction(context, 'Rapports'),
),
QuickAction(
title: 'Messages',
description: 'Envoyer des notifications',
icon: Icons.message,
color: AppTheme.warningColor,
onTap: () => _showAction(context, 'Messages'),
),
QuickAction(
title: 'Documents',
description: 'Gérer les documents',
icon: Icons.folder,
color: Color(0xFF9C27B0),
onTap: () => _showAction(context, 'Documents'),
),
];
return actions.map((action) => _buildActionCard(action)).toList();
}
Widget _buildActionCard(QuickAction action) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: action.onTap,
borderRadius: BorderRadius.circular(12),
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
border: Border.all(
color: action.color.withOpacity(0.2),
width: 1,
),
borderRadius: BorderRadius.circular(12),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Container(
width: ResponsiveUtils.iconSize(12),
height: ResponsiveUtils.iconSize(12),
decoration: BoxDecoration(
color: action.color.withOpacity(0.15),
borderRadius: BorderRadius.circular(ResponsiveUtils.iconSize(6)),
),
child: Icon(
action.icon,
color: action.color,
size: ResponsiveUtils.iconSize(6),
),
),
),
SizedBox(height: 2.hp),
Flexible(
child: Text(
action.title,
style: TextStyle(
fontSize: ResponsiveUtils.adaptive(
small: 3.5.fs,
medium: 3.2.fs,
large: 3.fs,
),
fontWeight: FontWeight.w600,
color: AppTheme.textPrimary,
),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
SizedBox(height: 0.5.hp),
Flexible(
child: Text(
action.description,
style: TextStyle(
fontSize: ResponsiveUtils.adaptive(
small: 2.8.fs,
medium: 2.6.fs,
large: 2.4.fs,
),
color: AppTheme.textSecondary,
),
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
),
);
}
void _showAction(BuildContext context, String actionName) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('$actionName - En cours de développement'),
backgroundColor: AppTheme.primaryColor,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
action: SnackBarAction(
label: 'OK',
textColor: Colors.white,
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
},
),
),
);
}
}
class QuickAction {
final String title;
final String description;
final IconData icon;
final Color color;
final VoidCallback onTap;
QuickAction({
required this.title,
required this.description,
required this.icon,
required this.color,
required this.onTap,
});
}