Skip to content

Commit

Permalink
TW-1827: write widget test for chat_app_bar_title
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn committed Jun 24, 2024
1 parent 8b4d523 commit c75e804
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 10 deletions.
2 changes: 1 addition & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2572,7 +2572,7 @@
"hour": {}
}
},
"onlineDayAgo": "online {day} day ago",
"onlineDayAgo": "online {day}d ago",
"@onlineDayAgo": {
"placeholders": {
"day": {}
Expand Down
15 changes: 8 additions & 7 deletions lib/pages/chat/chat_app_bar_title.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,18 @@ class _DirectChatAppBarStatusContent extends StatelessWidget {
);
if (connectivitySnapshot.hasData &&
connectivityResult == ConnectivityResult.none) {
return _ChatAppBarTitleText(
return ChatAppBarTitleText(
text: L10n.of(context)!.noConnection,
);
}
if (directChatPresence == null) {
return _ChatAppBarTitleText(
return ChatAppBarTitleText(
text: L10n.of(context)!.loading,
);
}
final typingText = room.getLocalizedTypingText(context);
if (typingText.isEmpty) {
return _ChatAppBarTitleText(
return ChatAppBarTitleText(
text: room
.getLocalizedStatus(
context,
Expand Down Expand Up @@ -241,11 +241,11 @@ class _GroupChatAppBarStatusContent extends StatelessWidget {
);

if (snapshot.hasData && connectivityResult == ConnectivityResult.none) {
return _ChatAppBarTitleText(text: L10n.of(context)!.noConnection);
return ChatAppBarTitleText(text: L10n.of(context)!.noConnection);
}
final typingText = room.getLocalizedTypingText(context);
if (typingText.isEmpty) {
return _ChatAppBarTitleText(
return ChatAppBarTitleText(
text: room.getLocalizedStatus(context).capitalize(context),
);
} else {
Expand All @@ -256,8 +256,9 @@ class _GroupChatAppBarStatusContent extends StatelessWidget {
}
}

class _ChatAppBarTitleText extends StatelessWidget {
const _ChatAppBarTitleText({
class ChatAppBarTitleText extends StatelessWidget {
const ChatAppBarTitleText({
super.key,
required this.text,
});

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/room_status_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension RoomStatusExtension on Room {

String getLocalizedStatus(BuildContext context, {CachedPresence? presence}) {
if (isDirectChat) {
return _getLocalizedStatusDirectChat(presence, context);
return getLocalizedStatusDirectChat(presence, context);
}

return _getLocalizedStatusGroupChat(context);
Expand Down Expand Up @@ -98,7 +98,7 @@ extension RoomStatusExtension on Room {
return L10n.of(context)!.countMembers(totalMembers);
}

String _getLocalizedStatusDirectChat(
String getLocalizedStatusDirectChat(
CachedPresence? directChatPresence,
BuildContext context,
) {
Expand Down
Loading

0 comments on commit c75e804

Please sign in to comment.