mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
feat: add service and translationbuilder for userstory configuration to fetch both when needed
This commit is contained in:
parent
37e975ceec
commit
06167d202e
9 changed files with 54 additions and 25 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
## 2.0.0
|
||||||
|
|
||||||
|
- Add a serviceBuilder to the userstory configuration
|
||||||
|
- Add a translationsBuilder to the userstory configuration
|
||||||
|
|
||||||
## 1.4.3
|
## 1.4.3
|
||||||
|
|
||||||
- Added default styling.
|
- Added default styling.
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_chat/flutter_chat.dart';
|
import 'package:flutter_chat/flutter_chat.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
|
||||||
|
|
||||||
/// Navigates to the chat user story screen.
|
/// Navigates to the chat user story screen.
|
||||||
///
|
///
|
||||||
|
|
|
@ -14,9 +14,11 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: ChatUserStoryRoutes.chatScreen,
|
path: ChatUserStoryRoutes.chatScreen,
|
||||||
pageBuilder: (context, state) {
|
pageBuilder: (context, state) {
|
||||||
|
var service = configuration.chatServiceBuilder?.call(context) ??
|
||||||
|
configuration.chatService;
|
||||||
var chatScreen = ChatScreen(
|
var chatScreen = ChatScreen(
|
||||||
unreadMessageTextStyle: configuration.unreadMessageTextStyle,
|
unreadMessageTextStyle: configuration.unreadMessageTextStyle,
|
||||||
service: configuration.chatService,
|
service: service,
|
||||||
options: configuration.chatOptionsBuilder(context),
|
options: configuration.chatOptionsBuilder(context),
|
||||||
onNoChats: () async =>
|
onNoChats: () async =>
|
||||||
context.push(ChatUserStoryRoutes.newChatScreen),
|
context.push(ChatUserStoryRoutes.newChatScreen),
|
||||||
|
@ -34,7 +36,8 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
configuration.onDeleteChat?.call(context, chat) ??
|
configuration.onDeleteChat?.call(context, chat) ??
|
||||||
configuration.chatService.chatOverviewService.deleteChat(chat),
|
configuration.chatService.chatOverviewService.deleteChat(chat),
|
||||||
deleteChatDialog: configuration.deleteChatDialog,
|
deleteChatDialog: configuration.deleteChatDialog,
|
||||||
translations: configuration.translations,
|
translations: configuration.translationsBuilder?.call(context) ??
|
||||||
|
configuration.translations,
|
||||||
);
|
);
|
||||||
return buildScreenWithoutTransition(
|
return buildScreenWithoutTransition(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -53,6 +56,8 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
path: ChatUserStoryRoutes.chatDetailScreen,
|
path: ChatUserStoryRoutes.chatDetailScreen,
|
||||||
pageBuilder: (context, state) {
|
pageBuilder: (context, state) {
|
||||||
var chatId = state.pathParameters['id'];
|
var chatId = state.pathParameters['id'];
|
||||||
|
var service = configuration.chatServiceBuilder?.call(context) ??
|
||||||
|
configuration.chatService;
|
||||||
var chatDetailScreen = ChatDetailScreen(
|
var chatDetailScreen = ChatDetailScreen(
|
||||||
chatTitleBuilder: configuration.chatTitleBuilder,
|
chatTitleBuilder: configuration.chatTitleBuilder,
|
||||||
usernameBuilder: configuration.usernameBuilder,
|
usernameBuilder: configuration.usernameBuilder,
|
||||||
|
@ -60,8 +65,9 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
iconDisabledColor: configuration.iconDisabledColor,
|
iconDisabledColor: configuration.iconDisabledColor,
|
||||||
pageSize: configuration.messagePageSize,
|
pageSize: configuration.messagePageSize,
|
||||||
options: configuration.chatOptionsBuilder(context),
|
options: configuration.chatOptionsBuilder(context),
|
||||||
translations: configuration.translations,
|
translations: configuration.translationsBuilder?.call(context) ??
|
||||||
service: configuration.chatService,
|
configuration.translations,
|
||||||
|
service: service,
|
||||||
chatId: chatId!,
|
chatId: chatId!,
|
||||||
textfieldBottomPadding: configuration.textfieldBottomPadding ?? 0,
|
textfieldBottomPadding: configuration.textfieldBottomPadding ?? 0,
|
||||||
onPressUserProfile: (userId) async {
|
onPressUserProfile: (userId) async {
|
||||||
|
@ -120,10 +126,13 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: ChatUserStoryRoutes.newChatScreen,
|
path: ChatUserStoryRoutes.newChatScreen,
|
||||||
pageBuilder: (context, state) {
|
pageBuilder: (context, state) {
|
||||||
|
var service = configuration.chatServiceBuilder?.call(context) ??
|
||||||
|
configuration.chatService;
|
||||||
var newChatScreen = NewChatScreen(
|
var newChatScreen = NewChatScreen(
|
||||||
options: configuration.chatOptionsBuilder(context),
|
options: configuration.chatOptionsBuilder(context),
|
||||||
translations: configuration.translations,
|
translations: configuration.translationsBuilder?.call(context) ??
|
||||||
service: configuration.chatService,
|
configuration.translations,
|
||||||
|
service: service,
|
||||||
onPressCreateChat: (user) async {
|
onPressCreateChat: (user) async {
|
||||||
configuration.onPressCreateChat?.call(user);
|
configuration.onPressCreateChat?.call(user);
|
||||||
if (configuration.onPressCreateChat != null) return;
|
if (configuration.onPressCreateChat != null) return;
|
||||||
|
@ -163,10 +172,13 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: ChatUserStoryRoutes.newGroupChatScreen,
|
path: ChatUserStoryRoutes.newGroupChatScreen,
|
||||||
pageBuilder: (context, state) {
|
pageBuilder: (context, state) {
|
||||||
|
var service = configuration.chatServiceBuilder?.call(context) ??
|
||||||
|
configuration.chatService;
|
||||||
var newGroupChatScreen = NewGroupChatScreen(
|
var newGroupChatScreen = NewGroupChatScreen(
|
||||||
options: configuration.chatOptionsBuilder(context),
|
options: configuration.chatOptionsBuilder(context),
|
||||||
translations: configuration.translations,
|
translations: configuration.translationsBuilder?.call(context) ??
|
||||||
service: configuration.chatService,
|
configuration.translations,
|
||||||
|
service: service,
|
||||||
onPressGroupChatOverview: (users) async => context.push(
|
onPressGroupChatOverview: (users) async => context.push(
|
||||||
ChatUserStoryRoutes.newGroupChatOverviewScreen,
|
ChatUserStoryRoutes.newGroupChatOverviewScreen,
|
||||||
extra: users,
|
extra: users,
|
||||||
|
@ -188,11 +200,14 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: ChatUserStoryRoutes.newGroupChatOverviewScreen,
|
path: ChatUserStoryRoutes.newGroupChatOverviewScreen,
|
||||||
pageBuilder: (context, state) {
|
pageBuilder: (context, state) {
|
||||||
|
var service = configuration.chatServiceBuilder?.call(context) ??
|
||||||
|
configuration.chatService;
|
||||||
var users = state.extra! as List<ChatUserModel>;
|
var users = state.extra! as List<ChatUserModel>;
|
||||||
var newGroupChatOverviewScreen = NewGroupChatOverviewScreen(
|
var newGroupChatOverviewScreen = NewGroupChatOverviewScreen(
|
||||||
options: configuration.chatOptionsBuilder(context),
|
options: configuration.chatOptionsBuilder(context),
|
||||||
translations: configuration.translations,
|
translations: configuration.translationsBuilder?.call(context) ??
|
||||||
service: configuration.chatService,
|
configuration.translations,
|
||||||
|
service: service,
|
||||||
users: users,
|
users: users,
|
||||||
onPressCompleteGroupChatCreation: (users, groupChatName) async {
|
onPressCompleteGroupChatCreation: (users, groupChatName) async {
|
||||||
configuration.onPressCompleteGroupChatCreation
|
configuration.onPressCompleteGroupChatCreation
|
||||||
|
@ -232,9 +247,12 @@ List<GoRoute> getChatStoryRoutes(
|
||||||
var chatId = state.pathParameters['id'];
|
var chatId = state.pathParameters['id'];
|
||||||
var userId = state.pathParameters['userId'];
|
var userId = state.pathParameters['userId'];
|
||||||
var id = userId == 'null' ? null : userId;
|
var id = userId == 'null' ? null : userId;
|
||||||
|
var service = configuration.chatServiceBuilder?.call(context) ??
|
||||||
|
configuration.chatService;
|
||||||
var profileScreen = ChatProfileScreen(
|
var profileScreen = ChatProfileScreen(
|
||||||
translations: configuration.translations,
|
translations: configuration.translationsBuilder?.call(context) ??
|
||||||
chatService: configuration.chatService,
|
configuration.translations,
|
||||||
|
chatService: service,
|
||||||
chatId: chatId!,
|
chatId: chatId!,
|
||||||
userId: id,
|
userId: id,
|
||||||
onTapUser: (user) async {
|
onTapUser: (user) async {
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ChatUserStoryConfiguration {
|
||||||
const ChatUserStoryConfiguration({
|
const ChatUserStoryConfiguration({
|
||||||
required this.chatService,
|
required this.chatService,
|
||||||
required this.chatOptionsBuilder,
|
required this.chatOptionsBuilder,
|
||||||
|
this.chatServiceBuilder,
|
||||||
this.onPressStartChat,
|
this.onPressStartChat,
|
||||||
this.onPressChat,
|
this.onPressChat,
|
||||||
this.onDeleteChat,
|
this.onDeleteChat,
|
||||||
|
@ -28,6 +29,7 @@ class ChatUserStoryConfiguration {
|
||||||
this.disableDismissForPermanentChats = false,
|
this.disableDismissForPermanentChats = false,
|
||||||
this.routeToNewChatIfEmpty = true,
|
this.routeToNewChatIfEmpty = true,
|
||||||
this.translations = const ChatTranslations(),
|
this.translations = const ChatTranslations(),
|
||||||
|
this.translationsBuilder,
|
||||||
this.chatPageBuilder,
|
this.chatPageBuilder,
|
||||||
this.onPressChatTitle,
|
this.onPressChatTitle,
|
||||||
this.afterMessageSent,
|
this.afterMessageSent,
|
||||||
|
@ -44,6 +46,9 @@ class ChatUserStoryConfiguration {
|
||||||
/// The service responsible for handling chat-related functionalities.
|
/// The service responsible for handling chat-related functionalities.
|
||||||
final ChatService chatService;
|
final ChatService chatService;
|
||||||
|
|
||||||
|
/// A method to get the chat service only when needed and with a context.
|
||||||
|
final ChatService Function(BuildContext context)? chatServiceBuilder;
|
||||||
|
|
||||||
/// Callback function triggered when a chat is pressed.
|
/// Callback function triggered when a chat is pressed.
|
||||||
final Function(BuildContext, ChatModel)? onPressChat;
|
final Function(BuildContext, ChatModel)? onPressChat;
|
||||||
|
|
||||||
|
@ -53,6 +58,9 @@ class ChatUserStoryConfiguration {
|
||||||
/// Translations for internationalization/localization support.
|
/// Translations for internationalization/localization support.
|
||||||
final ChatTranslations translations;
|
final ChatTranslations translations;
|
||||||
|
|
||||||
|
/// Translations builder because context might be needed for translations.
|
||||||
|
final ChatTranslations Function(BuildContext context)? translationsBuilder;
|
||||||
|
|
||||||
/// Determines whether dismissing is disabled for permanent chats.
|
/// Determines whether dismissing is disabled for permanent chats.
|
||||||
final bool disableDismissForPermanentChats;
|
final bool disableDismissForPermanentChats;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
name: flutter_chat
|
name: flutter_chat
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 1.4.3
|
version: 2.0.0
|
||||||
|
|
||||||
publish_to: none
|
publish_to: none
|
||||||
|
|
||||||
|
@ -20,17 +20,17 @@ dependencies:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_chat
|
url: https://github.com/Iconica-Development/flutter_chat
|
||||||
path: packages/flutter_chat_view
|
path: packages/flutter_chat_view
|
||||||
ref: 1.4.3
|
ref: 2.0.0
|
||||||
flutter_chat_interface:
|
flutter_chat_interface:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_chat
|
url: https://github.com/Iconica-Development/flutter_chat
|
||||||
path: packages/flutter_chat_interface
|
path: packages/flutter_chat_interface
|
||||||
ref: 1.4.3
|
ref: 2.0.0
|
||||||
flutter_chat_local:
|
flutter_chat_local:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_chat
|
url: https://github.com/Iconica-Development/flutter_chat
|
||||||
path: packages/flutter_chat_local
|
path: packages/flutter_chat_local
|
||||||
ref: 1.4.3
|
ref: 2.0.0
|
||||||
uuid: ^4.3.3
|
uuid: ^4.3.3
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
name: flutter_chat_firebase
|
name: flutter_chat_firebase
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 1.4.3
|
version: 2.0.0
|
||||||
publish_to: none
|
publish_to: none
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
@ -23,7 +23,7 @@ dependencies:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_chat
|
url: https://github.com/Iconica-Development/flutter_chat
|
||||||
path: packages/flutter_chat_interface
|
path: packages/flutter_chat_interface
|
||||||
ref: 1.4.3
|
ref: 2.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_iconica_analysis:
|
flutter_iconica_analysis:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
name: flutter_chat_interface
|
name: flutter_chat_interface
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 1.4.3
|
version: 2.0.0
|
||||||
publish_to: none
|
publish_to: none
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
name: flutter_chat_local
|
name: flutter_chat_local
|
||||||
description: "A new Flutter package project."
|
description: "A new Flutter package project."
|
||||||
version: 1.4.3
|
version: 2.0.0
|
||||||
publish_to: none
|
publish_to: none
|
||||||
homepage:
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.2.5 <4.0.0"
|
sdk: ">=3.2.5 <4.0.0"
|
||||||
|
@ -15,7 +14,7 @@ dependencies:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_chat
|
url: https://github.com/Iconica-Development/flutter_chat
|
||||||
path: packages/flutter_chat_interface
|
path: packages/flutter_chat_interface
|
||||||
ref: 1.4.3
|
ref: 2.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
name: flutter_chat_view
|
name: flutter_chat_view
|
||||||
description: A standard flutter package.
|
description: A standard flutter package.
|
||||||
version: 1.4.3
|
version: 2.0.0
|
||||||
|
|
||||||
publish_to: none
|
publish_to: none
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ dependencies:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_chat
|
url: https://github.com/Iconica-Development/flutter_chat
|
||||||
path: packages/flutter_chat_interface
|
path: packages/flutter_chat_interface
|
||||||
ref: 1.4.3
|
ref: 2.0.0
|
||||||
cached_network_image: ^3.2.2
|
cached_network_image: ^3.2.2
|
||||||
flutter_image_picker:
|
flutter_image_picker:
|
||||||
git:
|
git:
|
||||||
|
|
Loading…
Reference in a new issue