Files
unionflow-mobile-apps/lib/features/communication/presentation/pages/conversations_page.dart
dahoud b63fc46182 feat(mobile): amélioration UX NotImplementedFailure + SnackbarHelper
- NotImplementedFailure: ajout userFriendlyMessage et icon construction (blue)
- ErrorDisplayWidget: support spécial pour NotImplementedFailure (bientôt disponible)
- SnackbarHelper: classe centralisée pour messages cohérents (success, error, warning, info, notImplemented)
- budgets_list_page: remplace generic snackbar par SnackbarHelper.showNotImplemented
- conversations_page: remplace 2 TODOs par SnackbarHelper.showNotImplemented
- export_members: met à jour TODO obsolète (endpoint PDF maintenant disponible)
- cache_service: fix AppLogger.error calls (error: named param)
- cached_datasource_decorator: fix AppLogger.error call

Task #64 - Fix Snackbar Placeholders + NotImplementedFailure UX
2026-03-17 10:06:21 +00:00

146 lines
5.1 KiB
Dart

/// Page liste des conversations
library conversations_page;
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../core/di/injection_container.dart';
import '../../../../shared/design_system/unionflow_design_system.dart';
import '../../../../shared/utils/snackbar_helper.dart';
import '../bloc/messaging_bloc.dart';
import '../bloc/messaging_event.dart';
import '../bloc/messaging_state.dart';
import '../widgets/conversation_tile.dart';
class ConversationsPage extends StatelessWidget {
final String? organizationId;
const ConversationsPage({
super.key,
this.organizationId,
});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (_) => sl<MessagingBloc>()
..add(LoadConversations(organizationId: organizationId)),
child: Scaffold(
backgroundColor: ColorTokens.background,
appBar: const UFAppBar(
title: 'MESSAGES',
automaticallyImplyLeading: true,
),
body: BlocBuilder<MessagingBloc, MessagingState>(
builder: (context, state) {
if (state is MessagingLoading) {
return const Center(child: CircularProgressIndicator());
}
if (state is MessagingError) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.error_outline,
size: 64,
color: AppColors.error,
),
const SizedBox(height: SpacingTokens.md),
Text(
'Erreur',
style: AppTypography.headerSmall,
),
const SizedBox(height: SpacingTokens.sm),
Text(
state.message,
style: AppTypography.bodyTextSmall,
textAlign: TextAlign.center,
),
const SizedBox(height: SpacingTokens.lg),
UFPrimaryButton(
label: 'Réessayer',
onPressed: () {
context.read<MessagingBloc>().add(
LoadConversations(organizationId: organizationId),
);
},
),
],
),
);
}
if (state is ConversationsLoaded) {
final conversations = state.conversations;
if (conversations.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.chat_bubble_outline,
size: 64,
color: AppColors.textSecondaryLight,
),
const SizedBox(height: SpacingTokens.md),
Text(
'Aucune conversation',
style: AppTypography.headerSmall.copyWith(
color: AppColors.textSecondaryLight,
),
),
const SizedBox(height: SpacingTokens.sm),
Text(
'Commencez une nouvelle conversation',
style: AppTypography.bodyTextSmall.copyWith(
color: AppColors.textSecondaryLight,
),
),
],
),
);
}
return RefreshIndicator(
onRefresh: () async {
context.read<MessagingBloc>().add(
LoadConversations(organizationId: organizationId),
);
},
child: ListView.separated(
padding: const EdgeInsets.all(SpacingTokens.md),
itemCount: conversations.length,
separatorBuilder: (_, __) => const SizedBox(height: SpacingTokens.sm),
itemBuilder: (context, index) {
final conversation = conversations[index];
return ConversationTile(
conversation: conversation,
onTap: () {
SnackbarHelper.showNotImplemented(
context,
'Affichage des messages',
);
},
);
},
),
);
}
return const SizedBox.shrink();
},
),
floatingActionButton: FloatingActionButton(
backgroundColor: AppColors.primaryGreen,
onPressed: () {
SnackbarHelper.showNotImplemented(context, 'Nouvelle conversation');
},
child: const Icon(Icons.add, color: Colors.white),
),
),
);
}
}