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 25, 2024
1 parent 8b4d523 commit a46c068
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 14 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
5 changes: 1 addition & 4 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:fluffychat/pages/chat/chat_actions.dart';
import 'package:fluffychat/pages/chat/events/message_content_mixin.dart';
import 'package:fluffychat/presentation/extensions/event_update_extension.dart';
Expand Down Expand Up @@ -262,9 +261,6 @@ class ChatController extends State<Chat>

ValueNotifier<CachedPresence?> cachedPresenceNotifier = ValueNotifier(null);

final StreamController<ConnectivityResult>
connectivityResultStreamController = StreamController.broadcast();

StreamController<CachedPresence> cachedPresenceStreamController =
StreamController.broadcast();

Expand Down Expand Up @@ -2008,6 +2004,7 @@ class ChatController extends State<Chat>
InViewNotifierListCustom.of(context)?.dispose();
replyEventNotifier.dispose();
cachedPresenceStreamController.close();
cachedPresenceNotifier.dispose();
super.dispose();
}

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 a46c068

Please sign in to comment.