Enhance model and service documentation with detailed comments and descriptions
- Updated Group, Trip, User, and other model classes to include comprehensive documentation for better understanding and maintainability. - Improved error handling and logging in services, including AuthService, ErrorService, and StorageService. - Added validation and business logic explanations in ExpenseService and TripService. - Refactored method comments to follow a consistent format across the codebase. - Translated error messages and comments from French to English for consistency.
This commit is contained in:
@@ -8,9 +8,26 @@ import '../../blocs/message/message_state.dart';
|
||||
import '../../models/group.dart';
|
||||
import '../../models/message.dart';
|
||||
|
||||
/// Chat group content widget for group messaging functionality.
|
||||
///
|
||||
/// This widget provides a complete chat interface for group members to
|
||||
/// communicate within a travel group. Features include:
|
||||
/// - Real-time message loading and sending
|
||||
/// - Message editing and deletion
|
||||
/// - Message reactions (like/unlike)
|
||||
/// - Scroll-to-bottom functionality
|
||||
/// - Message status indicators
|
||||
///
|
||||
/// The widget integrates with MessageBloc for state management and
|
||||
/// handles various message operations through the bloc pattern.
|
||||
class ChatGroupContent extends StatefulWidget {
|
||||
/// The group for which to display the chat interface
|
||||
final Group group;
|
||||
|
||||
/// Creates a chat group content widget.
|
||||
///
|
||||
/// Args:
|
||||
/// [group]: The group object containing group details and ID
|
||||
const ChatGroupContent({
|
||||
super.key,
|
||||
required this.group,
|
||||
@@ -21,14 +38,19 @@ class ChatGroupContent extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChatGroupContentState extends State<ChatGroupContent> {
|
||||
/// Controller for the message input field
|
||||
final _messageController = TextEditingController();
|
||||
|
||||
/// Controller for managing scroll position in the message list
|
||||
final _scrollController = ScrollController();
|
||||
|
||||
/// Currently selected message for editing (null if not editing)
|
||||
Message? _editingMessage;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Charger les messages au démarrage
|
||||
// Load messages when the widget initializes
|
||||
context.read<MessageBloc>().add(LoadMessages(widget.group.id));
|
||||
}
|
||||
|
||||
@@ -39,12 +61,20 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Sends a new message or updates an existing message.
|
||||
///
|
||||
/// Handles both sending new messages and editing existing ones based
|
||||
/// on the current editing state. Validates input and clears the input
|
||||
/// field after successful submission.
|
||||
///
|
||||
/// Args:
|
||||
/// [currentUser]: The user sending or editing the message
|
||||
void _sendMessage(user_state.UserModel currentUser) {
|
||||
final messageText = _messageController.text.trim();
|
||||
if (messageText.isEmpty) return;
|
||||
|
||||
if (_editingMessage != null) {
|
||||
// Mode édition
|
||||
// Edit mode - update existing message
|
||||
context.read<MessageBloc>().add(
|
||||
UpdateMessage(
|
||||
groupId: widget.group.id,
|
||||
@@ -54,7 +84,7 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
||||
);
|
||||
_cancelEdit();
|
||||
} else {
|
||||
// Mode envoi
|
||||
// Send mode - create new message
|
||||
context.read<MessageBloc>().add(
|
||||
SendMessage(
|
||||
groupId: widget.group.id,
|
||||
@@ -68,6 +98,13 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
||||
_messageController.clear();
|
||||
}
|
||||
|
||||
/// Initiates editing mode for a selected message.
|
||||
///
|
||||
/// Sets the message as the currently editing message and populates
|
||||
/// the input field with the message text for modification.
|
||||
///
|
||||
/// Args:
|
||||
/// [message]: The message to edit
|
||||
void _editMessage(Message message) {
|
||||
setState(() {
|
||||
_editingMessage = message;
|
||||
@@ -75,6 +112,10 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
||||
});
|
||||
}
|
||||
|
||||
/// Cancels the current editing operation.
|
||||
///
|
||||
/// Resets the editing state and clears the input field,
|
||||
/// returning to normal message sending mode.
|
||||
void _cancelEdit() {
|
||||
setState(() {
|
||||
_editingMessage = null;
|
||||
@@ -82,6 +123,13 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
||||
});
|
||||
}
|
||||
|
||||
/// Deletes a message from the group chat.
|
||||
///
|
||||
/// Sends a delete event to the MessageBloc to remove the specified
|
||||
/// message from the group's message history.
|
||||
///
|
||||
/// Args:
|
||||
/// [messageId]: The ID of the message to delete
|
||||
void _deleteMessage(String messageId) {
|
||||
context.read<MessageBloc>().add(
|
||||
DeleteMessage(
|
||||
|
||||
Reference in New Issue
Block a user