feat: Simplify message state management by removing intermediate states and updating UI logic
This commit is contained in:
@@ -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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user