feat: Simplify message state management by removing intermediate states and updating UI logic

This commit is contained in:
Dayron
2025-10-20 17:51:16 +02:00
parent a2e366e1ce
commit 633d2c5e5c
3 changed files with 17 additions and 127 deletions

View File

@@ -159,17 +159,6 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
backgroundColor: Colors.red,
),
);
} else if (state is MessageSent || state is MessageUpdated) {
// Scroller vers le bas après l'envoi
WidgetsBinding.instance.addPostFrameCallback((_) {
if (_scrollController.hasClients) {
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
duration: const Duration(milliseconds: 300),
curve: Curves.easeOut,
);
}
});
}
},
builder: (context, state) {
@@ -277,26 +266,14 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
),
),
const SizedBox(width: 8),
BlocBuilder<MessageBloc, MessageState>(
builder: (context, state) {
if (state is MessageSending || state is MessageUpdating) {
return Container(
width: 48,
height: 48,
padding: const EdgeInsets.all(12),
child: const CircularProgressIndicator(strokeWidth: 2),
);
}
return IconButton(
onPressed: () => _sendMessage(currentUser),
icon: Icon(_editingMessage != null ? Icons.check : Icons.send),
style: IconButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Colors.white,
padding: const EdgeInsets.all(12),
),
);
},
IconButton(
onPressed: () => _sendMessage(currentUser),
icon: Icon(_editingMessage != null ? Icons.check : Icons.send),
style: IconButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Colors.white,
padding: const EdgeInsets.all(12),
),
),
],
),