feat(unionflow): ajout Spec-Kit, constitution, mission mutuelles
- Config Spec-Kit pour Spec-Driven Development - CONSTITUTION.md + .specify/memory/constitution.md - Commandes Cursor /speckit.*, règles projet - Mission: associations + mutuelles d'épargne et de financement - .gitignore: versionner config spec-kit unionflow Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
/// Page détail d'une demande d'aide + actions (approuver, rejeter)
|
||||
library demande_aide_detail_page;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../bloc/solidarity_bloc.dart';
|
||||
import '../../data/models/demande_aide_model.dart';
|
||||
|
||||
class DemandeAideDetailPage extends StatefulWidget {
|
||||
final String demandeId;
|
||||
|
||||
const DemandeAideDetailPage({super.key, required this.demandeId});
|
||||
|
||||
@override
|
||||
State<DemandeAideDetailPage> createState() => _DemandeAideDetailPageState();
|
||||
}
|
||||
|
||||
class _DemandeAideDetailPageState extends State<DemandeAideDetailPage> {
|
||||
final _currencyFormat = NumberFormat.currency(locale: 'fr_FR', symbol: 'FCFA');
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
context.read<SolidarityBloc>().add(LoadDemandeAideById(widget.demandeId));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Détail demande d\'aide'),
|
||||
),
|
||||
body: BlocConsumer<SolidarityBloc, SolidarityState>(
|
||||
listenWhen: (prev, curr) => prev.status != curr.status,
|
||||
listener: (context, state) {
|
||||
if (state.status == SolidarityStatus.error && state.message != null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.message!), backgroundColor: Colors.red),
|
||||
);
|
||||
}
|
||||
},
|
||||
buildWhen: (prev, curr) =>
|
||||
prev.demandeDetail != curr.demandeDetail || prev.status != curr.status,
|
||||
builder: (context, state) {
|
||||
if (state.status == SolidarityStatus.loading && state.demandeDetail == null) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
final d = state.demandeDetail;
|
||||
if (d == null) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error_outline, size: 64, color: Colors.grey),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Demande introuvable',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_InfoCard(title: 'Référence', value: d.numeroReference ?? d.id ?? '—'),
|
||||
_InfoCard(title: 'Statut', value: d.statutLibelle),
|
||||
_InfoCard(title: 'Titre', value: d.titre ?? '—'),
|
||||
if (d.type != null) _InfoCard(title: 'Type', value: d.typeLibelle),
|
||||
if (d.description != null && d.description!.isNotEmpty)
|
||||
_InfoCard(title: 'Description', value: d.description!),
|
||||
if (d.montantDemande != null && d.montantDemande! > 0)
|
||||
_InfoCard(
|
||||
title: 'Montant demandé',
|
||||
value: _currencyFormat.format(d.montantDemande!),
|
||||
),
|
||||
if (d.montantAccorde != null && d.montantAccorde! > 0)
|
||||
_InfoCard(
|
||||
title: 'Montant accordé',
|
||||
value: _currencyFormat.format(d.montantAccorde!),
|
||||
),
|
||||
if (d.demandeur != null) _InfoCard(title: 'Demandeur', value: d.demandeur!),
|
||||
if (d.dateDemande != null)
|
||||
_InfoCard(
|
||||
title: 'Date demande',
|
||||
value: DateFormat('dd/MM/yyyy').format(d.dateDemande!),
|
||||
),
|
||||
if (d.motif != null && d.motif!.isNotEmpty)
|
||||
_InfoCard(title: 'Motif', value: d.motif!),
|
||||
const SizedBox(height: 24),
|
||||
_ActionsSection(demande: d),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InfoCard extends StatelessWidget {
|
||||
final String title;
|
||||
final String value;
|
||||
|
||||
const _InfoCard({required this.title, required this.value});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(child: Text(value)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ActionsSection extends StatelessWidget {
|
||||
final DemandeAideModel demande;
|
||||
|
||||
const _ActionsSection({required this.demande});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bloc = context.read<SolidarityBloc>();
|
||||
if (demande.statut != 'EN_ATTENTE' && demande.statut != 'SOUMISE') {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
if (demande.id == null) return const SizedBox.shrink();
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
'Actions (admin)',
|
||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () => bloc.add(ApprouverDemandeAide(demande.id!)),
|
||||
icon: const Icon(Icons.check_circle),
|
||||
label: const Text('Approuver'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.green,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () => bloc.add(RejeterDemandeAide(demande.id!)),
|
||||
icon: const Icon(Icons.cancel),
|
||||
label: const Text('Rejeter'),
|
||||
style: OutlinedButton.styleFrom(foregroundColor: Colors.red),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
/// Page liste des demandes d'aide (solidarité)
|
||||
library demandes_aide_page;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../bloc/solidarity_bloc.dart';
|
||||
import '../../data/models/demande_aide_model.dart';
|
||||
import 'demande_aide_detail_page.dart';
|
||||
import '../widgets/create_demande_aide_dialog.dart';
|
||||
|
||||
class DemandesAidePage extends StatefulWidget {
|
||||
const DemandesAidePage({super.key});
|
||||
|
||||
@override
|
||||
State<DemandesAidePage> createState() => _DemandesAidePageState();
|
||||
}
|
||||
|
||||
class _DemandesAidePageState extends State<DemandesAidePage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
final _currencyFormat = NumberFormat.currency(locale: 'fr_FR', symbol: 'FCFA');
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 3, vsync: this);
|
||||
context.read<SolidarityBloc>().add(const LoadDemandesAide());
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _loadTab(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
context.read<SolidarityBloc>().add(const LoadDemandesAide());
|
||||
break;
|
||||
case 1:
|
||||
context.read<SolidarityBloc>().add(const SearchDemandesAide(statut: 'EN_ATTENTE'));
|
||||
break;
|
||||
case 2:
|
||||
context.read<SolidarityBloc>().add(const SearchDemandesAide(statut: 'APPROUVEE'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<SolidarityBloc, SolidarityState>(
|
||||
listener: (context, state) {
|
||||
if (state.status == SolidarityStatus.error && state.message != null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.message!),
|
||||
backgroundColor: Colors.red,
|
||||
action: SnackBarAction(
|
||||
label: 'Réessayer',
|
||||
textColor: Colors.white,
|
||||
onPressed: () => _loadTab(_tabController.index),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Demandes d\'aide'),
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
onTap: _loadTab,
|
||||
tabs: const [
|
||||
Tab(text: 'Toutes', icon: Icon(Icons.list)),
|
||||
Tab(text: 'En attente', icon: Icon(Icons.schedule)),
|
||||
Tab(text: 'Approuvées', icon: Icon(Icons.check_circle_outline)),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () => _showCreateDialog(),
|
||||
tooltip: 'Nouvelle demande',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_buildList(null),
|
||||
_buildList('EN_ATTENTE'),
|
||||
_buildList('APPROUVEE'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildList(String? statutFilter) {
|
||||
return BlocBuilder<SolidarityBloc, SolidarityState>(
|
||||
buildWhen: (prev, curr) =>
|
||||
prev.status != curr.status || prev.demandes != curr.demandes,
|
||||
builder: (context, state) {
|
||||
if (state.status == SolidarityStatus.loading && state.demandes.isEmpty) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
var list = state.demandes;
|
||||
if (statutFilter != null) {
|
||||
list = list.where((d) => d.statut == statutFilter).toList();
|
||||
}
|
||||
if (list.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.volunteer_activism, size: 64, color: Colors.grey[400]),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Aucune demande d\'aide',
|
||||
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextButton.icon(
|
||||
onPressed: () => _showCreateDialog(),
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('Créer une demande'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async => _loadTab(_tabController.index),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: list.length,
|
||||
itemBuilder: (context, index) {
|
||||
final d = list[index];
|
||||
return _DemandeCard(
|
||||
demande: d,
|
||||
currencyFormat: _currencyFormat,
|
||||
onTap: () => _openDetail(d),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _openDetail(DemandeAideModel d) {
|
||||
if (d.id == null) return;
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BlocProvider.value(
|
||||
value: context.read<SolidarityBloc>(),
|
||||
child: DemandeAideDetailPage(demandeId: d.id!),
|
||||
),
|
||||
),
|
||||
).then((_) => _loadTab(_tabController.index));
|
||||
}
|
||||
|
||||
void _showCreateDialog() {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => CreateDemandeAideDialog(
|
||||
onCreated: () {
|
||||
Navigator.of(context).pop();
|
||||
_loadTab(_tabController.index);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DemandeCard extends StatelessWidget {
|
||||
final DemandeAideModel demande;
|
||||
final NumberFormat currencyFormat;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _DemandeCard({
|
||||
required this.demande,
|
||||
required this.currencyFormat,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
demande.titre ?? demande.numeroReference ?? demande.id ?? '—',
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
_StatutChip(statut: demande.statut),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
if (demande.type != null)
|
||||
Text(
|
||||
demande.typeLibelle,
|
||||
style: theme.textTheme.bodySmall?.copyWith(color: Colors.grey[600]),
|
||||
),
|
||||
if (demande.montantDemande != null && demande.montantDemande! > 0) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
currencyFormat.format(demande.montantDemande),
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (demande.dateDemande != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
DateFormat('dd/MM/yyyy').format(demande.dateDemande!),
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StatutChip extends StatelessWidget {
|
||||
final String? statut;
|
||||
|
||||
const _StatutChip({this.statut});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color color;
|
||||
switch (statut) {
|
||||
case 'BROUILLON':
|
||||
color = Colors.grey;
|
||||
break;
|
||||
case 'SOUMISE':
|
||||
case 'EN_ATTENTE':
|
||||
color = Colors.orange;
|
||||
break;
|
||||
case 'APPROUVEE':
|
||||
color = Colors.green;
|
||||
break;
|
||||
case 'REJETEE':
|
||||
color = Colors.red;
|
||||
break;
|
||||
case 'TERMINEE':
|
||||
color = Colors.blue;
|
||||
break;
|
||||
default:
|
||||
color = Colors.grey;
|
||||
}
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
statut ?? '—',
|
||||
style: TextStyle(fontSize: 12, color: color, fontWeight: FontWeight.w500),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/// Wrapper BLoC pour la page des demandes d'aide
|
||||
library demandes_aide_page_wrapper;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import '../../bloc/solidarity_bloc.dart';
|
||||
import 'demandes_aide_page.dart';
|
||||
|
||||
final _getIt = GetIt.instance;
|
||||
|
||||
class DemandesAidePageWrapper extends StatelessWidget {
|
||||
const DemandesAidePageWrapper({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<SolidarityBloc>(
|
||||
create: (context) {
|
||||
final bloc = _getIt<SolidarityBloc>();
|
||||
bloc.add(const LoadDemandesAide());
|
||||
return bloc;
|
||||
},
|
||||
child: const DemandesAidePage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user