Add unit tests for ChannelMessage replies and update untranslated.json with new translations

This commit is contained in:
zjs81 committed 2026-09-25 13:23:07 -07:00
1 parent c1680208d8
commit 0e8a8bd8c4
61 files changed
+9701 -1140

No files matched your search

+40 -39
View File
@@ -31,6 +31,7 @@ import '../services/path_history_service.dart';
import '../services/translation_service.dart';
import '../widgets/chat_zoom_wrapper.dart';
import '../widgets/byte_count_input.dart';
import '../widgets/chat_day_separator.dart';
import 'channel_message_path_screen.dart';
import 'map_screen.dart';
import '../widgets/emoji_picker.dart';
@@ -189,10 +190,6 @@ class _ChatScreenState extends State<ChatScreen> {
title: Consumer2<PathHistoryService, MeshCoreConnector>(
builder: (context, pathService, connector, _) {
final contact = _resolveContact(connector);
final unreadCount = connector.getUnreadCountForContactKey(
widget.contact.publicKeyHex,
);
final unreadLabel = context.l10n.chat_unread(unreadCount);
final pathLabel = _currentPathLabel(contact);
return Column(
@@ -211,7 +208,7 @@ class _ChatScreenState extends State<ChatScreen> {
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: Text(
'$pathLabel • $unreadLabel',
pathLabel,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 11,
@@ -435,10 +432,20 @@ class _ChatScreenState extends State<ChatScreen> {
final isUnreadAnchor =
_unreadDividerMessageId != null &&
message.messageId == _unreadDividerMessageId;
final child = isUnreadAnchor
final startsDay =
messageIndex == reversedMessages.length - 1 ||
!isSameChatDay(
reversedMessages[messageIndex + 1].timestamp,
message.timestamp,
);
final child = isUnreadAnchor || startsDay
? Column(
mainAxisSize: MainAxisSize.min,
children: [const UnreadDivider(), bubble],
children: [
if (startsDay) ChatDaySeparator(day: message.timestamp),
if (isUnreadAnchor) const UnreadDivider(),
bubble,
],
)
: bubble;
if (identical(message, _pendingUnreadScrollTarget)) {
@@ -479,26 +486,10 @@ class _ChatScreenState extends State<ChatScreen> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
PopupMenuButton<String>(
icon: const Icon(Icons.add_circle_outline),
position: PopupMenuPosition.over,
offset: const Offset(0, -64),
tooltip: context.l10n.chat_selectSendAction,
onSelected: (action) {
if (action == 'gif') _showGifPicker(context);
},
itemBuilder: (context) => [
PopupMenuItem(
value: 'gif',
child: Row(
children: [
const Icon(Icons.gif_box),
const SizedBox(width: 12),
Text(context.l10n.chat_sendGif),
],
),
),
],
IconButton(
icon: const Icon(Icons.gif_box_outlined),
tooltip: context.l10n.chat_sendGif,
onPressed: () => _showGifPicker(context),
),
if (settings.translationEnabled)
MessageTranslationButton(
@@ -546,6 +537,7 @@ class _ChatScreenState extends State<ChatScreen> {
const SizedBox(width: 8),
IconButton(
icon: const Icon(Icons.close),
tooltip: context.l10n.chat_removeGif,
onPressed: () {
_textController.clear();
_textFieldFocusNode.requestFocus();
@@ -1121,7 +1113,11 @@ class _ChatScreenState extends State<ChatScreen> {
);
}
void _openMessagePath(Message message, Contact contact) {
void _openMessagePath(
Message message,
Contact contact, {
bool openMap = false,
}) {
final connector = context.read<MeshCoreConnector>();
final fourByteHex = message.fourByteRoomContactKey
.map((b) => b.toRadixString(16).padLeft(2, '0'))
@@ -1153,7 +1149,9 @@ class _ChatScreenState extends State<ChatScreen> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChannelMessagePathScreen(message: pathMessage),
builder: (context) => openMap
? ChannelMessagePathMapScreen(message: pathMessage)
: ChannelMessagePathScreen(message: pathMessage),
),
);
}
@@ -1197,6 +1195,15 @@ class _ChatScreenState extends State<ChatScreen> {
_openMessagePath(message, contact);
},
),
if (message.pathBytes.isNotEmpty)
ListTile(
leading: const Icon(Icons.map_outlined),
title: Text(context.l10n.chat_viewPathOnMap),
onTap: () {
Navigator.pop(sheetContext);
_openMessagePath(message, contact, openMap: true);
},
),
ListTile(
leading: const Icon(Icons.copy),
title: Text(context.l10n.common_copy),
@@ -1628,16 +1635,16 @@ class _MessageBubble extends StatelessWidget {
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text(
_formatTime(message.timestamp),
formatChatTime(context, message.timestamp),
style: MeshTheme.mono(
fontSize: 10 * textScale,
fontSize: 12 * textScale,
color: metaColor,
),
),
if (isOutgoing) ...[
const SizedBox(width: 2),
MessageStatusIcon(
size: 12 * textScale,
size: 16 * textScale,
onColor: metaColor,
isAcked:
message.status ==
@@ -1663,7 +1670,7 @@ class _MessageBubble extends StatelessWidget {
Text(
'${(message.tripTimeMs! / 1000).toStringAsFixed(1)}s',
style: MeshTheme.mono(
fontSize: 9 * textScale,
fontSize: 11 * textScale,
color: isOutgoing
? metaColor
: scheme.tertiary,
@@ -1842,12 +1849,6 @@ class _MessageBubble extends StatelessWidget {
Widget _buildAvatar(String senderName) {
return AvatarCircle(name: senderName, size: 32);
}
String _formatTime(DateTime time) {
final hour = time.hour.toString().padLeft(2, '0');
final minute = time.minute.toString().padLeft(2, '0');
return '$hour:$minute';
}
}
/// Deterministic name-to-hue mapping consistent with [AvatarCircle].