Fix stale map labels, avatar initials and offline bubble widths

- Map node labels follow light/dark theme changes.
- Avatar initials use only letters and digits; hop avatars fall back to the
  hash prefix.
- Incoming channel bubbles are the same width connected and offline.
- Day separators wrap instead of overflowing with large text.
This commit is contained in:
zjs81 committed 2026-11-20 16:04:50 -07:00
1 parent 34ea0cb7ca
commit 92dadb0d3a
12 files changed
+642 -48

No files matched your search

+3 -1
View File
@@ -3958,8 +3958,10 @@ class _SwipeReplyBubbleState extends State<_SwipeReplyBubble> {
onPointerMove: _handleSwipePointerMove,
onPointerUp: (event) => _handleSwipePointerUp(event.position),
onPointerCancel: (_) => _resetSwipe(),
// Same insets as the plain row in _buildMessageBubble, so a bubble is
// as wide whether or not it can be swiped (offline, desktop, outgoing).
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 8),
padding: const EdgeInsets.symmetric(vertical: 3),
child: Stack(
alignment: Alignment.center,
children: [
+19 -9
View File
@@ -21,6 +21,7 @@ import '../models/display_path.dart';
import '../models/path_playback.dart';
import '../theme/mesh_theme.dart';
import '../widgets/adaptive_app_bar_title.dart';
import '../widgets/contact_visuals.dart';
import '../widgets/mesh_ui.dart';
import '../widgets/path_map_scaffold.dart';
import '../widgets/path_map_ui.dart';
@@ -356,7 +357,7 @@ class ChannelMessagePathScreen extends StatelessWidget {
Stack(
clipBehavior: Clip.none,
children: [
AvatarCircle(name: hop.displayLabel, size: 36),
AvatarCircle(name: hop.avatarName, size: 36),
Positioned(
right: -4,
top: -4,
@@ -1616,14 +1617,23 @@ class _PathHop {
bool get hasLocation => position != null;
String get displayLabel {
final prefixLabel = hopBytes != null && hopBytes!.isNotEmpty
? hopBytes!
.map((b) => b.toRadixString(16).padLeft(2, '0'))
.join('')
.toUpperCase()
: _formatPrefix(prefix);
return '($prefixLabel) ${_resolveName(contact, l10n)}';
String get prefixLabel => hopBytes != null && hopBytes!.isNotEmpty
? hopBytes!
.map((b) => b.toRadixString(16).padLeft(2, '0'))
.join('')
.toUpperCase()
: _formatPrefix(prefix);
String get displayLabel => '($prefixLabel) ${_resolveName(contact, l10n)}';
/// Avatar source: the repeater's own name, or the hop's hex prefix when
/// the hop is unresolved or its name has nothing to make initials from.
String get avatarName {
final name = contact?.name.trim() ?? '';
if (name.toLowerCase() == 'unknown' || avatarInitials(name) == null) {
return prefixLabel;
}
return name;
}
}
+8 -1
View File
@@ -1198,6 +1198,9 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
showOtherNodes: settings.mapShowOtherNodes,
isBuildingPathTrace: _isBuildingPathTrace,
clusterNodes: settings.mapClusterNodes,
// Node labels bake in the overlay colors, so a light/dark or theme
// switch must rebuild them.
colorScheme: Theme.of(context).colorScheme,
);
if (key != _nodeMarkersCacheKey) {
_nodeMarkersCacheKey = key;
@@ -4385,6 +4388,7 @@ class _NodeMarkersCacheKey {
final bool showOtherNodes;
final bool isBuildingPathTrace;
final bool clusterNodes;
final ColorScheme colorScheme;
const _NodeMarkersCacheKey({
required this.contactsSignature,
@@ -4405,6 +4409,7 @@ class _NodeMarkersCacheKey {
required this.showOtherNodes,
required this.isBuildingPathTrace,
required this.clusterNodes,
required this.colorScheme,
});
@override
@@ -4427,7 +4432,8 @@ class _NodeMarkersCacheKey {
showChatNodes == other.showChatNodes &&
showOtherNodes == other.showOtherNodes &&
isBuildingPathTrace == other.isBuildingPathTrace &&
clusterNodes == other.clusterNodes;
clusterNodes == other.clusterNodes &&
colorScheme == other.colorScheme;
}
@override
@@ -4450,6 +4456,7 @@ class _NodeMarkersCacheKey {
showOtherNodes,
isBuildingPathTrace,
clusterNodes,
colorScheme,
);
}
+6 -1
View File
@@ -32,7 +32,12 @@ class PlatformInfo {
static bool get isMobile => isAndroid || isIOS;
/// Whether the app is running on a desktop platform (macOS, Windows, or Linux).
static bool get isDesktop => isMacOS || isWindows || isLinux;
static bool get isDesktop =>
debugIsDesktopOverride ?? (isMacOS || isWindows || isLinux);
/// Lets widget tests exercise the mobile layout on a desktop test host.
@visibleForTesting
static bool? debugIsDesktopOverride;
/// Whether the current platform supports a native USB serial backend.
static bool get supportsNativeUsbSerial =>
+27 -14
View File
@@ -44,21 +44,34 @@ class ChatDaySeparator extends StatelessWidget {
);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Row(
children: [
line,
const SizedBox(width: 10),
Text(
formatChatDayLabel(context, day),
style: MeshTheme.mono(
fontSize: 12,
fontWeight: FontWeight.w600,
color: color,
child: LayoutBuilder(
// Large text on a narrow phone wraps the label instead of overflowing;
// each rule keeps at least 16dp.
builder: (context, constraints) => Row(
children: [
line,
const SizedBox(width: 10),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: (constraints.maxWidth - 2 * (10 + 16)).clamp(
0.0,
double.infinity,
),
),
child: Text(
formatChatDayLabel(context, day),
textAlign: TextAlign.center,
style: MeshTheme.mono(
fontSize: 12,
fontWeight: FontWeight.w600,
color: color,
),
),
),
),
const SizedBox(width: 10),
line,
],
const SizedBox(width: 10),
line,
],
),
),
);
}
+35
View File
@@ -5,6 +5,7 @@ import '../l10n/app_localizations.dart';
import '../models/contact.dart';
import '../theme/mesh_theme.dart';
import '../theme/theme_icons.dart';
import '../utils/emoji_utils.dart';
/// Shared node-type visuals and last-seen formatting for contact lists
/// (contacts, discovery, nearby-node scan).
@@ -41,6 +42,40 @@ ThemeIconSlot? contactTypeIconSlot(int type) {
}
}
final RegExp _letterOrDigit = RegExp(r'^[\p{L}\p{N}]', unicode: true);
/// Avatar initials for a display name, or null when the name has nothing
/// usable so the caller can show an icon or key prefix instead.
///
/// Only letters and digits count: punctuation such as `-`, `(` or `[` splits
/// words but never becomes an initial, so "(Base) Node" gives "BN" and
/// "- Relay" gives "RE". Characters are whole grapheme clusters, so accented
/// letters and emoji are never cut in half. A name with no letters or digits
/// but an emoji shows that emoji.
String? avatarInitials(String name) {
final words = <String>[];
final current = StringBuffer();
String? emoji;
for (final cluster in name.characters) {
if (_letterOrDigit.hasMatch(cluster)) {
current.write(cluster);
continue;
}
if (current.isNotEmpty) {
words.add(current.toString());
current.clear();
}
emoji ??= firstEmoji(cluster);
}
if (current.isNotEmpty) words.add(current.toString());
if (words.isEmpty) return emoji;
if (words.length == 1) {
return words.first.characters.take(2).toString().toUpperCase();
}
return (words[0].characters.first + words[1].characters.first).toUpperCase();
}
/// The most recent activity for [contact]: for chat nodes this includes the
/// last message, for other node types only the last advert or telemetry fix.
DateTime resolveContactLastSeen(Contact contact) {
+6 -19
View File
@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
import '../l10n/l10n.dart';
import '../theme/mesh_theme.dart';
import '../theme/theme_icons.dart';
import 'contact_visuals.dart';
/// MeshCore shared design kit.
///
@@ -283,7 +284,8 @@ class StatTile extends StatelessWidget {
/// Initials avatar with a deterministic per-name hue, or a fixed [color]
/// for node-type coloring. Optional [icon] or themeable [iconSlot] replaces
/// initials.
/// initials. Initials come from [avatarInitials]; a name with no letters,
/// digits or emoji shows a generic person icon instead.
class AvatarCircle extends StatelessWidget {
final String name;
final double size;
@@ -320,7 +322,7 @@ class AvatarCircle extends StatelessWidget {
@override
Widget build(BuildContext context) {
final accent = color ?? _colorFor(name);
final initials = _initials(name);
final initials = avatarInitials(name);
final background = _tintedCardBackground(context, accent, 0.14);
// A theme picture (e.g. a holiday marker) fills the whole circle, the
// same as on the map, rather than sitting small inside the tint.
@@ -360,9 +362,9 @@ class AvatarCircle extends StatelessWidget {
size: size * 0.55,
color: readableAccent(accent, background, minContrast: 3),
)
: icon != null
: icon != null || initials == null
? Icon(
icon,
icon ?? Icons.person_outline,
size: size * 0.5,
color: readableAccent(accent, background, minContrast: 3),
)
@@ -376,21 +378,6 @@ class AvatarCircle extends StatelessWidget {
),
);
}
static String _initials(String name) {
final words = name
.trim()
.split(RegExp(r'\s+'))
.where((w) => w.isNotEmpty)
.toList();
if (words.isEmpty) return '?';
if (words.length == 1) {
return words.first.characters.take(2).toString().toUpperCase();
}
return (words.first.characters.take(1).toString() +
words[1].characters.take(1).toString())
.toUpperCase();
}
}
/// Four-bar signal strength indicator driven by an SNR value (dB), colored