feat: add translations for anonymous user

This commit is contained in:
Freek van de Ven 2023-11-06 11:55:12 +01:00
parent 08e695517b
commit 29d993682a
6 changed files with 14 additions and 5 deletions

View file

@ -1,4 +1,4 @@
## 0.4.0 - October 27 2023 ## 0.4.0 - November 6 2023
- Show amount of unread messages per chat - Show amount of unread messages per chat
- More intuitive chat UI - More intuitive chat UI

View file

@ -10,12 +10,14 @@ import 'package:flutter_community_chat_view/src/services/date_formatter.dart';
class ChatDetailRow extends StatefulWidget { class ChatDetailRow extends StatefulWidget {
const ChatDetailRow({ const ChatDetailRow({
required this.translations,
required this.isFirstMessage, required this.isFirstMessage,
required this.message, required this.message,
required this.userAvatarBuilder, required this.userAvatarBuilder,
super.key, super.key,
}); });
final ChatTranslations translations;
final bool isFirstMessage; final bool isFirstMessage;
final ChatMessageModel message; final ChatMessageModel message;
final UserAvatarBuilder userAvatarBuilder; final UserAvatarBuilder userAvatarBuilder;
@ -62,7 +64,7 @@ class _ChatDetailRowState extends State<ChatDetailRow> {
children: [ children: [
Text( Text(
widget.message.sender.fullName?.toUpperCase() ?? widget.message.sender.fullName?.toUpperCase() ??
'', widget.translations.anonymousUser,
style: const TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,

View file

@ -20,6 +20,7 @@ class ChatTranslations {
this.deleteChatModalCancel = 'Cancel', this.deleteChatModalCancel = 'Cancel',
this.deleteChatModalConfirm = 'Delete', this.deleteChatModalConfirm = 'Delete',
this.noUsersFound = 'No users found', this.noUsersFound = 'No users found',
this.anonymousUser = 'Anonymous user',
}); });
final String chatsTitle; final String chatsTitle;
@ -37,4 +38,7 @@ class ChatTranslations {
final String deleteChatModalCancel; final String deleteChatModalCancel;
final String deleteChatModalConfirm; final String deleteChatModalConfirm;
final String noUsersFound; final String noUsersFound;
/// Shown when the user has no name
final String anonymousUser;
} }

View file

@ -136,7 +136,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
? (widget.chat! as PersonalChatModel) ? (widget.chat! as PersonalChatModel)
.user .user
.fullName ?? .fullName ??
'' widget.translations.anonymousUser
: '', : '',
style: const TextStyle(fontSize: 18), style: const TextStyle(fontSize: 18),
), ),
@ -161,6 +161,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
lastMessage.sender.id != message.sender.id; lastMessage.sender.id != message.sender.id;
messageWidgets.add( messageWidgets.add(
ChatDetailRow( ChatDetailRow(
translations: widget.translations,
message: message, message: message,
isFirstMessage: isFirstMessage, isFirstMessage: isFirstMessage,
userAvatarBuilder: widget.options.userAvatarBuilder, userAvatarBuilder: widget.options.userAvatarBuilder,

View file

@ -129,7 +129,8 @@ class _ChatScreenState extends State<ChatScreen> {
chat.user, chat.user,
40.0, 40.0,
), ),
title: chat.user.fullName ?? '', title: chat.user.fullName ??
translations.anonymousUser,
subTitle: chat.lastMessage != null subTitle: chat.lastMessage != null
? chat.lastMessage ? chat.lastMessage
is ChatTextMessageModel is ChatTextMessageModel

View file

@ -90,7 +90,8 @@ class _NewChatScreenState extends State<NewChatScreen> {
user, user,
40.0, 40.0,
), ),
title: user.fullName ?? '', title:
user.fullName ?? widget.translations.anonymousUser,
), ),
), ),
onTap: () => widget.onPressCreateChat(user), onTap: () => widget.onPressCreateChat(user),