Merge pull request #66 from Iconica-Development/bugfix/feedback

fix: apply feedback
This commit is contained in:
Gorter-dev 2024-04-23 10:06:52 +02:00 committed by GitHub
commit c370df0bdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 58 additions and 12 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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:

View file

@ -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:

View file

@ -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<List<ChatModel>> getChatsStream();
/// Retrieves a chat based on the user.
Future<ChatModel> getChatByUser(ChatUserModel user);
/// Retrieves a chat based on the ID.
Future<ChatModel> getChatById(String id);
/// Deletes the chat for this user and the other users in the chat.
Future<void> deleteChat(ChatModel chat);
/// When a chat is read, this method is called.
Future<void> readChat(ChatModel chat);
/// Creates the chat if it does not exist.
Future<ChatModel> storeChatIfNot(ChatModel chat);
/// Retrieves the number of unread chats.
Stream<int> getUnreadChatsCountStream();
}

View file

@ -1,7 +1,13 @@
import 'package:flutter_chat_interface/flutter_chat_interface.dart';
abstract class ChatUserService {
/// Retrieves a user based on the ID.
Future<ChatUserModel?> getUser(String id);
/// Retrieves the current user.
/// This is the user that is currently logged in.
Future<ChatUserModel?> getCurrentUser();
/// Retrieves all users. Used for chat creation.
Future<List<ChatUserModel>> getAllUsers();
}

View file

@ -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:

View file

@ -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();

View file

@ -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:

View file

@ -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: