diff --git a/CHANGELOG.md b/CHANGELOG.md index aaefea8..570b51e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.4.2 + +- Added doc comments +- Fixed bug when creating a group chat with the `LocalChatService` +- Updated readme + ## 1.4.1 - Made UI changes to match the Figma design diff --git a/README.md b/README.md index 8e884ee..4a8c7ef 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,14 @@ To use this package, add flutter_chat as a dependency in your pubspec.yaml file: path: packages/flutter_chat ``` +You can use the `LocalChatService` to test the package in your project: + +``` +ChatUserStoryConfiguration( + chatService: LocalChatService(), +), +``` + If you are going to use Firebase as the back-end of the Chat, you should also add the following package as a dependency to your pubspec.yaml file: ``` @@ -32,7 +40,18 @@ Create a Firebase project for your application and add firebase firestore and st make sure you are authenticated using the `Firebase_auth` package or adjust your firebase rules, otherwise you won't be able to retreive data. Also make sure you have the corresponding collections in your firebase project as defined in `FirebaseChatOptions`, you can override the -default paths as you wish, also the structure of your data should be equal to our predefined models, you can implement any model by making your own model and implementing one of the predefined interfaces like so: +default paths as you wish: +``` + const FirebaseChatOptions({ + this.groupChatsCollectionName = 'group_chats', + this.chatsCollectionName = 'chats', + this.messagesCollectionName = 'messages', + this.usersCollectionName = 'users', + this.chatsMetaDataCollectionName = 'chat_metadata', + this.userChatsCollectionName = 'chats', + }); + ``` + Also the structure of your data should be equal to our predefined models, you can implement any model by making your own model and implementing one of the predefined interfaces like so: ``` class ChatMessageModel implements ChatMessageModelInterface { diff --git a/packages/flutter_chat/pubspec.yaml b/packages/flutter_chat/pubspec.yaml index a32f89d..c532246 100644 --- a/packages/flutter_chat/pubspec.yaml +++ b/packages/flutter_chat/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_chat description: A new Flutter package project. -version: 1.4.1 +version: 1.4.2 publish_to: none @@ -20,17 +20,17 @@ dependencies: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_view - ref: 1.4.1 + ref: 1.4.2 flutter_chat_interface: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_interface - ref: 1.4.1 + ref: 1.4.2 flutter_chat_local: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_local - ref: 1.4.1 + ref: 1.4.2 uuid: ^4.3.3 dev_dependencies: diff --git a/packages/flutter_chat_firebase/pubspec.yaml b/packages/flutter_chat_firebase/pubspec.yaml index cc657f5..f2bda6c 100644 --- a/packages/flutter_chat_firebase/pubspec.yaml +++ b/packages/flutter_chat_firebase/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_chat_firebase description: A new Flutter package project. -version: 1.4.1 +version: 1.4.2 publish_to: none environment: @@ -23,7 +23,7 @@ dependencies: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_interface - ref: 1.4.1 + ref: 1.4.2 dev_dependencies: flutter_iconica_analysis: diff --git a/packages/flutter_chat_interface/lib/src/service/chat_overview_service.dart b/packages/flutter_chat_interface/lib/src/service/chat_overview_service.dart index 2f7d2e9..d0c806f 100644 --- a/packages/flutter_chat_interface/lib/src/service/chat_overview_service.dart +++ b/packages/flutter_chat_interface/lib/src/service/chat_overview_service.dart @@ -1,11 +1,25 @@ import 'package:flutter_chat_interface/flutter_chat_interface.dart'; abstract class ChatOverviewService { + /// Retrieves a stream of chats. + /// This stream is updated whenever a new chat is created. Stream> getChatsStream(); + + /// Retrieves a chat based on the user. Future getChatByUser(ChatUserModel user); + + /// Retrieves a chat based on the ID. Future getChatById(String id); + + /// Deletes the chat for this user and the other users in the chat. Future deleteChat(ChatModel chat); + + /// When a chat is read, this method is called. Future readChat(ChatModel chat); + + /// Creates the chat if it does not exist. Future storeChatIfNot(ChatModel chat); + + /// Retrieves the number of unread chats. Stream getUnreadChatsCountStream(); } diff --git a/packages/flutter_chat_interface/lib/src/service/user_service.dart b/packages/flutter_chat_interface/lib/src/service/user_service.dart index ba65fd6..17307d9 100644 --- a/packages/flutter_chat_interface/lib/src/service/user_service.dart +++ b/packages/flutter_chat_interface/lib/src/service/user_service.dart @@ -1,7 +1,13 @@ import 'package:flutter_chat_interface/flutter_chat_interface.dart'; abstract class ChatUserService { + /// Retrieves a user based on the ID. Future getUser(String id); + + /// Retrieves the current user. + /// This is the user that is currently logged in. Future getCurrentUser(); + + /// Retrieves all users. Used for chat creation. Future> getAllUsers(); } diff --git a/packages/flutter_chat_interface/pubspec.yaml b/packages/flutter_chat_interface/pubspec.yaml index 21cbc0c..3fb2061 100644 --- a/packages/flutter_chat_interface/pubspec.yaml +++ b/packages/flutter_chat_interface/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_chat_interface description: A new Flutter package project. -version: 1.4.1 +version: 1.4.2 publish_to: none environment: diff --git a/packages/flutter_chat_local/lib/service/local_chat_overview_service.dart b/packages/flutter_chat_local/lib/service/local_chat_overview_service.dart index d8aa2f2..759eb06 100644 --- a/packages/flutter_chat_local/lib/service/local_chat_overview_service.dart +++ b/packages/flutter_chat_local/lib/service/local_chat_overview_service.dart @@ -81,6 +81,7 @@ class LocalChatOverviewService var chatExists = _chats.any((element) => element.id == chat.id); if (!chatExists) { + chat.id = chat.hashCode.toString(); _chats.add(chat); _chatsController.add([..._chats]); notifyListeners(); diff --git a/packages/flutter_chat_local/pubspec.yaml b/packages/flutter_chat_local/pubspec.yaml index 93fcfdf..30233a4 100644 --- a/packages/flutter_chat_local/pubspec.yaml +++ b/packages/flutter_chat_local/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_chat_local description: "A new Flutter package project." -version: 1.4.1 +version: 1.4.2 publish_to: none homepage: @@ -15,7 +15,7 @@ dependencies: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_interface - ref: 1.4.1 + ref: 1.4.2 dev_dependencies: flutter_test: diff --git a/packages/flutter_chat_view/pubspec.yaml b/packages/flutter_chat_view/pubspec.yaml index 30dbc78..8982d65 100644 --- a/packages/flutter_chat_view/pubspec.yaml +++ b/packages/flutter_chat_view/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_chat_view description: A standard flutter package. -version: 1.4.1 +version: 1.4.2 publish_to: none @@ -20,7 +20,7 @@ dependencies: git: url: https://github.com/Iconica-Development/flutter_chat path: packages/flutter_chat_interface - ref: 1.4.1 + ref: 1.4.2 cached_network_image: ^3.2.2 flutter_image_picker: git: