mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
feat: make all transltions required for ChatTranslations and provide an .empty() alternative
This commit is contained in:
parent
b5656d5f3a
commit
146ec3a1a9
7 changed files with 105 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
||||||
- Add a translationsBuilder to the userstory configuration
|
- Add a translationsBuilder to the userstory configuration
|
||||||
- Change onPressUserProfile callback to use a ChatUserModel instead of a String
|
- Change onPressUserProfile callback to use a ChatUserModel instead of a String
|
||||||
- Add a enableGroupChatCreation boolean to the userstory configuration to enable or disable group chat creation
|
- Add a enableGroupChatCreation boolean to the userstory configuration to enable or disable group chat creation
|
||||||
|
- Change the ChatTranslations constructor to require all translations or use the ChatTranslations.empty constructor if you don't want to specify all translations
|
||||||
|
|
||||||
## 1.4.3
|
## 1.4.3
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,44 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
/// Class that holds all the translations for the chat component view and
|
||||||
|
/// the corresponding userstory
|
||||||
class ChatTranslations {
|
class ChatTranslations {
|
||||||
|
/// ChatTranslations constructor where everything is required use this
|
||||||
|
/// if you want to be sure to have all translations specified
|
||||||
|
/// If you just want the default values use the empty constructor
|
||||||
|
/// and optionally override the values with the copyWith method
|
||||||
const ChatTranslations({
|
const ChatTranslations({
|
||||||
|
required this.chatsTitle,
|
||||||
|
required this.chatsUnread,
|
||||||
|
required this.newChatButton,
|
||||||
|
required this.newGroupChatButton,
|
||||||
|
required this.newChatTitle,
|
||||||
|
required this.deleteChatButton,
|
||||||
|
required this.image,
|
||||||
|
required this.searchPlaceholder,
|
||||||
|
required this.startTyping,
|
||||||
|
required this.cancelImagePickerBtn,
|
||||||
|
required this.messagePlaceholder,
|
||||||
|
required this.writeMessageToStartChat,
|
||||||
|
required this.writeFirstMessageInGroupChat,
|
||||||
|
required this.imageUploading,
|
||||||
|
required this.deleteChatModalTitle,
|
||||||
|
required this.deleteChatModalDescription,
|
||||||
|
required this.deleteChatModalCancel,
|
||||||
|
required this.deleteChatModalConfirm,
|
||||||
|
required this.noUsersFound,
|
||||||
|
required this.noChatsFound,
|
||||||
|
required this.chatCantBeDeleted,
|
||||||
|
required this.chatProfileUsers,
|
||||||
|
required this.imagePickerTitle,
|
||||||
|
required this.uploadFile,
|
||||||
|
required this.takePicture,
|
||||||
|
required this.anonymousUser,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Default translations for the chat component view
|
||||||
|
const ChatTranslations.empty({
|
||||||
this.chatsTitle = 'Chats',
|
this.chatsTitle = 'Chats',
|
||||||
this.chatsUnread = 'unread',
|
this.chatsUnread = 'unread',
|
||||||
this.newChatButton = 'Start a chat',
|
this.newChatButton = 'Start a chat',
|
||||||
|
@ -62,4 +98,67 @@ class ChatTranslations {
|
||||||
|
|
||||||
/// Shown when the user has no name
|
/// Shown when the user has no name
|
||||||
final String anonymousUser;
|
final String anonymousUser;
|
||||||
|
|
||||||
|
// copyWith method to override the default values
|
||||||
|
ChatTranslations copyWith({
|
||||||
|
String? chatsTitle,
|
||||||
|
String? chatsUnread,
|
||||||
|
String? newChatButton,
|
||||||
|
String? newGroupChatButton,
|
||||||
|
String? newChatTitle,
|
||||||
|
String? deleteChatButton,
|
||||||
|
String? image,
|
||||||
|
String? searchPlaceholder,
|
||||||
|
String? startTyping,
|
||||||
|
String? cancelImagePickerBtn,
|
||||||
|
String? messagePlaceholder,
|
||||||
|
String? writeMessageToStartChat,
|
||||||
|
String? writeFirstMessageInGroupChat,
|
||||||
|
String? imageUploading,
|
||||||
|
String? deleteChatModalTitle,
|
||||||
|
String? deleteChatModalDescription,
|
||||||
|
String? deleteChatModalCancel,
|
||||||
|
String? deleteChatModalConfirm,
|
||||||
|
String? noUsersFound,
|
||||||
|
String? noChatsFound,
|
||||||
|
String? chatCantBeDeleted,
|
||||||
|
String? chatProfileUsers,
|
||||||
|
String? imagePickerTitle,
|
||||||
|
String? uploadFile,
|
||||||
|
String? takePicture,
|
||||||
|
String? anonymousUser,
|
||||||
|
}) =>
|
||||||
|
ChatTranslations(
|
||||||
|
chatsTitle: chatsTitle ?? this.chatsTitle,
|
||||||
|
chatsUnread: chatsUnread ?? this.chatsUnread,
|
||||||
|
newChatButton: newChatButton ?? this.newChatButton,
|
||||||
|
newGroupChatButton: newGroupChatButton ?? this.newGroupChatButton,
|
||||||
|
newChatTitle: newChatTitle ?? this.newChatTitle,
|
||||||
|
deleteChatButton: deleteChatButton ?? this.deleteChatButton,
|
||||||
|
image: image ?? this.image,
|
||||||
|
searchPlaceholder: searchPlaceholder ?? this.searchPlaceholder,
|
||||||
|
startTyping: startTyping ?? this.startTyping,
|
||||||
|
cancelImagePickerBtn: cancelImagePickerBtn ?? this.cancelImagePickerBtn,
|
||||||
|
messagePlaceholder: messagePlaceholder ?? this.messagePlaceholder,
|
||||||
|
writeMessageToStartChat:
|
||||||
|
writeMessageToStartChat ?? this.writeMessageToStartChat,
|
||||||
|
writeFirstMessageInGroupChat:
|
||||||
|
writeFirstMessageInGroupChat ?? this.writeFirstMessageInGroupChat,
|
||||||
|
imageUploading: imageUploading ?? this.imageUploading,
|
||||||
|
deleteChatModalTitle: deleteChatModalTitle ?? this.deleteChatModalTitle,
|
||||||
|
deleteChatModalDescription:
|
||||||
|
deleteChatModalDescription ?? this.deleteChatModalDescription,
|
||||||
|
deleteChatModalCancel:
|
||||||
|
deleteChatModalCancel ?? this.deleteChatModalCancel,
|
||||||
|
deleteChatModalConfirm:
|
||||||
|
deleteChatModalConfirm ?? this.deleteChatModalConfirm,
|
||||||
|
noUsersFound: noUsersFound ?? this.noUsersFound,
|
||||||
|
noChatsFound: noChatsFound ?? this.noChatsFound,
|
||||||
|
chatCantBeDeleted: chatCantBeDeleted ?? this.chatCantBeDeleted,
|
||||||
|
chatProfileUsers: chatProfileUsers ?? this.chatProfileUsers,
|
||||||
|
imagePickerTitle: imagePickerTitle ?? this.imagePickerTitle,
|
||||||
|
uploadFile: uploadFile ?? this.uploadFile,
|
||||||
|
takePicture: takePicture ?? this.takePicture,
|
||||||
|
anonymousUser: anonymousUser ?? this.anonymousUser,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ChatDetailScreen extends StatefulWidget {
|
||||||
this.chatTitleBuilder,
|
this.chatTitleBuilder,
|
||||||
this.usernameBuilder,
|
this.usernameBuilder,
|
||||||
this.loadingWidgetBuilder,
|
this.loadingWidgetBuilder,
|
||||||
this.translations = const ChatTranslations(),
|
this.translations = const ChatTranslations.empty(),
|
||||||
this.iconColor,
|
this.iconColor,
|
||||||
this.iconDisabledColor,
|
this.iconDisabledColor,
|
||||||
this.showTime = false,
|
this.showTime = false,
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ChatScreen extends StatefulWidget {
|
||||||
this.unreadMessageTextStyle,
|
this.unreadMessageTextStyle,
|
||||||
this.onNoChats,
|
this.onNoChats,
|
||||||
this.deleteChatDialog,
|
this.deleteChatDialog,
|
||||||
this.translations = const ChatTranslations(),
|
this.translations = const ChatTranslations.empty(),
|
||||||
this.disableDismissForPermanentChats = false,
|
this.disableDismissForPermanentChats = false,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@ class NewChatScreen extends StatefulWidget {
|
||||||
required this.service,
|
required this.service,
|
||||||
required this.onPressCreateGroupChat,
|
required this.onPressCreateGroupChat,
|
||||||
this.showGroupChatButton = true,
|
this.showGroupChatButton = true,
|
||||||
this.translations = const ChatTranslations(),
|
this.translations = const ChatTranslations.empty(),
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class NewGroupChatOverviewScreen extends StatefulWidget {
|
||||||
required this.onPressCompleteGroupChatCreation,
|
required this.onPressCompleteGroupChatCreation,
|
||||||
required this.service,
|
required this.service,
|
||||||
required this.users,
|
required this.users,
|
||||||
this.translations = const ChatTranslations(),
|
this.translations = const ChatTranslations.empty(),
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ class NewGroupChatScreen extends StatefulWidget {
|
||||||
required this.options,
|
required this.options,
|
||||||
required this.onPressGroupChatOverview,
|
required this.onPressGroupChatOverview,
|
||||||
required this.service,
|
required this.service,
|
||||||
this.translations = const ChatTranslations(),
|
this.translations = const ChatTranslations.empty(),
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue