mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
Merge 99c15dbd7f
into f7f15ef750
This commit is contained in:
commit
7cde32e2cf
8 changed files with 52 additions and 36 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
## 6.0.1
|
||||||
|
- Added proper implementation for getAllUsersForChat in Firebase repository
|
||||||
|
- Removed cast which throws an error in ChatProfileScreen
|
||||||
|
- Added BackButton to ChatOverviewScreen when onExit is not null
|
||||||
|
|
||||||
## 6.0.0
|
## 6.0.0
|
||||||
- Added pending message repository to temporarily store messages that are not yet received by the backend
|
- Added pending message repository to temporarily store messages that are not yet received by the backend
|
||||||
- Added pending message icons next to time on default messages
|
- Added pending message icons next to time on default messages
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: chat_repository_interface
|
name: chat_repository_interface
|
||||||
description: "The interface for a chat repository"
|
description: "The interface for a chat repository"
|
||||||
version: 6.0.0
|
version: 6.0.1
|
||||||
homepage: "https://github.com/Iconica-Development"
|
homepage: "https://github.com/Iconica-Development"
|
||||||
|
|
||||||
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/
|
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/
|
||||||
|
|
|
@ -7,10 +7,13 @@ class FirebaseUserRepository implements UserRepositoryInterface {
|
||||||
FirebaseUserRepository({
|
FirebaseUserRepository({
|
||||||
FirebaseFirestore? firestore,
|
FirebaseFirestore? firestore,
|
||||||
String userCollection = "users",
|
String userCollection = "users",
|
||||||
|
String chatCollection = "chats",
|
||||||
}) : _userCollection = userCollection,
|
}) : _userCollection = userCollection,
|
||||||
|
_chatCollection = chatCollection,
|
||||||
_firestore = firestore ?? FirebaseFirestore.instance;
|
_firestore = firestore ?? FirebaseFirestore.instance;
|
||||||
final FirebaseFirestore _firestore;
|
final FirebaseFirestore _firestore;
|
||||||
final String _userCollection;
|
final String _userCollection;
|
||||||
|
final String _chatCollection;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<List<UserModel>> getAllUsers() =>
|
Stream<List<UserModel>> getAllUsers() =>
|
||||||
|
@ -35,19 +38,20 @@ class FirebaseUserRepository implements UserRepositoryInterface {
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<List<UserModel>> getAllUsersForChat({required String chatId}) =>
|
Stream<List<UserModel>> getAllUsersForChat({required String chatId}) {
|
||||||
_firestore
|
var chatDocStream =
|
||||||
.collection(_userCollection)
|
_firestore.collection(_chatCollection).doc(chatId).snapshots();
|
||||||
.where("chats", arrayContains: chatId)
|
|
||||||
.snapshots()
|
return chatDocStream.asyncMap((snapshot) async {
|
||||||
.map(
|
if (!snapshot.exists) return [];
|
||||||
(querySnapshot) => querySnapshot.docs
|
|
||||||
.map(
|
var chatModel = ChatModel.fromMap(snapshot.id, snapshot.data()!);
|
||||||
(doc) => UserModel.fromMap(
|
var userIds = chatModel.users;
|
||||||
doc.id,
|
|
||||||
doc.data(),
|
var userStreams =
|
||||||
),
|
userIds.map((userId) => getUser(userId: userId)).toList();
|
||||||
)
|
|
||||||
.toList(),
|
return Future.wait(userStreams.map((s) => s.first));
|
||||||
);
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: firebase_chat_repository
|
name: firebase_chat_repository
|
||||||
description: "Firebase repository implementation for the chat domain repository interface"
|
description: "Firebase repository implementation for the chat domain repository interface"
|
||||||
version: 6.0.0
|
version: 6.0.1
|
||||||
homepage: "https://github.com/Iconica-Development"
|
homepage: "https://github.com/Iconica-Development"
|
||||||
|
|
||||||
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/
|
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/
|
||||||
|
@ -15,7 +15,7 @@ dependencies:
|
||||||
|
|
||||||
chat_repository_interface:
|
chat_repository_interface:
|
||||||
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
||||||
version: ^6.0.0
|
version: ^6.0.1
|
||||||
|
|
||||||
firebase_storage: any
|
firebase_storage: any
|
||||||
cloud_firestore: any
|
cloud_firestore: any
|
||||||
|
|
|
@ -78,6 +78,8 @@ abstract class _BaseChatNavigatorUserstory extends HookWidget {
|
||||||
final ChatOptions options;
|
final ChatOptions options;
|
||||||
|
|
||||||
/// Callback for when the user wants to navigate back.
|
/// Callback for when the user wants to navigate back.
|
||||||
|
///
|
||||||
|
/// This will also show the back button in the appbar when not null
|
||||||
final VoidCallback? onExit;
|
final VoidCallback? onExit;
|
||||||
|
|
||||||
/// Implemented by subclasses to provide the initial route of the userstory.
|
/// Implemented by subclasses to provide the initial route of the userstory.
|
||||||
|
@ -108,7 +110,7 @@ abstract class _BaseChatNavigatorUserstory extends HookWidget {
|
||||||
service: service,
|
service: service,
|
||||||
popHandler: popHandler,
|
popHandler: popHandler,
|
||||||
child: NavigatorPopHandler(
|
child: NavigatorPopHandler(
|
||||||
onPop: () => popHandler.handlePop(),
|
onPop: popHandler.handlePop,
|
||||||
child: Navigator(
|
child: Navigator(
|
||||||
key: nestedNavigatorKey,
|
key: nestedNavigatorKey,
|
||||||
onGenerateInitialRoutes: (_, __) => [
|
onGenerateInitialRoutes: (_, __) => [
|
||||||
|
|
|
@ -193,8 +193,7 @@ class _Body extends StatelessWidget {
|
||||||
);
|
);
|
||||||
|
|
||||||
var targetUser = user ??
|
var targetUser = user ??
|
||||||
(
|
(chat != null
|
||||||
chat != null
|
|
||||||
? UserModel(
|
? UserModel(
|
||||||
id: UniqueKey().toString(),
|
id: UniqueKey().toString(),
|
||||||
firstName: chat?.chatName,
|
firstName: chat?.chatName,
|
||||||
|
@ -203,8 +202,7 @@ class _Body extends StatelessWidget {
|
||||||
: UserModel(
|
: UserModel(
|
||||||
id: UniqueKey().toString(),
|
id: UniqueKey().toString(),
|
||||||
firstName: options.translations.groupNameEmpty,
|
firstName: options.translations.groupNameEmpty,
|
||||||
),
|
));
|
||||||
) as UserModel;
|
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ChatScreen extends HookWidget {
|
||||||
|
|
||||||
if (options.builders.baseScreenBuilder == null) {
|
if (options.builders.baseScreenBuilder == null) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const _AppBar(),
|
appBar: _AppBar(onExit),
|
||||||
body: _Body(
|
body: _Body(
|
||||||
onPressChat: onPressChat,
|
onPressChat: onPressChat,
|
||||||
onPressStartChat: onPressStartChat,
|
onPressStartChat: onPressStartChat,
|
||||||
|
@ -58,7 +58,7 @@ class ChatScreen extends HookWidget {
|
||||||
return options.builders.baseScreenBuilder!.call(
|
return options.builders.baseScreenBuilder!.call(
|
||||||
context,
|
context,
|
||||||
mapScreenType,
|
mapScreenType,
|
||||||
const _AppBar(),
|
_AppBar(onExit),
|
||||||
translations.chatsTitle,
|
translations.chatsTitle,
|
||||||
_Body(
|
_Body(
|
||||||
onPressChat: onPressChat,
|
onPressChat: onPressChat,
|
||||||
|
@ -70,7 +70,9 @@ class ChatScreen extends HookWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AppBar extends StatelessWidget implements PreferredSizeWidget {
|
class _AppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
const _AppBar();
|
const _AppBar(this.onExit);
|
||||||
|
|
||||||
|
final VoidCallback? onExit;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -81,6 +83,11 @@ class _AppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
var theme = Theme.of(context);
|
var theme = Theme.of(context);
|
||||||
|
|
||||||
return AppBar(
|
return AppBar(
|
||||||
|
leading: onExit != null
|
||||||
|
? BackButton(
|
||||||
|
onPressed: () => onExit?.call(),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
title: Text(
|
title: Text(
|
||||||
translations.chatsTitle,
|
translations.chatsTitle,
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_chat
|
name: flutter_chat
|
||||||
description: "User story of the chat domain for quick integration into flutter apps"
|
description: "User story of the chat domain for quick integration into flutter apps"
|
||||||
version: 6.0.0
|
version: 6.0.1
|
||||||
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/
|
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
@ -26,7 +26,7 @@ dependencies:
|
||||||
version: ^1.6.0
|
version: ^1.6.0
|
||||||
chat_repository_interface:
|
chat_repository_interface:
|
||||||
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
||||||
version: ^6.0.0
|
version: ^6.0.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in a new issue