Merge pull request #25 from Iconica-Development/0.4.1

fix: update GroupAvatarBuilder so the groupName is available
This commit is contained in:
Freek van de Ven 2023-11-23 09:50:07 +01:00 committed by Freek van de Ven
commit d870b8424b
11 changed files with 32 additions and 14 deletions

View file

@ -1,3 +1,7 @@
## 0.4.1 - November 22 2023
- Add groupName for groupchat avatarbuilder
## 0.4.0 - November 6 2023 ## 0.4.0 - November 6 2023
- Show amount of unread messages per chat - Show amount of unread messages per chat

View file

@ -4,7 +4,7 @@
name: flutter_community_chat name: flutter_community_chat
description: A new Flutter package project. description: A new Flutter package project.
version: 0.4.0 version: 0.4.1
publish_to: none publish_to: none
@ -19,12 +19,12 @@ dependencies:
git: git:
url: https://github.com/Iconica-Development/flutter_community_chat url: https://github.com/Iconica-Development/flutter_community_chat
path: packages/flutter_community_chat_view path: packages/flutter_community_chat_view
ref: 0.4.0 ref: 0.4.1
flutter_community_chat_interface: flutter_community_chat_interface:
git: git:
url: https://github.com/Iconica-Development/flutter_community_chat url: https://github.com/Iconica-Development/flutter_community_chat
path: packages/flutter_community_chat_interface path: packages/flutter_community_chat_interface
ref: 0.4.0 ref: 0.4.1
dev_dependencies: dev_dependencies:
flutter_lints: ^2.0.0 flutter_lints: ^2.0.0

View file

@ -493,6 +493,6 @@ class FirebaseChatService implements ChatService {
.doc(currentUser!.id!) .doc(currentUser!.id!)
.collection('chats') .collection('chats')
.doc(chat.id) .doc(chat.id)
.update({'amount_unread_messages': 0}); .set({'amount_unread_messages': 0}, SetOptions(merge: true));
} }
} }

View file

@ -84,10 +84,20 @@ class FirebaseMessageService implements MessageService {
.doc(userId) .doc(userId)
.collection('chats') .collection('chats')
.doc(chat.id); .doc(chat.id);
// what if the amount_unread_messages field does not exist?
await userReference.update({ // it should be created when the chat is create
'amount_unread_messages': FieldValue.increment(1), if ((await userReference.get())
}); .data()
?.containsKey('amount_unread_messages') ??
false) {
await userReference.update({
'amount_unread_messages': FieldValue.increment(1),
});
} else {
await userReference.set({
'amount_unread_messages': 1,
});
}
} }
} }
} }

View file

@ -4,7 +4,7 @@
name: flutter_community_chat_firebase name: flutter_community_chat_firebase
description: A new Flutter package project. description: A new Flutter package project.
version: 0.4.0 version: 0.4.1
publish_to: none publish_to: none
environment: environment:
@ -23,7 +23,7 @@ dependencies:
git: git:
url: https://github.com/Iconica-Development/flutter_community_chat url: https://github.com/Iconica-Development/flutter_community_chat
path: packages/flutter_community_chat_interface path: packages/flutter_community_chat_interface
ref: 0.4.0 ref: 0.4.1
dev_dependencies: dev_dependencies:
flutter_lints: ^2.0.0 flutter_lints: ^2.0.0

View file

@ -4,7 +4,7 @@
name: flutter_community_chat_interface name: flutter_community_chat_interface
description: A new Flutter package project. description: A new Flutter package project.
version: 0.4.0 version: 0.4.1
publish_to: none publish_to: none
environment: environment:

View file

@ -18,7 +18,7 @@ dependencies:
git: git:
url: https://github.com/Iconica-Development/flutter_community_chat url: https://github.com/Iconica-Development/flutter_community_chat
path: packages/flutter_community_chat_view path: packages/flutter_community_chat_view
ref: 0.4.0 ref: 0.4.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

View file

@ -104,6 +104,7 @@ Widget _createUserAvatar(
size: size, size: size,
); );
Widget _createGroupAvatar( Widget _createGroupAvatar(
String groupName,
String imageUrl, String imageUrl,
double size, double size,
) => ) =>
@ -158,6 +159,7 @@ typedef UserAvatarBuilder = Widget Function(
); );
typedef GroupAvatarBuilder = Widget Function( typedef GroupAvatarBuilder = Widget Function(
String groupName,
String imageUrl, String imageUrl,
double size, double size,
); );

View file

@ -116,6 +116,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
: [ : [
if (widget.chat is GroupChatModel) ...[ if (widget.chat is GroupChatModel) ...[
widget.options.groupAvatarBuilder( widget.options.groupAvatarBuilder(
(widget.chat! as GroupChatModel).title,
(widget.chat! as GroupChatModel).imageUrl, (widget.chat! as GroupChatModel).imageUrl,
36.0, 36.0,
), ),

View file

@ -161,6 +161,7 @@ class _ChatScreenState extends State<ChatScreen> {
: '', : '',
avatar: avatar:
widget.options.groupAvatarBuilder( widget.options.groupAvatarBuilder(
chat.title,
chat.imageUrl, chat.imageUrl,
40.0, 40.0,
), ),

View file

@ -4,7 +4,7 @@
name: flutter_community_chat_view name: flutter_community_chat_view
description: A standard flutter package. description: A standard flutter package.
version: 0.4.0 version: 0.4.1
publish_to: none publish_to: none
@ -20,7 +20,7 @@ dependencies:
git: git:
url: https://github.com/Iconica-Development/flutter_community_chat url: https://github.com/Iconica-Development/flutter_community_chat
path: packages/flutter_community_chat_interface path: packages/flutter_community_chat_interface
ref: 0.4.0 ref: 0.4.1
cached_network_image: ^3.2.2 cached_network_image: ^3.2.2
flutter_image_picker: flutter_image_picker:
git: git: