Merge pull request #53 from Iconica-Development/doc/improve-documentation

doc: create documentation for files
This commit is contained in:
Freek van de Ven 2024-03-14 14:03:56 +01:00 committed by GitHub
commit 37bac6c4cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 477 additions and 20 deletions

View file

@ -239,7 +239,7 @@ Please file any issues, bugs or feature request as an issue on our [GitHub](http
## Want to contribute ## Want to contribute
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide](../CONTRIBUTING.md) and send us your [pull request](https://github.com/Iconica-Development/flutter_chat/pulls). If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide](./CONTRIBUTING.md) and send us your [pull request](https://github.com/Iconica-Development/flutter_chat/pulls).
## Author ## Author

View file

@ -3,7 +3,9 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_chat/flutter_chat.dart'; import 'package:flutter_chat/flutter_chat.dart';
/// A widget representing an entry point for a chat UI.
class ChatEntryWidget extends StatefulWidget { class ChatEntryWidget extends StatefulWidget {
/// Constructs a [ChatEntryWidget].
const ChatEntryWidget({ const ChatEntryWidget({
this.chatService, this.chatService,
this.onTap, this.onTap,
@ -16,19 +18,35 @@ class ChatEntryWidget extends StatefulWidget {
super.key, super.key,
}); });
/// The chat service associated with the widget.
final ChatService? chatService; final ChatService? chatService;
/// Background color of the widget.
final Color backgroundColor; final Color backgroundColor;
/// Size of the widget.
final double widgetSize; final double widgetSize;
/// Background color of the counter.
final Color counterBackgroundColor; final Color counterBackgroundColor;
/// Callback function triggered when the widget is tapped.
final Function()? onTap; final Function()? onTap;
/// Icon to be displayed.
final IconData icon; final IconData icon;
/// Color of the icon.
final Color iconColor; final Color iconColor;
/// Text style for the counter.
final TextStyle? textStyle; final TextStyle? textStyle;
@override @override
State<ChatEntryWidget> createState() => _ChatEntryWidgetState(); State<ChatEntryWidget> createState() => _ChatEntryWidgetState();
} }
/// State class for [ChatEntryWidget].
class _ChatEntryWidgetState extends State<ChatEntryWidget> { class _ChatEntryWidgetState extends State<ChatEntryWidget> {
ChatService? chatService; ChatService? chatService;
@ -98,13 +116,17 @@ class _ChatEntryWidgetState extends State<ChatEntryWidget> {
); );
} }
/// Stateful widget representing an animated notification icon.
class _AnimatedNotificationIcon extends StatefulWidget { class _AnimatedNotificationIcon extends StatefulWidget {
const _AnimatedNotificationIcon({ const _AnimatedNotificationIcon({
required this.notifications, required this.notifications,
required this.icon, required this.icon,
}); });
/// The number of notifications.
final int notifications; final int notifications;
/// The icon to be displayed.
final Icon icon; final Icon icon;
@override @override
@ -112,6 +134,7 @@ class _AnimatedNotificationIcon extends StatefulWidget {
_AnimatedNotificationIconState(); _AnimatedNotificationIconState();
} }
/// State class for [_AnimatedNotificationIcon].
class _AnimatedNotificationIconState extends State<_AnimatedNotificationIcon> class _AnimatedNotificationIconState extends State<_AnimatedNotificationIcon>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
late AnimationController _animationController; late AnimationController _animationController;

View file

@ -5,6 +5,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_chat/flutter_chat.dart'; import 'package:flutter_chat/flutter_chat.dart';
/// Navigates to the chat user story screen.
///
/// [context]: The build context.
/// [configuration]: The configuration for the chat user story.
Widget chatNavigatorUserStory( Widget chatNavigatorUserStory(
BuildContext context, { BuildContext context, {
ChatUserStoryConfiguration? configuration, ChatUserStoryConfiguration? configuration,
@ -18,6 +22,10 @@ Widget chatNavigatorUserStory(
context, context,
); );
/// Constructs the chat screen route widget.
///
/// [configuration]: The configuration for the chat user story.
/// [context]: The build context.
Widget _chatScreenRoute( Widget _chatScreenRoute(
ChatUserStoryConfiguration configuration, ChatUserStoryConfiguration configuration,
BuildContext context, BuildContext context,
@ -65,6 +73,11 @@ Widget _chatScreenRoute(
translations: configuration.translations, translations: configuration.translations,
); );
/// Constructs the chat detail screen route widget.
///
/// [configuration]: The configuration for the chat user story.
/// [context]: The build context.
/// [chatId]: The id of the chat.
Widget _chatDetailScreenRoute( Widget _chatDetailScreenRoute(
ChatUserStoryConfiguration configuration, ChatUserStoryConfiguration configuration,
BuildContext context, BuildContext context,
@ -118,6 +131,12 @@ Widget _chatDetailScreenRoute(
iconColor: configuration.iconColor, iconColor: configuration.iconColor,
); );
/// Constructs the chat profile screen route widget.
///
/// [configuration]: The configuration for the chat user story.
/// [context]: The build context.
/// [chatId]: The id of the chat.
/// [userId]: The id of the user.
Widget _chatProfileScreenRoute( Widget _chatProfileScreenRoute(
ChatUserStoryConfiguration configuration, ChatUserStoryConfiguration configuration,
BuildContext context, BuildContext context,
@ -147,6 +166,10 @@ Widget _chatProfileScreenRoute(
}, },
); );
/// Constructs the new chat screen route widget.
///
/// [configuration]: The configuration for the chat user story.
/// [context]: The build context.
Widget _newChatScreenRoute( Widget _newChatScreenRoute(
ChatUserStoryConfiguration configuration, ChatUserStoryConfiguration configuration,
BuildContext context, BuildContext context,

View file

@ -5,6 +5,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
/// Builds a screen with a fade transition.
///
/// [context]: The build context.
/// [state]: The state of the GoRouter.
/// [child]: The child widget to be displayed.
CustomTransitionPage buildScreenWithFadeTransition<T>({ CustomTransitionPage buildScreenWithFadeTransition<T>({
required BuildContext context, required BuildContext context,
required GoRouterState state, required GoRouterState state,
@ -17,6 +22,11 @@ CustomTransitionPage buildScreenWithFadeTransition<T>({
FadeTransition(opacity: animation, child: child), FadeTransition(opacity: animation, child: child),
); );
/// Builds a screen without any transition.
///
/// [context]: The build context.
/// [state]: The state of the GoRouter.
/// [child]: The child widget to be displayed.
CustomTransitionPage buildScreenWithoutTransition<T>({ CustomTransitionPage buildScreenWithoutTransition<T>({
required BuildContext context, required BuildContext context,
required GoRouterState state, required GoRouterState state,

View file

@ -7,8 +7,10 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_chat_view/flutter_chat_view.dart'; import 'package:flutter_chat_view/flutter_chat_view.dart';
/// `ChatUserStoryConfiguration` is a class that configures the chat user story.
@immutable @immutable
class ChatUserStoryConfiguration { class ChatUserStoryConfiguration {
/// Creates a new instance of `ChatUserStoryConfiguration`.
const ChatUserStoryConfiguration({ const ChatUserStoryConfiguration({
required this.chatService, required this.chatService,
required this.chatOptionsBuilder, required this.chatOptionsBuilder,
@ -30,30 +32,63 @@ class ChatUserStoryConfiguration {
this.messagePageSize = 20, this.messagePageSize = 20,
this.onPressUserProfile, this.onPressUserProfile,
}); });
/// The service responsible for handling chat-related functionalities.
final ChatService chatService; final ChatService chatService;
/// Callback function triggered when a chat is pressed.
final Function(BuildContext, ChatModel)? onPressChat; final Function(BuildContext, ChatModel)? onPressChat;
/// Callback function triggered when a chat is deleted.
final Function(BuildContext, ChatModel)? onDeleteChat; final Function(BuildContext, ChatModel)? onDeleteChat;
/// Translations for internationalization/localization support.
final ChatTranslations translations; final ChatTranslations translations;
/// Determines whether dismissing is disabled for permanent chats.
final bool disableDismissForPermanentChats; final bool disableDismissForPermanentChats;
/// Callback function for uploading an image.
final Future<void> Function(Uint8List image)? onUploadImage; final Future<void> Function(Uint8List image)? onUploadImage;
/// Callback function for submitting a message.
final Future<void> Function(String text)? onMessageSubmit; final Future<void> Function(String text)? onMessageSubmit;
/// Called after a new message is sent. This can be used to do something /// Called after a new message is sent. This can be used to do something
/// extra like sending a push notification. /// extra like sending a push notification.
final Function(String chatId)? afterMessageSent; final Function(String chatId)? afterMessageSent;
/// Callback function triggered when a chat is read.
final Future<void> Function(ChatModel chat)? onReadChat; final Future<void> Function(ChatModel chat)? onReadChat;
/// Callback function triggered when creating a chat.
final Function(ChatUserModel)? onPressCreateChat; final Function(ChatUserModel)? onPressCreateChat;
/// Builder for chat options based on context.
final ChatOptions Function(BuildContext context) chatOptionsBuilder; final ChatOptions Function(BuildContext context) chatOptionsBuilder;
/// If true, the user will be routed to the new chat screen if there are /// If true, the user will be routed to the new chat screen if there are
/// no chats. /// no chats.
final bool routeToNewChatIfEmpty; final bool routeToNewChatIfEmpty;
/// The size of each page of messages.
final int messagePageSize; final int messagePageSize;
/// Dialog for confirming chat deletion.
final Future<bool?> Function(BuildContext, ChatModel)? deleteChatDialog; final Future<bool?> Function(BuildContext, ChatModel)? deleteChatDialog;
/// Callback function triggered when chat title is pressed.
final Function(BuildContext context, ChatModel chat)? onPressChatTitle; final Function(BuildContext context, ChatModel chat)? onPressChatTitle;
/// Color of icons.
final Color? iconColor; final Color? iconColor;
/// Builder for the chat page.
final Widget Function(BuildContext context, Widget child)? chatPageBuilder; final Widget Function(BuildContext context, Widget child)? chatPageBuilder;
/// Callback function triggered when starting a chat.
final Function()? onPressStartChat; final Function()? onPressStartChat;
/// Callback function triggered when user profile is pressed.
final Function()? onPressUserProfile; final Function()? onPressUserProfile;
} }

View file

@ -2,12 +2,19 @@
// //
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
/// Provides route paths for the chat user story.
mixin ChatUserStoryRoutes { mixin ChatUserStoryRoutes {
static const String chatScreen = '/chat'; static const String chatScreen = '/chat';
/// Constructs the path for the chat detail view.
static String chatDetailViewPath(String chatId) => '/chat-detail/$chatId'; static String chatDetailViewPath(String chatId) => '/chat-detail/$chatId';
static const String chatDetailScreen = '/chat-detail/:id'; static const String chatDetailScreen = '/chat-detail/:id';
static const String newChatScreen = '/new-chat'; static const String newChatScreen = '/new-chat';
/// Constructs the path for the chat profile screen.
static String chatProfileScreenPath(String chatId, String? userId) => static String chatProfileScreenPath(String chatId, String? userId) =>
'/chat-profile/$chatId/$userId'; '/chat-profile/$chatId/$userId';
static const String chatProfileScreen = '/chat-profile/:id/:userId'; static const String chatProfileScreen = '/chat-profile/:id/:userId';
} }

View file

@ -4,8 +4,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Options for Firebase chat configuration.
@immutable @immutable
class FirebaseChatOptions { class FirebaseChatOptions {
/// Creates a new instance of `FirebaseChatOptions`.
const FirebaseChatOptions({ const FirebaseChatOptions({
this.groupChatsCollectionName = 'group_chats', this.groupChatsCollectionName = 'group_chats',
this.chatsCollectionName = 'chats', this.chatsCollectionName = 'chats',
@ -15,15 +17,26 @@ class FirebaseChatOptions {
this.userChatsCollectionName = 'chats', this.userChatsCollectionName = 'chats',
}); });
/// The collection name for group chats.
final String groupChatsCollectionName; final String groupChatsCollectionName;
/// The collection name for chats.
final String chatsCollectionName; final String chatsCollectionName;
/// The collection name for messages.
final String messagesCollectionName; final String messagesCollectionName;
/// The collection name for users.
final String usersCollectionName; final String usersCollectionName;
/// The collection name for chat metadata.
final String chatsMetaDataCollectionName; final String chatsMetaDataCollectionName;
///This is the collection inside the user document. /// The collection name for user chats.
final String userChatsCollectionName; final String userChatsCollectionName;
/// Creates a copy of this FirebaseChatOptions but with the given fields
/// replaced with the new values.
FirebaseChatOptions copyWith({ FirebaseChatOptions copyWith({
String? groupChatsCollectionName, String? groupChatsCollectionName,
String? chatsCollectionName, String? chatsCollectionName,

View file

@ -6,8 +6,10 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_chat_firebase/dto/firebase_message_document.dart'; import 'package:flutter_chat_firebase/dto/firebase_message_document.dart';
/// Represents a chat document in Firebase.
@immutable @immutable
class FirebaseChatDocument { class FirebaseChatDocument {
/// Creates a new instance of `FirebaseChatDocument`.
const FirebaseChatDocument({ const FirebaseChatDocument({
required this.personal, required this.personal,
required this.canBeDeleted, required this.canBeDeleted,
@ -19,6 +21,7 @@ class FirebaseChatDocument {
this.lastMessage, this.lastMessage,
}); });
/// Constructs a FirebaseChatDocument from JSON.
FirebaseChatDocument.fromJson(Map<String, dynamic> json, this.id) FirebaseChatDocument.fromJson(Map<String, dynamic> json, this.id)
: title = json['title'], : title = json['title'],
imageUrl = json['image_url'], imageUrl = json['image_url'],
@ -33,15 +36,31 @@ class FirebaseChatDocument {
null, null,
); );
/// The unique identifier of the chat document.
final String? id; final String? id;
/// The title of the chat.
final String? title; final String? title;
/// The image URL of the chat.
final String? imageUrl; final String? imageUrl;
/// Indicates if the chat is personal.
final bool personal; final bool personal;
/// Indicates if the chat can be deleted.
final bool canBeDeleted; final bool canBeDeleted;
/// The timestamp of when the chat was last used.
final Timestamp? lastUsed; final Timestamp? lastUsed;
/// The list of users participating in the chat.
final List<String> users; final List<String> users;
/// The last message in the chat.
final FirebaseMessageDocument? lastMessage; final FirebaseMessageDocument? lastMessage;
/// Converts the FirebaseChatDocument to JSON format.
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'title': title, 'title': title,
'image_url': imageUrl, 'image_url': imageUrl,

View file

@ -5,8 +5,10 @@
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Represents a message document in Firebase.
@immutable @immutable
class FirebaseMessageDocument { class FirebaseMessageDocument {
/// Creates a new instance of `FirebaseMessageDocument`.
const FirebaseMessageDocument({ const FirebaseMessageDocument({
required this.sender, required this.sender,
required this.timestamp, required this.timestamp,
@ -15,18 +17,29 @@ class FirebaseMessageDocument {
this.imageUrl, this.imageUrl,
}); });
/// Constructs a FirebaseMessageDocument from JSON.
FirebaseMessageDocument.fromJson(Map<String, dynamic> json, this.id) FirebaseMessageDocument.fromJson(Map<String, dynamic> json, this.id)
: sender = json['sender'], : sender = json['sender'],
text = json['text'], text = json['text'],
imageUrl = json['image_url'], imageUrl = json['image_url'],
timestamp = json['timestamp']; timestamp = json['timestamp'];
/// The unique identifier of the message document.
final String? id; final String? id;
/// The sender of the message.
final String sender; final String sender;
/// The text content of the message.
final String? text; final String? text;
/// The image URL of the message.
final String? imageUrl; final String? imageUrl;
/// The timestamp of when the message was sent.
final Timestamp timestamp; final Timestamp timestamp;
/// Converts the FirebaseMessageDocument to JSON format.
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'sender': sender, 'sender': sender,
'text': text, 'text': text,

View file

@ -4,8 +4,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Represents a user document in Firebase.
@immutable @immutable
class FirebaseUserDocument { class FirebaseUserDocument {
/// Creates a new instance of `FirebaseUserDocument`.
const FirebaseUserDocument({ const FirebaseUserDocument({
this.firstName, this.firstName,
this.lastName, this.lastName,
@ -13,6 +15,7 @@ class FirebaseUserDocument {
this.id, this.id,
}); });
/// Constructs a FirebaseUserDocument from JSON.
FirebaseUserDocument.fromJson( FirebaseUserDocument.fromJson(
Map<String, Object?> json, Map<String, Object?> json,
String id, String id,
@ -26,11 +29,19 @@ class FirebaseUserDocument {
json['image_url'] == null ? null : json['image_url']! as String, json['image_url'] == null ? null : json['image_url']! as String,
); );
/// The first name of the user.
final String? firstName; final String? firstName;
/// The last name of the user.
final String? lastName; final String? lastName;
/// The image URL of the user.
final String? imageUrl; final String? imageUrl;
/// The unique identifier of the user document.
final String? id; final String? id;
/// Converts the FirebaseUserDocument to JSON format.
Map<String, Object?> toJson() => { Map<String, Object?> toJson() => {
'first_name': firstName, 'first_name': firstName,
'last_name': lastName, 'last_name': lastName,

View file

@ -13,9 +13,16 @@ import 'package:flutter_chat_firebase/dto/firebase_message_document.dart';
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
/// Service class for managing chat details using Firebase.
class FirebaseChatDetailService class FirebaseChatDetailService
with ChangeNotifier with ChangeNotifier
implements ChatDetailService { implements ChatDetailService {
/// Constructor for FirebaseChatDetailService.
///
/// [userService]: Instance of ChatUserService.
/// [app]: Optional FirebaseApp instance, defaults to Firebase.app().
/// [options]: Optional FirebaseChatOptions instance,
/// defaults to FirebaseChatOptions().
FirebaseChatDetailService({ FirebaseChatDetailService({
required ChatUserService userService, required ChatUserService userService,
FirebaseApp? app, FirebaseApp? app,
@ -123,6 +130,10 @@ class FirebaseChatDetailService
} }
} }
/// Sends a text message to a chat.
///
/// [text]: The text message to send.
/// [chatId]: The ID of the chat where the message will be sent.
@override @override
Future<void> sendTextMessage({ Future<void> sendTextMessage({
required String text, required String text,
@ -135,6 +146,10 @@ class FirebaseChatDetailService
}, },
); );
/// Sends an image message to a chat.
///
/// [chatId]: The ID of the chat where the message will be sent.
/// [image]: The image data to send.
@override @override
Future<void> sendImageMessage({ Future<void> sendImageMessage({
required String chatId, required String chatId,
@ -157,6 +172,9 @@ class FirebaseChatDetailService
); );
} }
/// Retrieves a stream of messages for a chat.
///
/// [chatId]: The ID of the chat.
@override @override
Stream<List<ChatMessageModel>> getMessagesStream(String chatId) { Stream<List<ChatMessageModel>> getMessagesStream(String chatId) {
timestampToFilter = DateTime.now(); timestampToFilter = DateTime.now();
@ -227,6 +245,7 @@ class FirebaseChatDetailService
return _controller!.stream; return _controller!.stream;
} }
/// Stops listening for messages.
@override @override
Future<void> stopListeningForMessages() async { Future<void> stopListeningForMessages() async {
await _subscription?.cancel(); await _subscription?.cancel();
@ -235,6 +254,10 @@ class FirebaseChatDetailService
_controller = null; _controller = null;
} }
/// Fetches more messages for a chat.
///
/// [pageSize]: The number of messages to fetch.
/// [chatId]: The ID of the chat.
@override @override
Future<void> fetchMoreMessage(int pageSize, String chatId) async { Future<void> fetchMoreMessage(int pageSize, String chatId) async {
if (lastChat == null) { if (lastChat == null) {
@ -313,6 +336,7 @@ class FirebaseChatDetailService
notifyListeners(); notifyListeners();
} }
/// Retrieves the list of messages.
@override @override
List<ChatMessageModel> getMessages() => _cumulativeMessages; List<ChatMessageModel> getMessages() => _cumulativeMessages;
} }

View file

@ -12,12 +12,19 @@ import 'package:flutter_chat_firebase/config/firebase_chat_options.dart';
import 'package:flutter_chat_firebase/dto/firebase_chat_document.dart'; import 'package:flutter_chat_firebase/dto/firebase_chat_document.dart';
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
/// Service class for managing chat overviews using Firebase.
class FirebaseChatOverviewService implements ChatOverviewService { class FirebaseChatOverviewService implements ChatOverviewService {
late FirebaseFirestore _db; late FirebaseFirestore _db;
late FirebaseStorage _storage; late FirebaseStorage _storage;
late ChatUserService _userService; late ChatUserService _userService;
late FirebaseChatOptions _options; late FirebaseChatOptions _options;
/// Constructor for FirebaseChatOverviewService.
///
/// [userService]: Instance of ChatUserService.
/// [app]: Optional FirebaseApp instance, defaults to Firebase.app().
/// [options]: Optional FirebaseChatOptions instance, defaults
/// to FirebaseChatOptions().
FirebaseChatOverviewService({ FirebaseChatOverviewService({
required ChatUserService userService, required ChatUserService userService,
FirebaseApp? app, FirebaseApp? app,
@ -45,6 +52,7 @@ class FirebaseChatOverviewService implements ChatOverviewService {
return snapshots.data()?['amount_unread_messages']; return snapshots.data()?['amount_unread_messages'];
} }
/// Retrieves a stream of chat overviews.
@override @override
Stream<List<ChatModel>> getChatsStream() { Stream<List<ChatModel>> getChatsStream() {
StreamSubscription? chatSubscription; StreamSubscription? chatSubscription;
@ -199,6 +207,9 @@ class FirebaseChatOverviewService implements ChatOverviewService {
return controller.stream; return controller.stream;
} }
/// Retrieves a chat by the given user.
///
/// [user]: The user associated with the chat.
@override @override
Future<ChatModel> getChatByUser(ChatUserModel user) async { Future<ChatModel> getChatByUser(ChatUserModel user) async {
var currentUser = await _userService.getCurrentUser(); var currentUser = await _userService.getCurrentUser();
@ -217,6 +228,9 @@ class FirebaseChatOverviewService implements ChatOverviewService {
); );
} }
/// Retrieves a chat by the given ID.
///
/// [chatId]: The ID of the chat.
@override @override
Future<ChatModel> getChatById(String chatId) async { Future<ChatModel> getChatById(String chatId) async {
var currentUser = await _userService.getCurrentUser(); var currentUser = await _userService.getCurrentUser();
@ -266,6 +280,9 @@ class FirebaseChatOverviewService implements ChatOverviewService {
} }
} }
/// Deletes the given chat.
///
/// [chat]: The chat to be deleted.
@override @override
Future<void> deleteChat(ChatModel chat) async { Future<void> deleteChat(ChatModel chat) async {
var chatCollection = await _db var chatCollection = await _db
@ -308,6 +325,9 @@ class FirebaseChatOverviewService implements ChatOverviewService {
} }
} }
/// Stores the given chat if it does not exist already.
///
/// [chat]: The chat to be stored.
@override @override
Future<ChatModel> storeChatIfNot(ChatModel chat) async { Future<ChatModel> storeChatIfNot(ChatModel chat) async {
if (chat.id == null) { if (chat.id == null) {
@ -392,6 +412,7 @@ class FirebaseChatOverviewService implements ChatOverviewService {
return chat; return chat;
} }
/// Retrieves a stream of the count of unread chats.
@override @override
Stream<int> getUnreadChatsCountStream() { Stream<int> getUnreadChatsCountStream() {
// open a stream to the user's chats collection and listen to changes in // open a stream to the user's chats collection and listen to changes in
@ -428,6 +449,9 @@ class FirebaseChatOverviewService implements ChatOverviewService {
return controller.stream; return controller.stream;
} }
/// Marks a chat as read.
///
/// [chat]: The chat to be marked as read.
@override @override
Future<void> readChat(ChatModel chat) async { Future<void> readChat(ChatModel chat) async {
// set the amount of read chats to the amount of messages in the chat // set the amount of read chats to the amount of messages in the chat
@ -436,6 +460,7 @@ class FirebaseChatOverviewService implements ChatOverviewService {
return; return;
} }
// set the amount of unread messages to 0 // set the amount of unread messages to 0
await _db await _db
.collection(_options.usersCollectionName) .collection(_options.usersCollectionName)
.doc(currentUser!.id) .doc(currentUser!.id)

View file

@ -3,6 +3,7 @@ import 'package:flutter_chat_firebase/config/firebase_chat_options.dart';
import 'package:flutter_chat_firebase/flutter_chat_firebase.dart'; import 'package:flutter_chat_firebase/flutter_chat_firebase.dart';
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
/// Service class for managing chat services using Firebase.
class FirebaseChatService implements ChatService { class FirebaseChatService implements ChatService {
FirebaseChatService({ FirebaseChatService({
this.options, this.options,
@ -29,10 +30,19 @@ class FirebaseChatService implements ChatService {
); );
} }
/// The options for configuring Firebase Chat.
final FirebaseChatOptions? options; final FirebaseChatOptions? options;
/// The Firebase app instance.
final FirebaseApp? app; final FirebaseApp? app;
/// The service for managing chat details.
ChatDetailService? firebaseChatDetailService; ChatDetailService? firebaseChatDetailService;
/// The service for managing chat overviews.
ChatOverviewService? firebaseChatOverviewService; ChatOverviewService? firebaseChatOverviewService;
/// The service for managing chat users.
ChatUserService? firebaseChatUserService; ChatUserService? firebaseChatUserService;
@override @override

View file

@ -9,7 +9,12 @@ import 'package:flutter_chat_firebase/config/firebase_chat_options.dart';
import 'package:flutter_chat_firebase/dto/firebase_user_document.dart'; import 'package:flutter_chat_firebase/dto/firebase_user_document.dart';
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
/// Service class for managing chat users using Firebase.
class FirebaseChatUserService implements ChatUserService { class FirebaseChatUserService implements ChatUserService {
/// Constructor for FirebaseChatUserService.
///
/// [app]: The Firebase app instance.
/// [options]: The options for configuring Firebase Chat.
FirebaseChatUserService({ FirebaseChatUserService({
FirebaseApp? app, FirebaseApp? app,
FirebaseChatOptions? options, FirebaseChatOptions? options,
@ -21,13 +26,22 @@ class FirebaseChatUserService implements ChatUserService {
_options = options ?? const FirebaseChatOptions(); _options = options ?? const FirebaseChatOptions();
} }
/// The Firebase Firestore instance.
late FirebaseFirestore _db; late FirebaseFirestore _db;
/// The Firebase Authentication instance.
late FirebaseAuth _auth; late FirebaseAuth _auth;
/// The options for configuring Firebase Chat.
late FirebaseChatOptions _options; late FirebaseChatOptions _options;
/// The current user.
ChatUserModel? _currentUser; ChatUserModel? _currentUser;
/// Map to cache user models.
final Map<String, ChatUserModel> _users = {}; final Map<String, ChatUserModel> _users = {};
/// Collection reference for users.
CollectionReference<FirebaseUserDocument> get _userCollection => _db CollectionReference<FirebaseUserDocument> get _userCollection => _db
.collection(_options.usersCollectionName) .collection(_options.usersCollectionName)
.withConverter<FirebaseUserDocument>( .withConverter<FirebaseUserDocument>(

View file

@ -14,7 +14,21 @@ abstract class ChatModelInterface {
bool get canBeDeleted; bool get canBeDeleted;
} }
/// A concrete implementation of [ChatModelInterface] representing a chat.
class ChatModel implements ChatModelInterface { class ChatModel implements ChatModelInterface {
/// Constructs a [ChatModel] instance.
///
/// [id]: The ID of the chat.
///
/// [messages]: The list of messages in the chat.
///
/// [unreadMessages]: The number of unread messages in the chat.
///
/// [lastUsed]: The timestamp when the chat was last used.
///
/// [lastMessage]: The last message sent in the chat.
///
/// [canBeDeleted]: Indicates whether the chat can be deleted.
ChatModel({ ChatModel({
this.id, this.id,
this.messages = const [], this.messages = const [],
@ -26,14 +40,19 @@ class ChatModel implements ChatModelInterface {
@override @override
String? id; String? id;
@override @override
final List<ChatMessageModel>? messages; final List<ChatMessageModel>? messages;
@override @override
final int? unreadMessages; final int? unreadMessages;
@override @override
final DateTime? lastUsed; final DateTime? lastUsed;
@override @override
final ChatMessageModel? lastMessage; final ChatMessageModel? lastMessage;
@override @override
final bool canBeDeleted; final bool canBeDeleted;
} }

View file

@ -5,25 +5,44 @@
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
/// An abstract class defining the interface for an image message in a chat.
abstract class ChatImageMessageModelInterface extends ChatMessageModel { abstract class ChatImageMessageModelInterface extends ChatMessageModel {
/// Constructs a [ChatImageMessageModelInterface] instance.
///
/// [sender]: The sender of the message.
///
/// [timestamp]: The timestamp when the message was sent.
ChatImageMessageModelInterface({ ChatImageMessageModelInterface({
required super.sender, required super.sender,
required super.timestamp, required super.timestamp,
}); });
/// Returns the URL of the image associated with the message.
String get imageUrl; String get imageUrl;
} }
/// A concrete implementation of [ChatImageMessageModelInterface]
/// representing an image message in a chat.
class ChatImageMessageModel implements ChatImageMessageModelInterface { class ChatImageMessageModel implements ChatImageMessageModelInterface {
/// Constructs a [ChatImageMessageModel] instance.
///
/// [sender]: The sender of the message.
///
/// [timestamp]: The timestamp when the message was sent.
///
/// [imageUrl]: The URL of the image associated with the message.
ChatImageMessageModel({ ChatImageMessageModel({
required this.sender, required this.sender,
required this.timestamp, required this.timestamp,
required this.imageUrl, required this.imageUrl,
}); });
@override @override
final ChatUserModel sender; final ChatUserModel sender;
@override @override
final DateTime timestamp; final DateTime timestamp;
@override @override
final String imageUrl; final String imageUrl;
} }

View file

@ -10,7 +10,14 @@ abstract class ChatMessageModelInterface {
DateTime get timestamp; DateTime get timestamp;
} }
/// A concrete implementation of [ChatMessageModelInterface]
/// representing a chat message.
class ChatMessageModel implements ChatMessageModelInterface { class ChatMessageModel implements ChatMessageModelInterface {
/// Constructs a [ChatMessageModel] instance.
///
/// [sender]: The sender of the message.
///
/// [timestamp]: The timestamp when the message was sent.
ChatMessageModel({ ChatMessageModel({
required this.sender, required this.sender,
required this.timestamp, required this.timestamp,
@ -18,6 +25,7 @@ class ChatMessageModel implements ChatMessageModelInterface {
@override @override
final ChatUserModel sender; final ChatUserModel sender;
@override @override
final DateTime timestamp; final DateTime timestamp;
} }

View file

@ -14,16 +14,28 @@ abstract class ChatTextMessageModelInterface extends ChatMessageModel {
String get text; String get text;
} }
/// A concrete implementation of [ChatTextMessageModelInterface]
/// representing a text message in a chat.
class ChatTextMessageModel implements ChatTextMessageModelInterface { class ChatTextMessageModel implements ChatTextMessageModelInterface {
/// Constructs a [ChatTextMessageModel] instance.
///
/// [sender]: The sender of the message.
///
/// [timestamp]: The timestamp when the message was sent.
///
/// [text]: The text content of the message.
ChatTextMessageModel({ ChatTextMessageModel({
required this.sender, required this.sender,
required this.timestamp, required this.timestamp,
required this.text, required this.text,
}); });
@override @override
final ChatUserModel sender; final ChatUserModel sender;
@override @override
final DateTime timestamp; final DateTime timestamp;
@override @override
final String text; final String text;
} }

View file

@ -12,7 +12,18 @@ abstract class ChatUserModelInterface {
String? get fullName; String? get fullName;
} }
/// A concrete implementation of [ChatUserModelInterface]
/// representing a chat user.
class ChatUserModel implements ChatUserModelInterface { class ChatUserModel implements ChatUserModelInterface {
/// Constructs a [ChatUserModel] instance.
///
/// [id]: The ID of the user.
///
/// [firstName]: The first name of the user.
///
/// [lastName]: The last name of the user.
///
/// [imageUrl]: The URL of the user's image.
ChatUserModel({ ChatUserModel({
this.id, this.id,
this.firstName, this.firstName,
@ -22,12 +33,16 @@ class ChatUserModel implements ChatUserModelInterface {
@override @override
final String? id; final String? id;
@override @override
final String? firstName; final String? firstName;
@override @override
final String? lastName; final String? lastName;
@override @override
final String? imageUrl; final String? imageUrl;
@override @override
String? get fullName { String? get fullName {
var fullName = ''; var fullName = '';

View file

@ -33,6 +33,25 @@ abstract class GroupChatModelInterface extends ChatModel {
} }
class GroupChatModel implements GroupChatModelInterface { class GroupChatModel implements GroupChatModelInterface {
/// Constructs a [GroupChatModel] instance.
///
/// [id]: The ID of the chat.
///
/// [messages]: The list of messages in the chat.
///
/// [unreadMessages]: The number of unread messages in the chat.
///
/// [lastUsed]: The timestamp when the chat was last used.
///
/// [lastMessage]: The last message sent in the chat.
///
/// [title]: The title of the group chat.
///
/// [imageUrl]: The URL of the image associated with the group chat.
///
/// [users]: The list of users participating in the group chat.
///
/// [canBeDeleted]: Indicates whether the chat can be deleted.
GroupChatModel({ GroupChatModel({
required this.canBeDeleted, required this.canBeDeleted,
required this.title, required this.title,

View file

@ -29,6 +29,21 @@ abstract class PersonalChatModelInterface extends ChatModel {
} }
class PersonalChatModel implements PersonalChatModelInterface { class PersonalChatModel implements PersonalChatModelInterface {
/// Constructs a [PersonalChatModel] instance.
///
/// [user]: The user involved in the personal chat.
///
/// [id]: The ID of the chat.
///
/// [messages]: The list of messages in the chat.
///
/// [unreadMessages]: The number of unread messages in the chat.
///
/// [lastUsed]: The timestamp when the chat was last used.
///
/// [lastMessage]: The last message sent in the chat.
///
/// [canBeDeleted]: Indicates whether the chat can be deleted.
PersonalChatModel({ PersonalChatModel({
required this.user, required this.user,
this.id, this.id,

View file

@ -2,24 +2,31 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
/// An abstract class defining the interface for a chat detail service.
abstract class ChatDetailService with ChangeNotifier { abstract class ChatDetailService with ChangeNotifier {
/// Sends a text message to the specified chat.
Future<void> sendTextMessage({ Future<void> sendTextMessage({
required String chatId, required String chatId,
required String text, required String text,
}); });
/// Sends an image message to the specified chat.
Future<void> sendImageMessage({ Future<void> sendImageMessage({
required String chatId, required String chatId,
required Uint8List image, required Uint8List image,
}); });
/// Retrieves a stream of messages for the specified chat.
Stream<List<ChatMessageModel>> getMessagesStream( Stream<List<ChatMessageModel>> getMessagesStream(
String chatId, String chatId,
); );
/// Fetches more messages for the specified chat with a given page size.
Future<void> fetchMoreMessage(int pageSize, String chatId); Future<void> fetchMoreMessage(int pageSize, String chatId);
/// Retrieves the list of messages for the chat.
List<ChatMessageModel> getMessages(); List<ChatMessageModel> getMessages();
/// Stops listening for messages.
void stopListeningForMessages(); void stopListeningForMessages();
} }

View file

@ -4,12 +4,24 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
import 'package:flutter_chat_local/local_chat_service.dart'; import 'package:flutter_chat_local/local_chat_service.dart';
/// A class providing local chat detail service implementation.
class LocalChatDetailService with ChangeNotifier implements ChatDetailService { class LocalChatDetailService with ChangeNotifier implements ChatDetailService {
/// Constructs a [LocalChatDetailService] instance.
///
/// [chatOverviewService]: The chat overview service.
LocalChatDetailService({required this.chatOverviewService}); LocalChatDetailService({required this.chatOverviewService});
/// The chat overview service.
final ChatOverviewService chatOverviewService; final ChatOverviewService chatOverviewService;
/// The list of cumulative messages.
final List<ChatMessageModel> _cumulativeMessages = []; final List<ChatMessageModel> _cumulativeMessages = [];
/// The stream controller for messages.
final StreamController<List<ChatMessageModel>> _controller = final StreamController<List<ChatMessageModel>> _controller =
StreamController<List<ChatMessageModel>>.broadcast(); StreamController<List<ChatMessageModel>>.broadcast();
/// The subscription for the stream.
late StreamSubscription? _subscription; late StreamSubscription? _subscription;
@override @override

View file

@ -3,12 +3,17 @@ import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
/// A class providing local chat overview service implementation.
class LocalChatOverviewService class LocalChatOverviewService
with ChangeNotifier with ChangeNotifier
implements ChatOverviewService { implements ChatOverviewService {
/// The list of personal chat models.
final List<PersonalChatModel> _chats = []; final List<PersonalChatModel> _chats = [];
/// Retrieves the list of personal chat models.
List<PersonalChatModel> get chats => _chats; List<PersonalChatModel> get chats => _chats;
/// The stream controller for chats.
final StreamController<List<ChatModel>> _chatsController = final StreamController<List<ChatModel>> _chatsController =
StreamController<List<ChatModel>>.broadcast(); StreamController<List<ChatModel>>.broadcast();

View file

@ -3,13 +3,21 @@ import 'package:flutter_chat_local/service/local_chat_detail_service.dart';
import 'package:flutter_chat_local/service/local_chat_overview_service.dart'; import 'package:flutter_chat_local/service/local_chat_overview_service.dart';
import 'package:flutter_chat_local/service/local_chat_user_service.dart'; import 'package:flutter_chat_local/service/local_chat_user_service.dart';
/// Service class for managing local chat services.
class LocalChatService implements ChatService { class LocalChatService implements ChatService {
/// Constructor for LocalChatService.
///
/// [localChatDetailService]: Optional local ChatDetailService instance,
/// defaults to LocalChatDetailService.
/// [localChatOverviewService]: Optional local ChatOverviewService instance,
/// defaults to LocalChatOverviewService.
/// [localChatUserService]: Optional local ChatUserService instance,
/// defaults to LocalChatUserService.
LocalChatService({ LocalChatService({
this.localChatDetailService, this.localChatDetailService,
this.localChatOverviewService, this.localChatOverviewService,
this.localChatUserService, this.localChatUserService,
}) { }) {
{
localChatOverviewService ??= LocalChatOverviewService(); localChatOverviewService ??= LocalChatOverviewService();
localChatDetailService ??= LocalChatDetailService( localChatDetailService ??= LocalChatDetailService(
chatOverviewService: localChatOverviewService!, chatOverviewService: localChatOverviewService!,
@ -17,10 +25,14 @@ class LocalChatService implements ChatService {
localChatUserService ??= LocalChatUserService(); localChatUserService ??= LocalChatUserService();
} }
}
/// The local chat detail service.
ChatDetailService? localChatDetailService; ChatDetailService? localChatDetailService;
/// The local chat overview service.
ChatOverviewService? localChatOverviewService; ChatOverviewService? localChatOverviewService;
/// The local chat user service.
ChatUserService? localChatUserService; ChatUserService? localChatUserService;
@override @override

View file

@ -1,6 +1,8 @@
import 'package:flutter_chat_interface/flutter_chat_interface.dart'; import 'package:flutter_chat_interface/flutter_chat_interface.dart';
/// Service class for managing local chat users.
class LocalChatUserService implements ChatUserService { class LocalChatUserService implements ChatUserService {
/// List of predefined chat users.
List<ChatUserModel> users = [ List<ChatUserModel> users = [
ChatUserModel( ChatUserModel(
id: '1', id: '1',
@ -15,6 +17,7 @@ class LocalChatUserService implements ChatUserService {
imageUrl: 'https://picsum.photos/200/300', imageUrl: 'https://picsum.photos/200/300',
), ),
]; ];
@override @override
Future<List<ChatUserModel>> getAllUsers() => Future.value(users); Future<List<ChatUserModel>> getAllUsers() => Future.value(users);

View file

@ -16,11 +16,22 @@ class ChatBottom extends StatefulWidget {
super.key, super.key,
}); });
/// Callback function invoked when a message is submitted.
final Future<void> Function(String text) onMessageSubmit; final Future<void> Function(String text) onMessageSubmit;
/// The builder function for the message input.
final TextInputBuilder messageInputBuilder; final TextInputBuilder messageInputBuilder;
/// Callback function invoked when the select image button is pressed.
final VoidCallback? onPressSelectImage; final VoidCallback? onPressSelectImage;
/// The chat model.
final ChatModel chat; final ChatModel chat;
/// The translations for the chat.
final ChatTranslations translations; final ChatTranslations translations;
/// The color of the icons.
final Color? iconColor; final Color? iconColor;
@override @override

View file

@ -18,12 +18,21 @@ class ChatDetailRow extends StatefulWidget {
super.key, super.key,
}); });
/// The translations for the chat.
final ChatTranslations translations; final ChatTranslations translations;
/// The chat message model.
final ChatMessageModel message; final ChatMessageModel message;
/// The builder function for user avatar.
final UserAvatarBuilder userAvatarBuilder; final UserAvatarBuilder userAvatarBuilder;
final bool showTime;
/// The previous chat message model.
final ChatMessageModel? previousMessage; final ChatMessageModel? previousMessage;
/// Flag indicating whether to show the time.
final bool showTime;
@override @override
State<ChatDetailRow> createState() => _ChatDetailRowState(); State<ChatDetailRow> createState() => _ChatDetailRowState();
} }

View file

@ -5,14 +5,23 @@
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// A stateless widget representing an image in the chat.
class ChatImage extends StatelessWidget { class ChatImage extends StatelessWidget {
/// Constructs a [ChatImage] widget.
///
/// [image]: The URL of the image.
///
/// [size]: The size of the image widget.
const ChatImage({ const ChatImage({
required this.image, required this.image,
this.size = 40, this.size = 40,
super.key, super.key,
}); });
/// The URL of the image.
final String image; final String image;
/// The size of the image widget.
final double size; final double size;
@override @override
@ -24,7 +33,7 @@ class ChatImage extends StatelessWidget {
), ),
width: size, width: size,
height: size, height: size,
child: image != '' child: image.isNotEmpty
? CachedNetworkImage( ? CachedNetworkImage(
imageUrl: image, imageUrl: image,
fit: BoxFit.cover, fit: BoxFit.cover,

View file

@ -13,12 +13,22 @@ class ChatRow extends StatelessWidget {
this.avatar, this.avatar,
super.key, super.key,
}); });
/// The title of the chat.
final String title; final String title;
/// The number of unread messages in the chat.
final int unreadMessages; final int unreadMessages;
final Widget? avatar;
final String? subTitle; /// The last time the chat was used.
final String? lastUsed; final String? lastUsed;
/// The subtitle of the chat.
final String? subTitle;
/// The avatar associated with the chat.
final Widget? avatar;
@override @override
Widget build(BuildContext context) => Row( Widget build(BuildContext context) => Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,

View file

@ -19,13 +19,28 @@ class ChatOptions {
this.noChatsPlaceholderBuilder = _createNoChatsPlaceholder, this.noChatsPlaceholderBuilder = _createNoChatsPlaceholder,
}); });
/// Builder function for the new chat button.
final ButtonBuilder newChatButtonBuilder; final ButtonBuilder newChatButtonBuilder;
/// Builder function for the message input field.
final TextInputBuilder messageInputBuilder; final TextInputBuilder messageInputBuilder;
/// Builder function for the container wrapping each chat row.
final ContainerBuilder chatRowContainerBuilder; final ContainerBuilder chatRowContainerBuilder;
/// Builder function for the container wrapping the image picker.
final ImagePickerContainerBuilder imagePickerContainerBuilder; final ImagePickerContainerBuilder imagePickerContainerBuilder;
/// Builder function for the scaffold containing the chat view.
final ScaffoldBuilder scaffoldBuilder; final ScaffoldBuilder scaffoldBuilder;
/// Builder function for the user avatar.
final UserAvatarBuilder userAvatarBuilder; final UserAvatarBuilder userAvatarBuilder;
/// Builder function for the group avatar.
final GroupAvatarBuilder groupAvatarBuilder; final GroupAvatarBuilder groupAvatarBuilder;
/// Builder function for the placeholder shown when no chats are available.
final NoChatsPlaceholderBuilder noChatsPlaceholderBuilder; final NoChatsPlaceholderBuilder noChatsPlaceholderBuilder;
} }

View file

@ -13,10 +13,19 @@ class ChatProfileScreen extends StatefulWidget {
super.key, super.key,
}); });
/// Translations for the chat.
final ChatTranslations translations; final ChatTranslations translations;
/// Chat service instance.
final ChatService chatService; final ChatService chatService;
/// ID of the chat.
final String chatId; final String chatId;
/// ID of the user (optional).
final String? userId; final String? userId;
/// Callback function for tapping on a user.
final Function(String userId) onTapUser; final Function(String userId) onTapUser;
@override @override

View file

@ -24,19 +24,33 @@ class ChatScreen extends StatefulWidget {
super.key, super.key,
}); });
/// Chat options.
final ChatOptions options; final ChatOptions options;
final ChatTranslations translations;
/// Chat service instance.
final ChatService service; final ChatService service;
/// Callback function for starting a chat.
final Function()? onPressStartChat; final Function()? onPressStartChat;
final Function()? onNoChats;
final void Function(ChatModel chat) onDeleteChat; /// Callback function for pressing on a chat.
final void Function(ChatModel chat) onPressChat; final void Function(ChatModel chat) onPressChat;
/// Disable the swipe to dismiss feature for chats that are not deletable /// Callback function for deleting a chat.
final void Function(ChatModel chat) onDeleteChat;
/// Callback function for handling when there are no chats.
final Function()? onNoChats;
/// Method to optionally change the bottom sheet dialog.
final Future<bool?> Function(BuildContext, ChatModel)? deleteChatDialog;
/// Translations for the chat.
final ChatTranslations translations;
/// Disables the swipe to dismiss feature for chats that are not deletable.
final bool disableDismissForPermanentChats; final bool disableDismissForPermanentChats;
/// Method to optionally change the bottomsheetdialog
final Future<bool?> Function(BuildContext, ChatModel)? deleteChatDialog;
@override @override
State<ChatScreen> createState() => _ChatScreenState(); State<ChatScreen> createState() => _ChatScreenState();
} }

View file

@ -14,11 +14,18 @@ class NewChatScreen extends StatefulWidget {
super.key, super.key,
}); });
/// Chat options.
final ChatOptions options; final ChatOptions options;
final ChatTranslations translations;
/// Chat service instance.
final ChatService service; final ChatService service;
/// Callback function for creating a new chat with a user.
final Function(ChatUserModel) onPressCreateChat; final Function(ChatUserModel) onPressCreateChat;
/// Translations for the chat.
final ChatTranslations translations;
@override @override
State<NewChatScreen> createState() => _NewChatScreenState(); State<NewChatScreen> createState() => _NewChatScreenState();
} }