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
- 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 {
const ChatDetailRow({
required this.translations,
required this.isFirstMessage,
required this.message,
required this.userAvatarBuilder,
super.key,
});
final ChatTranslations translations;
final bool isFirstMessage;
final ChatMessageModel message;
final UserAvatarBuilder userAvatarBuilder;
@ -62,7 +64,7 @@ class _ChatDetailRowState extends State<ChatDetailRow> {
children: [
Text(
widget.message.sender.fullName?.toUpperCase() ??
'',
widget.translations.anonymousUser,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,

View file

@ -20,6 +20,7 @@ class ChatTranslations {
this.deleteChatModalCancel = 'Cancel',
this.deleteChatModalConfirm = 'Delete',
this.noUsersFound = 'No users found',
this.anonymousUser = 'Anonymous user',
});
final String chatsTitle;
@ -37,4 +38,7 @@ class ChatTranslations {
final String deleteChatModalCancel;
final String deleteChatModalConfirm;
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)
.user
.fullName ??
''
widget.translations.anonymousUser
: '',
style: const TextStyle(fontSize: 18),
),
@ -161,6 +161,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
lastMessage.sender.id != message.sender.id;
messageWidgets.add(
ChatDetailRow(
translations: widget.translations,
message: message,
isFirstMessage: isFirstMessage,
userAvatarBuilder: widget.options.userAvatarBuilder,

View file

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

View file

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