From 77572a7cd502cd24d12970e31b71434d92c5a10b Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sun, 29 Nov 2026 04:55:02 -0500 Subject: [PATCH 1/5] fix(#1273): one triangle signal glyph per strength level The signal helper drew a triangle at the top tier and bars below it, and the two lowest tiers shared one glyph. Every tier now uses the Material Symbols triangle family (4 bars down to 0, and "off" for no reading), filled, through one SignalIcon widget at all five call sites. Regression test signal_ui_test.dart: distinct glyph per tier, one family, filled, and no screen draws a signal glyph outside SignalIcon. Against dev's icons 3 of 4 cases fail. Epic: #1272 Agent: StormyElk (session 088ce922) --- lib/screens/neighbors_screen.dart | 3 +- lib/screens/path_trace_map.dart | 3 +- lib/widgets/device_tile.dart | 2 +- lib/widgets/signal_ui.dart | 30 ++++++++++++++++---- lib/widgets/snr_indicator.dart | 6 ++-- test/widgets/signal_ui_test.dart | 46 +++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 test/widgets/signal_ui_test.dart diff --git a/lib/screens/neighbors_screen.dart b/lib/screens/neighbors_screen.dart index 77559d48..f9c137e9 100644 --- a/lib/screens/neighbors_screen.dart +++ b/lib/screens/neighbors_screen.dart @@ -10,6 +10,7 @@ import '../connector/meshcore_connector.dart'; import '../connector/meshcore_protocol.dart'; import '../services/repeater_command_service.dart'; import '../widgets/path_management_dialog.dart'; +import '../widgets/signal_ui.dart'; import '../widgets/snr_indicator.dart'; import '../helpers/snack_bar_builder.dart'; @@ -466,7 +467,7 @@ class _NeighborsScreenState extends State { trailing: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon(snrUi.icon, color: snrUi.color, size: 18.0), + SignalIcon(snrUi.icon, color: snrUi.color, size: 18.0), Text( snrUi.text, style: TextStyle(fontSize: 10, color: snrUi.color), diff --git a/lib/screens/path_trace_map.dart b/lib/screens/path_trace_map.dart index a3bc63ac..89309976 100644 --- a/lib/screens/path_trace_map.dart +++ b/lib/screens/path_trace_map.dart @@ -15,6 +15,7 @@ import 'package:meshcore_open/services/app_settings_service.dart'; import 'package:meshcore_open/services/map_tile_cache_service.dart'; import 'package:meshcore_open/utils/app_logger.dart'; import 'package:meshcore_open/widgets/osm_attribution.dart'; +import 'package:meshcore_open/widgets/signal_ui.dart'; import 'package:meshcore_open/widgets/snr_indicator.dart'; import 'package:provider/provider.dart'; @@ -1050,7 +1051,7 @@ class _PathTraceMapScreenState extends State { trailing: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon( + SignalIcon( snrUi.icon, color: snrUi.color, size: 18.0, diff --git a/lib/widgets/device_tile.dart b/lib/widgets/device_tile.dart index f59e1a4d..36fef725 100644 --- a/lib/widgets/device_tile.dart +++ b/lib/widgets/device_tile.dart @@ -50,7 +50,7 @@ class DeviceTile extends StatelessWidget { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon(signalUi.icon, color: signalUi.color), + SignalIcon(signalUi.icon, color: signalUi.color), Text( '$rssi dBm', style: TextStyle(fontSize: 10, color: signalUi.color), diff --git a/lib/widgets/signal_ui.dart b/lib/widgets/signal_ui.dart index e0e05111..242d51b5 100644 --- a/lib/widgets/signal_ui.dart +++ b/lib/widgets/signal_ui.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:material_symbols_icons/symbols.dart'; class SignalUi { final IconData icon; @@ -7,32 +8,51 @@ class SignalUi { const SignalUi({required this.icon, required this.color}); } +/// Signal glyph for "no reading", from the same family as the tiers. +const IconData signalNoReadingIcon = Symbols.signal_cellular_off; + +/// One triangle glyph per tier, all from the same family, so the level reads +/// from the shape alone and never switches between triangles and bars. (#1273) SignalUi signalUiForStrengthTier(int tier) { switch (tier) { case 0: return const SignalUi( - icon: Icons.signal_cellular_4_bar, + icon: Symbols.signal_cellular_4_bar, color: Colors.green, ); case 1: return const SignalUi( - icon: Icons.signal_cellular_alt, + icon: Symbols.signal_cellular_3_bar, color: Colors.lightGreen, ); case 2: return const SignalUi( - icon: Icons.signal_cellular_alt_2_bar, + icon: Symbols.signal_cellular_2_bar, color: Colors.amber, ); case 3: return const SignalUi( - icon: Icons.signal_cellular_alt_1_bar, + icon: Symbols.signal_cellular_1_bar, color: Colors.orange, ); default: return const SignalUi( - icon: Icons.signal_cellular_alt_1_bar, + icon: Symbols.signal_cellular_0_bar, color: Colors.red, ); } } + +/// A signal glyph. Symbols are outlined unless filled, and the bars inside the +/// triangle only read when filled. +class SignalIcon extends StatelessWidget { + final IconData icon; + final Color color; + final double? size; + + const SignalIcon(this.icon, {super.key, required this.color, this.size}); + + @override + Widget build(BuildContext context) => + Icon(icon, color: color, size: size, fill: 1); +} diff --git a/lib/widgets/snr_indicator.dart b/lib/widgets/snr_indicator.dart index 410a1f38..7aa5413f 100644 --- a/lib/widgets/snr_indicator.dart +++ b/lib/widgets/snr_indicator.dart @@ -95,7 +95,7 @@ SNRUi snrUiFromSNR(double? snr, int? spreadingFactor) { spreadingFactor == null || spreadingFactor < 7 || spreadingFactor > 12) { - return const SNRUi(Icons.signal_cellular_off, Colors.grey, '—'); + return const SNRUi(signalNoReadingIcon, Colors.grey, '—'); } final snrLevels = getSNRfromSF(spreadingFactor); @@ -167,7 +167,7 @@ class _SNRIndicatorState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - Icon(snrUi.icon, size: 18, color: snrUi.color), + SignalIcon(snrUi.icon, size: 18, color: snrUi.color), Text( snrUi.text, style: TextStyle(fontSize: 12, color: snrUi.color), @@ -258,7 +258,7 @@ class _SNRIndicatorState extends State { return Column( children: [ ListTile( - leading: Icon(snrUi.icon, color: snrUi.color), + leading: SignalIcon(snrUi.icon, color: snrUi.color), title: Text(name ?? repeater.prefixHex), subtitle: Text( 'SNR: ${repeater.snr.toStringAsFixed(1)} dB\n${l10n.snrIndicator_lastSeen}: ${_formatLastUpdated(repeater.lastUpdated)}', diff --git a/test/widgets/signal_ui_test.dart b/test/widgets/signal_ui_test.dart new file mode 100644 index 00000000..389cf9fd --- /dev/null +++ b/test/widgets/signal_ui_test.dart @@ -0,0 +1,46 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:material_symbols_icons/symbols.dart'; +import 'package:meshcore_open/widgets/signal_ui.dart'; +import 'package:meshcore_open/widgets/snr_indicator.dart'; + +// #1273: the signal glyph switched from a triangle at the top tier to bars +// below it, and the two lowest tiers shared one glyph. +void main() { + final family = Symbols.signal_cellular_4_bar.fontFamily; + + test('every tier has its own glyph, all from one family', () { + final icons = [for (var t = 0; t < 5; t++) signalUiForStrengthTier(t).icon]; + expect(icons.toSet().length, 5); + for (final icon in icons) { + expect(icon.fontFamily, family); + } + }); + + test('no reading uses the same family', () { + expect(snrUiFromSNR(null, 10).icon.fontFamily, family); + }); + + testWidgets('SignalIcon draws the glyph filled', (tester) async { + await tester.pumpWidget( + const MaterialApp( + home: SignalIcon(Symbols.signal_cellular_2_bar, color: Colors.amber), + ), + ); + expect(tester.widget(find.byType(Icon)).fill, 1); + }); + + test('no screen draws a signal glyph outside SignalIcon', () { + final offenders = []; + final pattern = RegExp( + r'Icons\.signal_cellular|\bIcon\(\s*(snrUi|signalUi)\.icon', + ); + for (final f in Directory('lib').listSync(recursive: true)) { + if (f is! File || !f.path.endsWith('.dart')) continue; + if (pattern.hasMatch(f.readAsStringSync())) offenders.add(f.path); + } + expect(offenders, isEmpty); + }); +} From e4e02289386aedd75a319a2aa542264ca21c3a6c Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sun, 29 Nov 2026 04:56:52 -0500 Subject: [PATCH 2/5] fix(#1274): solid bottom bar, no frosted glow over the map The tab bar was a transparent frosted BackdropFilter. No screen draws behind it, so the blur only showed where it sampled the content above its top edge: the light map bled in as a glow. It is now a standard opaque Material NavigationBar. The shell no longer wraps it in a SafeArea, since NavigationBar pads for the bottom inset itself and paints its colour under the home indicator. Regression test quick_switch_bar_test.dart: no BackdropFilter and an opaque surface in light and dark, and inside the shell the bar reaches the bottom edge under a 34px inset. Each fails against dev. Epic: #1272 Agent: StormyElk (session 088ce922) --- lib/widgets/app_shell.dart | 15 ++- lib/widgets/quick_switch_bar.dart | 127 ++++++++++-------------- test/widgets/quick_switch_bar_test.dart | 88 ++++++++++++++++ 3 files changed, 149 insertions(+), 81 deletions(-) create mode 100644 test/widgets/quick_switch_bar_test.dart diff --git a/lib/widgets/app_shell.dart b/lib/widgets/app_shell.dart index 176978a9..67c50b43 100644 --- a/lib/widgets/app_shell.dart +++ b/lib/widgets/app_shell.dart @@ -191,14 +191,13 @@ class _AppShellState extends State { final index = widget.selectedIndex; final onSelected = widget.onDestinationSelected; if (index == null || onSelected == null) return null; - return SafeArea( - top: false, - child: QuickSwitchBar( - selectedIndex: index, - onDestinationSelected: onSelected, - contactsUnreadCount: widget.contactsUnreadCount, - channelsUnreadCount: widget.channelsUnreadCount, - ), + // NavigationBar pads for the bottom inset itself and paints its colour + // under it, so it is not wrapped in a SafeArea. + return QuickSwitchBar( + selectedIndex: index, + onDestinationSelected: onSelected, + contactsUnreadCount: widget.contactsUnreadCount, + channelsUnreadCount: widget.channelsUnreadCount, ); } diff --git a/lib/widgets/quick_switch_bar.dart b/lib/widgets/quick_switch_bar.dart index 40dcb59a..80f5c46e 100644 --- a/lib/widgets/quick_switch_bar.dart +++ b/lib/widgets/quick_switch_bar.dart @@ -1,5 +1,3 @@ -import 'dart:ui'; - import 'package:flutter/material.dart'; import '../l10n/l10n.dart'; @@ -23,80 +21,63 @@ class QuickSwitchBar extends StatelessWidget { final colorScheme = theme.colorScheme; final labelStyle = theme.textTheme.labelMedium ?? const TextStyle(); - return SizedBox( - width: double.infinity, - child: ClipRRect( - borderRadius: BorderRadius.circular(20), - child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 14, sigmaY: 14), - child: DecoratedBox( - decoration: BoxDecoration( - color: Colors.transparent, - border: Border.all( - color: colorScheme.outlineVariant.withValues(alpha: 0.4), - ), + // A plain opaque bar. The frosted BackdropFilter it replaced had nothing + // drawn behind it, so it only showed as a glow where its blur sampled the + // content above its top edge, such as the map. (#1274) + return NavigationBarTheme( + data: NavigationBarThemeData( + indicatorColor: colorScheme.primaryContainer, + labelTextStyle: WidgetStateProperty.resolveWith((states) { + final isSelected = states.contains(WidgetState.selected); + return labelStyle.copyWith( + fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500, + color: isSelected + ? colorScheme.onPrimaryContainer + : colorScheme.onSurfaceVariant, + ); + }), + iconTheme: WidgetStateProperty.resolveWith((states) { + final isSelected = states.contains(WidgetState.selected); + return IconThemeData( + color: isSelected + ? colorScheme.onPrimaryContainer + : colorScheme.onSurfaceVariant, + ); + }), + ), + child: NavigationBar( + height: 60, + selectedIndex: selectedIndex, + onDestinationSelected: onDestinationSelected, + destinations: [ + NavigationDestination( + icon: _buildIconWithBadge( + const Icon(Icons.people_outline), + contactsUnreadCount, ), - child: NavigationBarTheme( - data: NavigationBarThemeData( - backgroundColor: Colors.transparent, - surfaceTintColor: Colors.transparent, - shadowColor: Colors.transparent, - indicatorColor: colorScheme.primaryContainer, - labelTextStyle: WidgetStateProperty.resolveWith((states) { - final isSelected = states.contains(WidgetState.selected); - return labelStyle.copyWith( - fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500, - color: isSelected - ? colorScheme.onPrimaryContainer - : colorScheme.onSurfaceVariant, - ); - }), - iconTheme: WidgetStateProperty.resolveWith((states) { - final isSelected = states.contains(WidgetState.selected); - return IconThemeData( - color: isSelected - ? colorScheme.onPrimaryContainer - : colorScheme.onSurfaceVariant, - ); - }), - ), - child: NavigationBar( - height: 60, - selectedIndex: selectedIndex, - onDestinationSelected: onDestinationSelected, - destinations: [ - NavigationDestination( - icon: _buildIconWithBadge( - const Icon(Icons.people_outline), - contactsUnreadCount, - ), - selectedIcon: _buildIconWithBadge( - const Icon(Icons.people), - contactsUnreadCount, - ), - label: context.l10n.nav_contacts, - ), - NavigationDestination( - icon: _buildIconWithBadge( - const Icon(Icons.tag), - channelsUnreadCount, - ), - selectedIcon: _buildIconWithBadge( - const Icon(Icons.tag), - channelsUnreadCount, - ), - label: context.l10n.nav_channels, - ), - NavigationDestination( - icon: const Icon(Icons.map_outlined), - selectedIcon: const Icon(Icons.map), - label: context.l10n.nav_map, - ), - ], - ), + selectedIcon: _buildIconWithBadge( + const Icon(Icons.people), + contactsUnreadCount, ), + label: context.l10n.nav_contacts, ), - ), + NavigationDestination( + icon: _buildIconWithBadge( + const Icon(Icons.tag), + channelsUnreadCount, + ), + selectedIcon: _buildIconWithBadge( + const Icon(Icons.tag), + channelsUnreadCount, + ), + label: context.l10n.nav_channels, + ), + NavigationDestination( + icon: const Icon(Icons.map_outlined), + selectedIcon: const Icon(Icons.map), + label: context.l10n.nav_map, + ), + ], ), ); } diff --git a/test/widgets/quick_switch_bar_test.dart b/test/widgets/quick_switch_bar_test.dart new file mode 100644 index 00000000..1b3e0ae3 --- /dev/null +++ b/test/widgets/quick_switch_bar_test.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/l10n/app_localizations.dart'; +import 'package:meshcore_open/services/ui_view_state_service.dart'; +import 'package:meshcore_open/widgets/app_shell.dart'; +import 'package:meshcore_open/widgets/quick_switch_bar.dart'; +import 'package:provider/provider.dart'; + +// #1274: the bar was a frosted BackdropFilter over a transparent background. +// Nothing was drawn behind it, so the blur only showed where it sampled the +// content above its top edge, as a glow over the light map. +void main() { + for (final brightness in Brightness.values) { + testWidgets('the bar is opaque with no blur ($brightness)', (tester) async { + await tester.pumpWidget( + MaterialApp( + localizationsDelegates: const [ + AppLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: AppLocalizations.supportedLocales, + theme: ThemeData( + colorScheme: ColorScheme.fromSeed( + seedColor: Colors.blue, + brightness: brightness, + ), + useMaterial3: true, + ), + home: Scaffold( + body: const SizedBox.expand(), + bottomNavigationBar: QuickSwitchBar( + selectedIndex: 2, + onDestinationSelected: (_) {}, + ), + ), + ), + ); + + expect(find.byType(BackdropFilter), findsNothing); + final surface = tester.widget( + find + .descendant( + of: find.byType(NavigationBar), + matching: find.byType(Material), + ) + .first, + ); + expect(surface.color, isNotNull); + expect(surface.color!.a, 1.0); + }); + } + + testWidgets('in the shell, the bar paints down under the bottom inset', ( + tester, + ) async { + tester.view.physicalSize = const Size(400, 800); + tester.view.devicePixelRatio = 1; + tester.view.padding = const FakeViewPadding(bottom: 34); + addTearDown(tester.view.reset); + + await tester.pumpWidget( + ChangeNotifierProvider( + create: (_) => UiViewStateService(), + child: MaterialApp( + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: AppShell( + isTopLevel: true, + selectedIndex: 2, + onDestinationSelected: (_) {}, + body: const SizedBox.expand(), + ), + ), + ), + ); + + final surface = find + .descendant( + of: find.byType(NavigationBar), + matching: find.byType(Material), + ) + .first; + expect(tester.getRect(surface).bottom, 800); + expect(tester.getRect(surface).height, greaterThanOrEqualTo(60 + 34)); + }); +} From 074d186c094d79ae2e943d04a903583710dccfe4 Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sun, 29 Nov 2026 05:01:21 -0500 Subject: [PATCH 3/5] fix(#1275): one app-bar title style on every screen Ten screens built their two-line header by hand with different sizes (titles 24 / 22 / 18 bold / 16, subtitles 11 / 12 / 14), and eleven more shrank a long title to fit (AdaptiveAppBarTitle) instead of cutting it off. A new AppBarTitle gives every app bar the app bar's own title style and a 14 normal subtitle, cut off with an ellipsis when long. It replaces AdaptiveAppBarTitle, which is removed. The DM subtitle loses its dotted underline and tap: the full path is reached from Path Management. Regression test app_bar_title_test.dart: sizes, no shrink-to-fit, every AppBar title in lib goes through AppBarTitle or plain Text with no hard-coded size, and no dotted underline in the DM header. The two source guards fail against dev. Epic: #1272 Agent: StormyElk (session 088ce922) --- lib/screens/app_debug_log_screen.dart | 4 +- lib/screens/ble_debug_log_screen.dart | 4 +- lib/screens/channel_chat_screen.dart | 33 +++----- lib/screens/channel_message_path_screen.dart | 8 +- lib/screens/chat_screen.dart | 32 ++----- lib/screens/community_qr_scanner_screen.dart | 4 +- lib/screens/device_cli_screen.dart | 17 +--- lib/screens/export_config_screen.dart | 4 +- lib/screens/import_config_screen.dart | 4 +- lib/screens/map_cache_screen.dart | 4 +- lib/screens/neighbors_screen.dart | 20 +---- lib/screens/path_trace_map.dart | 15 +--- lib/screens/repeater_cli_screen.dart | 16 +--- lib/screens/repeater_hub_screen.dart | 30 ++----- lib/screens/repeater_settings_screen.dart | 17 +--- lib/screens/repeater_status_screen.dart | 16 +--- lib/screens/scanner_screen.dart | 4 +- lib/screens/tcp_screen.dart | 4 +- lib/screens/telemetry_screen.dart | 20 +---- lib/screens/topology_debug_screen.dart | 4 +- lib/screens/usb_screen.dart | 4 +- lib/widgets/adaptive_app_bar_title.dart | 17 ---- lib/widgets/app_bar_title.dart | 35 ++++++++ test/widgets/app_bar_title_test.dart | 87 ++++++++++++++++++++ 24 files changed, 192 insertions(+), 211 deletions(-) delete mode 100644 lib/widgets/adaptive_app_bar_title.dart create mode 100644 lib/widgets/app_bar_title.dart create mode 100644 test/widgets/app_bar_title_test.dart diff --git a/lib/screens/app_debug_log_screen.dart b/lib/screens/app_debug_log_screen.dart index f8324335..0da5e384 100644 --- a/lib/screens/app_debug_log_screen.dart +++ b/lib/screens/app_debug_log_screen.dart @@ -4,7 +4,7 @@ import 'package:provider/provider.dart'; import '../l10n/l10n.dart'; import '../services/app_debug_log_service.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import '../helpers/snack_bar_builder.dart'; import '../utils/log_export.dart'; import 'send_logs_screen.dart'; @@ -21,7 +21,7 @@ class AppDebugLogScreen extends StatelessWidget { return Scaffold( appBar: AppBar( - title: AdaptiveAppBarTitle(context.l10n.debugLog_appTitle), + title: AppBarTitle(context.l10n.debugLog_appTitle), centerTitle: true, actions: [ IconButton( diff --git a/lib/screens/ble_debug_log_screen.dart b/lib/screens/ble_debug_log_screen.dart index 8bee9bae..93d4eb8a 100644 --- a/lib/screens/ble_debug_log_screen.dart +++ b/lib/screens/ble_debug_log_screen.dart @@ -4,7 +4,7 @@ import 'package:flutter/services.dart'; import '../l10n/l10n.dart'; import '../services/ble_debug_log_service.dart'; import '../connector/meshcore_protocol.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import '../helpers/snack_bar_builder.dart'; import '../utils/log_export.dart'; import 'send_logs_screen.dart'; @@ -33,7 +33,7 @@ class _BleDebugLogScreenState extends State { : rawEntries.isNotEmpty; return Scaffold( appBar: AppBar( - title: AdaptiveAppBarTitle(context.l10n.debugLog_bleTitle), + title: AppBarTitle(context.l10n.debugLog_bleTitle), actions: [ IconButton( tooltip: LogExport.tooltip(context), diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index e88bf0c0..1e8d5384 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -45,6 +45,7 @@ import '../utils/route_transitions.dart'; import 'chat_screen.dart'; import 'settings_screen.dart'; import '../utils/dialog_utils.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/app_shell.dart'; import '../widgets/channel_drawer_list.dart'; import '../widgets/composer_budget_notice.dart'; @@ -470,32 +471,24 @@ class _ChannelChatScreenState extends State { _channelIcon(_currentChannel), const SizedBox(width: 8), Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( + child: Consumer( + builder: (context, connector, _) { + final unreadCount = connector.getUnreadCountForChannelIndex( + _currentChannel.index, + ); + final privacy = _currentChannel.isPublicChannel + ? context.l10n.channels_public + : context.l10n.channels_private; + return AppBarTitle( _currentChannel.name.isEmpty ? context.l10n.channels_channelIndex( _currentChannel.index, ) : _currentChannel.name, - style: const TextStyle(fontSize: 16), - ), - Consumer( - builder: (context, connector, _) { - final unreadCount = connector - .getUnreadCountForChannelIndex(_currentChannel.index); - final privacy = _currentChannel.isPublicChannel - ? context.l10n.channels_public - : context.l10n.channels_private; - return Text( + subtitle: '$privacy • ${context.l10n.chat_unread(unreadCount)}', - overflow: TextOverflow.ellipsis, - style: const TextStyle(fontSize: 12), - ); - }, - ), - ], + ); + }, ), ), ], diff --git a/lib/screens/channel_message_path_screen.dart b/lib/screens/channel_message_path_screen.dart index 3ad3c229..8a1cc2cc 100644 --- a/lib/screens/channel_message_path_screen.dart +++ b/lib/screens/channel_message_path_screen.dart @@ -16,7 +16,7 @@ import '../l10n/l10n.dart'; import '../models/channel_message.dart'; import '../models/app_settings.dart'; import '../models/contact.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/osm_attribution.dart'; class ChannelMessagePathScreen extends StatelessWidget { @@ -71,7 +71,7 @@ class ChannelMessagePathScreen extends StatelessWidget { final extraPaths = _otherPaths(primaryPath, message.pathVariants); return Scaffold( appBar: AppBar( - title: AdaptiveAppBarTitle(l10n.channelPath_title), + title: AppBarTitle(l10n.channelPath_title), actions: [ IconButton( icon: const Icon(Icons.radar_outlined), @@ -550,9 +550,7 @@ class _ChannelMessagePathMapScreenState _pathDistance = _getPathDistance(points); return Scaffold( - appBar: AppBar( - title: AdaptiveAppBarTitle(context.l10n.channelPath_mapTitle), - ), + appBar: AppBar(title: AppBarTitle(context.l10n.channelPath_mapTitle)), body: SafeArea( top: false, child: Stack( diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index 49da8532..aa83574d 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -31,6 +31,7 @@ import '../services/block_service.dart'; import '../services/chat_text_scale_service.dart'; import '../services/path_history_service.dart'; import '../services/translation_service.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/chat_zoom_wrapper.dart'; import '../widgets/composer_budget_notice.dart'; import '../widgets/contact_settings_dialog.dart'; @@ -195,32 +196,11 @@ class _ChatScreenState extends State { final unreadLabel = context.l10n.chat_unread(unreadCount); final pathLabel = _currentPathLabel(contact); - // Show path details if we have non-empty path data (from device or override) - final effectivePath = contact.pathOverrideBytes ?? contact.path; - final hasPathData = effectivePath.isNotEmpty; - - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text(contact.name), - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: hasPathData - ? () => _showFullPathDialog(context, effectivePath) - : null, - child: Text( - '$pathLabel • $unreadLabel', - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 11, - fontWeight: FontWeight.normal, - decoration: hasPathData ? TextDecoration.underline : null, - decorationStyle: TextDecorationStyle.dotted, - ), - ), - ), - ], + // The full path is reached from Path Management, so the subtitle + // is plain text, not a dotted-underline shortcut. (#1275) + return AppBarTitle( + contact.name, + subtitle: '$pathLabel • $unreadLabel', ); }, ), diff --git a/lib/screens/community_qr_scanner_screen.dart b/lib/screens/community_qr_scanner_screen.dart index a49f4931..217851d2 100644 --- a/lib/screens/community_qr_scanner_screen.dart +++ b/lib/screens/community_qr_scanner_screen.dart @@ -7,7 +7,7 @@ import '../l10n/l10n.dart'; import '../models/channel.dart'; import '../models/community.dart'; import '../storage/community_store.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/qr_scanner_widget.dart'; import '../helpers/channel_share_add.dart'; import '../helpers/channel_slot_ui.dart'; @@ -34,7 +34,7 @@ class _CommunityQrScannerScreenState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: AdaptiveAppBarTitle(context.l10n.channels_scanQr), + title: AppBarTitle(context.l10n.channels_scanQr), centerTitle: true, ), body: _isProcessing diff --git a/lib/screens/device_cli_screen.dart b/lib/screens/device_cli_screen.dart index fe3bc6f6..4783fa8e 100644 --- a/lib/screens/device_cli_screen.dart +++ b/lib/screens/device_cli_screen.dart @@ -24,6 +24,7 @@ import '../helpers/snack_bar_builder.dart'; import '../l10n/l10n.dart'; import '../models/contact.dart'; import '../services/cli_console_transport.dart'; +import '../widgets/app_bar_title.dart'; enum _EntryKind { command, reply, timeout, sendFailed } @@ -334,21 +335,7 @@ class _DeviceCliScreenState extends State { return Scaffold( appBar: AppBar( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text(title), - if (subtitle.isNotEmpty) - Text( - subtitle, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal, - ), - ), - ], - ), + title: AppBarTitle(title, subtitle: subtitle), centerTitle: false, actions: [ IconButton( diff --git a/lib/screens/export_config_screen.dart b/lib/screens/export_config_screen.dart index b8c66620..8d60ec6b 100644 --- a/lib/screens/export_config_screen.dart +++ b/lib/screens/export_config_screen.dart @@ -13,7 +13,7 @@ import '../connector/meshcore_connector.dart'; import '../l10n/l10n.dart'; import '../services/stock_config_export_service.dart'; import '../utils/stock_config_file.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; class ExportConfigScreen extends StatefulWidget { const ExportConfigScreen({super.key}); @@ -34,7 +34,7 @@ class _ExportConfigScreenState extends State { return Scaffold( appBar: AppBar( - title: AdaptiveAppBarTitle(l10n.exportConfig_title), + title: AppBarTitle(l10n.exportConfig_title), centerTitle: true, actions: [ IconButton( diff --git a/lib/screens/import_config_screen.dart b/lib/screens/import_config_screen.dart index 27f86520..daa605e0 100644 --- a/lib/screens/import_config_screen.dart +++ b/lib/screens/import_config_screen.dart @@ -20,7 +20,7 @@ import '../l10n/l10n.dart'; import '../models/stock_config.dart'; import '../services/stock_config_export_service.dart' show StockConfigSection; import '../services/stock_config_import_service.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import 'export_config_screen.dart' show sectionLabel; class ImportConfigScreen extends StatefulWidget { @@ -45,7 +45,7 @@ class _ImportConfigScreenState extends State { return Scaffold( appBar: AppBar( - title: AdaptiveAppBarTitle(l10n.importConfig_title), + title: AppBarTitle(l10n.importConfig_title), centerTitle: true, actions: [ if (config != null) diff --git a/lib/screens/map_cache_screen.dart b/lib/screens/map_cache_screen.dart index e30cb6c4..a7e4a5f1 100644 --- a/lib/screens/map_cache_screen.dart +++ b/lib/screens/map_cache_screen.dart @@ -8,7 +8,7 @@ import '../l10n/app_localizations.dart'; import '../l10n/l10n.dart'; import '../services/app_settings_service.dart'; import '../services/map_tile_cache_service.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/osm_attribution.dart'; import '../helpers/snack_bar_builder.dart'; @@ -289,7 +289,7 @@ class _MapCacheScreenState extends State { return Scaffold( appBar: AppBar( - title: AdaptiveAppBarTitle(l10n.mapCache_title), + title: AppBarTitle(l10n.mapCache_title), centerTitle: true, ), body: Column( diff --git a/lib/screens/neighbors_screen.dart b/lib/screens/neighbors_screen.dart index f9c137e9..08ab430a 100644 --- a/lib/screens/neighbors_screen.dart +++ b/lib/screens/neighbors_screen.dart @@ -9,6 +9,7 @@ import '../models/path_selection.dart'; import '../connector/meshcore_connector.dart'; import '../connector/meshcore_protocol.dart'; import '../services/repeater_command_service.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/path_management_dialog.dart'; import '../widgets/signal_ui.dart'; import '../widgets/snr_indicator.dart'; @@ -274,22 +275,9 @@ class _NeighborsScreenState extends State { return Scaffold( appBar: AppBar( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - l10n.neighbors_repeatersNeighbors, - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), - ), - Text( - repeater.name, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal, - ), - ), - ], + title: AppBarTitle( + l10n.neighbors_repeatersNeighbors, + subtitle: repeater.name, ), centerTitle: false, actions: [ diff --git a/lib/screens/path_trace_map.dart b/lib/screens/path_trace_map.dart index 89309976..e5e91fd6 100644 --- a/lib/screens/path_trace_map.dart +++ b/lib/screens/path_trace_map.dart @@ -15,6 +15,7 @@ import 'package:meshcore_open/services/app_settings_service.dart'; import 'package:meshcore_open/services/map_tile_cache_service.dart'; import 'package:meshcore_open/utils/app_logger.dart'; import 'package:meshcore_open/widgets/osm_attribution.dart'; +import 'package:meshcore_open/widgets/app_bar_title.dart'; import 'package:meshcore_open/widgets/signal_ui.dart'; import 'package:meshcore_open/widgets/snr_indicator.dart'; import 'package:provider/provider.dart'; @@ -604,19 +605,7 @@ class _PathTraceMapScreenState extends State { return Scaffold( appBar: AppBar( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - FittedBox( - fit: BoxFit.scaleDown, - child: Text( - widget.title, - style: const TextStyle(fontSize: 24), - ), - ), - ], - ), + title: AppBarTitle(widget.title), centerTitle: false, actions: [ IconButton( diff --git a/lib/screens/repeater_cli_screen.dart b/lib/screens/repeater_cli_screen.dart index 33e84324..596c1521 100644 --- a/lib/screens/repeater_cli_screen.dart +++ b/lib/screens/repeater_cli_screen.dart @@ -8,6 +8,7 @@ import '../connector/meshcore_connector.dart'; import '../connector/meshcore_protocol.dart'; import '../widgets/debug_frame_viewer.dart'; import '../services/repeater_command_service.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/path_management_dialog.dart'; import '../helpers/snack_bar_builder.dart'; @@ -255,20 +256,7 @@ class _RepeaterCliScreenState extends State { return Scaffold( appBar: AppBar( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text(l10n.repeater_cliTitle), - Text( - repeater.name, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal, - ), - ), - ], - ), + title: AppBarTitle(l10n.repeater_cliTitle, subtitle: repeater.name), centerTitle: false, actions: [ PopupMenuButton( diff --git a/lib/screens/repeater_hub_screen.dart b/lib/screens/repeater_hub_screen.dart index 083cc48f..76e17763 100644 --- a/lib/screens/repeater_hub_screen.dart +++ b/lib/screens/repeater_hub_screen.dart @@ -5,6 +5,7 @@ import '../l10n/l10n.dart'; import '../models/contact.dart'; import '../l10n/contact_localization.dart'; import '../services/app_settings_service.dart'; +import '../widgets/app_bar_title.dart'; import 'repeater_status_screen.dart'; import 'repeater_cli_screen.dart'; import 'repeater_settings_screen.dart'; @@ -35,30 +36,15 @@ class RepeaterHubScreen extends StatelessWidget { ); return Scaffold( appBar: AppBar( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - if (isAdmin) - Text( - repeater.type == advTypeRepeater + title: AppBarTitle( + isAdmin + ? (repeater.type == advTypeRepeater ? l10n.repeater_management - : l10n.room_management, - ), - if (!isAdmin) - Text( - repeater.type == advTypeRepeater + : l10n.room_management) + : (repeater.type == advTypeRepeater ? l10n.repeater_guest - : l10n.room_guest, - ), - Text( - repeater.name, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal, - ), - ), - ], + : l10n.room_guest), + subtitle: repeater.name, ), centerTitle: false, ), diff --git a/lib/screens/repeater_settings_screen.dart b/lib/screens/repeater_settings_screen.dart index f1a87478..d01a058d 100644 --- a/lib/screens/repeater_settings_screen.dart +++ b/lib/screens/repeater_settings_screen.dart @@ -10,6 +10,7 @@ import '../models/radio_preset.dart'; import '../services/radio_preset_service.dart'; import '../services/repeater_command_service.dart'; import '../services/storage_service.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/path_management_dialog.dart'; import '../widgets/radio_preset_picker.dart'; import '../helpers/remote_radio_commands.dart'; @@ -1153,19 +1154,9 @@ class _RepeaterSettingsScreenState extends State { return Scaffold( appBar: AppBar( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text(l10n.repeater_settingsTitle), - Text( - repeater.name, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal, - ), - ), - ], + title: AppBarTitle( + l10n.repeater_settingsTitle, + subtitle: repeater.name, ), centerTitle: false, actions: [ diff --git a/lib/screens/repeater_status_screen.dart b/lib/screens/repeater_status_screen.dart index 9dbd8e31..df39b07d 100644 --- a/lib/screens/repeater_status_screen.dart +++ b/lib/screens/repeater_status_screen.dart @@ -11,6 +11,7 @@ import '../connector/meshcore_protocol.dart'; import '../services/app_settings_service.dart'; import '../services/repeater_command_service.dart'; import '../utils/battery_utils.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/path_management_dialog.dart'; import '../helpers/snack_bar_builder.dart'; @@ -356,20 +357,7 @@ class _RepeaterStatusScreenState extends State { return Scaffold( appBar: AppBar( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text(l10n.repeater_statusTitle), - Text( - repeater.name, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal, - ), - ), - ], - ), + title: AppBarTitle(l10n.repeater_statusTitle, subtitle: repeater.name), centerTitle: false, actions: [ PopupMenuButton( diff --git a/lib/screens/scanner_screen.dart b/lib/screens/scanner_screen.dart index 14b476b6..2500d7c7 100644 --- a/lib/screens/scanner_screen.dart +++ b/lib/screens/scanner_screen.dart @@ -9,7 +9,7 @@ import '../connector/meshcore_connector.dart'; import '../l10n/l10n.dart'; import '../services/linux_ble_error_classifier.dart'; import '../utils/app_logger.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/battery_optimization_banner.dart'; import '../widgets/device_tile.dart'; import '../helpers/snack_bar_builder.dart'; @@ -142,7 +142,7 @@ class _ScannerScreenState extends State { }, ) : null, - title: AdaptiveAppBarTitle(context.l10n.scanner_title), + title: AppBarTitle(context.l10n.scanner_title), centerTitle: true, automaticallyImplyLeading: false, actions: [ diff --git a/lib/screens/tcp_screen.dart b/lib/screens/tcp_screen.dart index b51d3766..6271c3e9 100644 --- a/lib/screens/tcp_screen.dart +++ b/lib/screens/tcp_screen.dart @@ -8,7 +8,7 @@ import '../l10n/l10n.dart'; import '../services/app_settings_service.dart'; import '../utils/app_logger.dart'; import '../utils/platform_info.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import '../helpers/snack_bar_builder.dart'; import 'channels_screen.dart'; import 'usb_screen.dart'; @@ -86,7 +86,7 @@ class _TcpScreenState extends State { icon: const Icon(Icons.arrow_back), onPressed: () => Navigator.of(context).maybePop(), ), - title: AdaptiveAppBarTitle(context.l10n.tcpScreenTitle), + title: AppBarTitle(context.l10n.tcpScreenTitle), centerTitle: true, ), body: SafeArea( diff --git a/lib/screens/telemetry_screen.dart b/lib/screens/telemetry_screen.dart index f277a8e1..6ae9bb44 100644 --- a/lib/screens/telemetry_screen.dart +++ b/lib/screens/telemetry_screen.dart @@ -13,6 +13,7 @@ import '../connector/meshcore_protocol.dart'; import '../services/app_settings_service.dart'; import '../services/repeater_command_service.dart'; import '../utils/app_logger.dart'; +import '../widgets/app_bar_title.dart'; import '../widgets/path_management_dialog.dart'; import '../helpers/cayenne_lpp.dart'; import '../utils/battery_utils.dart'; @@ -327,22 +328,9 @@ class _TelemetryScreenState extends State { return Scaffold( appBar: AppBar( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - l10n.repeater_telemetry, - style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold), - ), - Text( - widget.contact.name, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal, - ), - ), - ], + title: AppBarTitle( + l10n.repeater_telemetry, + subtitle: widget.contact.name, ), centerTitle: false, bottom: const SyncProgressAppBarBottom(), diff --git a/lib/screens/topology_debug_screen.dart b/lib/screens/topology_debug_screen.dart index 3b2f5691..d96027b0 100644 --- a/lib/screens/topology_debug_screen.dart +++ b/lib/screens/topology_debug_screen.dart @@ -7,7 +7,7 @@ import '../connector/meshcore_protocol.dart'; import '../helpers/snack_bar_builder.dart'; import '../models/contact.dart'; import '../services/mesh_topology_service.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; /// Read-only diagnostic view of the passively-learned mesh topology (#196 / /// epic #186). It answers one question on real hardware: is @@ -33,7 +33,7 @@ class TopologyDebugScreen extends StatelessWidget { return Scaffold( appBar: AppBar( - title: const AdaptiveAppBarTitle('Mesh topology'), + title: const AppBarTitle('Mesh topology'), centerTitle: true, actions: [ IconButton( diff --git a/lib/screens/usb_screen.dart b/lib/screens/usb_screen.dart index 01ddb112..051c01f2 100644 --- a/lib/screens/usb_screen.dart +++ b/lib/screens/usb_screen.dart @@ -9,7 +9,7 @@ import '../l10n/l10n.dart'; import '../utils/app_logger.dart'; import '../utils/platform_info.dart'; import '../utils/usb_port_labels.dart'; -import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/app_bar_title.dart'; import '../helpers/snack_bar_builder.dart'; import 'channels_screen.dart'; import 'scanner_screen.dart'; @@ -90,7 +90,7 @@ class _UsbScreenState extends State { icon: const Icon(Icons.arrow_back), onPressed: () => Navigator.of(context).maybePop(), ), - title: AdaptiveAppBarTitle(context.l10n.usbScreenTitle), + title: AppBarTitle(context.l10n.usbScreenTitle), centerTitle: true, ), body: SafeArea( diff --git a/lib/widgets/adaptive_app_bar_title.dart b/lib/widgets/adaptive_app_bar_title.dart deleted file mode 100644 index 12363dd7..00000000 --- a/lib/widgets/adaptive_app_bar_title.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter/material.dart'; - -class AdaptiveAppBarTitle extends StatelessWidget { - final String text; - - const AdaptiveAppBarTitle(this.text, {super.key}); - - @override - Widget build(BuildContext context) { - return LayoutBuilder( - builder: (context, constraints) => SizedBox( - width: constraints.maxWidth, - child: FittedBox(fit: BoxFit.scaleDown, child: Text(text, maxLines: 1)), - ), - ); - } -} diff --git a/lib/widgets/app_bar_title.dart b/lib/widgets/app_bar_title.dart new file mode 100644 index 00000000..54eb4de0 --- /dev/null +++ b/lib/widgets/app_bar_title.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +/// The two-line app-bar title: the title in the app bar's own style, and a +/// subtitle under it. Every screen with a subtitle uses this, so the sizes +/// cannot drift apart again. (#1275) +class AppBarTitle extends StatelessWidget { + final String title; + final String? subtitle; + + static const subtitleStyle = TextStyle( + fontSize: 14, + fontWeight: FontWeight.normal, + ); + + const AppBarTitle(this.title, {super.key, this.subtitle}); + + @override + Widget build(BuildContext context) { + final sub = subtitle; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text(title, maxLines: 1, overflow: TextOverflow.ellipsis), + if (sub != null && sub.isNotEmpty) + Text( + sub, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: subtitleStyle, + ), + ], + ); + } +} diff --git a/test/widgets/app_bar_title_test.dart b/test/widgets/app_bar_title_test.dart new file mode 100644 index 00000000..47f2ed2c --- /dev/null +++ b/test/widgets/app_bar_title_test.dart @@ -0,0 +1,87 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/widgets/app_bar_title.dart'; + +// #1275: two-line app-bar headers were built by hand on each screen with +// different sizes (titles 24 / 22 / 18 bold / 16, subtitles 11 / 12 / 14), +// and 11 screens shrank a long title to fit instead of cutting it off. +void main() { + testWidgets('title takes the app bar style, subtitle is 14 normal', ( + tester, + ) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const AppBarTitle('Alpha', subtitle: 'Beta')), + ), + ), + ); + final appBarStyle = Theme.of( + tester.element(find.byType(AppBar)), + ).textTheme.titleLarge!; + + final title = tester.renderObject(find.text('Alpha')); + final subtitle = tester.renderObject(find.text('Beta')); + expect(title.text.style!.fontSize, appBarStyle.fontSize); + expect(subtitle.text.style!.fontSize, 14); + expect(subtitle.text.style!.fontWeight, FontWeight.normal); + expect(subtitle.text.style!.decoration, isNot(TextDecoration.underline)); + expect(find.byType(FittedBox), findsNothing); + }); + + testWidgets('a long title keeps its size and is cut off', (tester) async { + tester.view.physicalSize = const Size(320, 640); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + appBar: AppBar(title: AppBarTitle('W' * 60, subtitle: 'x' * 90)), + ), + ), + ); + final title = tester.renderObject(find.text('W' * 60)); + expect(title.didExceedMaxLines, isTrue); + expect(tester.takeException(), isNull); + }); + + test('every app bar title goes through AppBarTitle or plain Text', () { + final offenders = []; + final appBar = RegExp(r'\bAppBar\('); + final title = RegExp(r'\btitle:\s*'); + for (final f in Directory('lib').listSync(recursive: true)) { + if (f is! File || !f.path.endsWith('.dart')) continue; + final src = f.readAsStringSync(); + for (final m in appBar.allMatches(src)) { + final window = src.substring(m.end, (m.end + 400).clamp(0, src.length)); + final t = title.firstMatch(window); + if (t == null) continue; + final value = window.substring(t.end); + final head = value.substring(0, value.length.clamp(0, 220)); + // A Consumer wrapper is fine as long as what it builds is AppBarTitle. + final consumer = RegExp(r'^Consumer\d?<[^>]+>\(').hasMatch(value); + final ok = consumer + ? src + .substring(m.end, (m.end + 1200).clamp(0, src.length)) + .contains('AppBarTitle(') + : RegExp(r'^(const\s+)?(AppBarTitle|Text|Row)\(').hasMatch(value) && + !head.contains('fontSize') && + !head.contains('FittedBox'); + if (!ok) { + final line = '\n'.allMatches(src.substring(0, m.start)).length + 1; + offenders.add('${f.path}:$line'); + } + } + } + expect(offenders, isEmpty); + }); + + test('no dotted-underline tap targets remain in headers', () { + final chat = File('lib/screens/chat_screen.dart').readAsStringSync(); + expect(chat.contains('TextDecorationStyle.dotted'), isFalse); + }); +} From 202b14e59b993a7432561e94d2b8bf2cf05e7381 Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sun, 29 Nov 2026 05:02:22 -0500 Subject: [PATCH 4/5] fix(#1276): same separator above the input in DM and channel chat The DM composer drew a hard top border in the divider colour; the channel composer drew a soft shadow. All three composer bars (DM text, DM GIF-only, channel) now take composerDecoration: the surface colour with the channel chat's soft shadow. Regression test composer_decoration_test.dart: the decoration has no border, and both chats build their composer bars from it. The source check fails against dev. Epic: #1272 Agent: StormyElk (session 088ce922) --- lib/screens/channel_chat_screen.dart | 12 ++----- lib/screens/chat_screen.dart | 11 ++---- lib/widgets/composer_decoration.dart | 14 ++++++++ test/widgets/composer_decoration_test.dart | 42 ++++++++++++++++++++++ 4 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 lib/widgets/composer_decoration.dart create mode 100644 test/widgets/composer_decoration_test.dart diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 1e8d5384..88194c9e 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -49,6 +49,7 @@ import '../widgets/app_bar_title.dart'; import '../widgets/app_shell.dart'; import '../widgets/channel_drawer_list.dart'; import '../widgets/composer_budget_notice.dart'; +import '../widgets/composer_decoration.dart'; import '../widgets/mention_autocomplete.dart'; import '../helpers/emoji_shortcodes.dart'; import '../widgets/chat_zoom_wrapper.dart'; @@ -1603,16 +1604,7 @@ class _ChannelChatScreenState extends State { ), Container( padding: const EdgeInsets.all(8), - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.surface, - boxShadow: [ - BoxShadow( - color: Colors.black.withValues(alpha: 0.1), - blurRadius: 4, - offset: const Offset(0, -2), - ), - ], - ), + decoration: composerDecoration(context), child: Row( children: [ IconButton( diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index aa83574d..8e4ecdaf 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -34,6 +34,7 @@ import '../services/translation_service.dart'; import '../widgets/app_bar_title.dart'; import '../widgets/chat_zoom_wrapper.dart'; import '../widgets/composer_budget_notice.dart'; +import '../widgets/composer_decoration.dart'; import '../widgets/contact_settings_dialog.dart'; import '../widgets/elements_ui.dart'; import '../widgets/mention_autocomplete.dart'; @@ -624,10 +625,7 @@ class _ChatScreenState extends State { ) { return Container( padding: const EdgeInsets.all(8), - decoration: BoxDecoration( - color: colorScheme.surface, - border: Border(top: BorderSide(color: Theme.of(context).dividerColor)), - ), + decoration: composerDecoration(context), child: SafeArea( child: Row( children: [ @@ -764,10 +762,7 @@ class _ChatScreenState extends State { final colorScheme = Theme.of(context).colorScheme; return Container( padding: const EdgeInsets.all(8), - decoration: BoxDecoration( - color: colorScheme.surface, - border: Border(top: BorderSide(color: Theme.of(context).dividerColor)), - ), + decoration: composerDecoration(context), child: SafeArea( child: Row( children: [ diff --git a/lib/widgets/composer_decoration.dart b/lib/widgets/composer_decoration.dart new file mode 100644 index 00000000..0050a1f7 --- /dev/null +++ b/lib/widgets/composer_decoration.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +/// The bar behind every chat composer: the surface colour with a soft shadow +/// above it, the same in direct and channel chat. (#1276) +BoxDecoration composerDecoration(BuildContext context) => BoxDecoration( + color: Theme.of(context).colorScheme.surface, + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.1), + blurRadius: 4, + offset: const Offset(0, -2), + ), + ], +); diff --git a/test/widgets/composer_decoration_test.dart b/test/widgets/composer_decoration_test.dart new file mode 100644 index 00000000..01a42bbd --- /dev/null +++ b/test/widgets/composer_decoration_test.dart @@ -0,0 +1,42 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/widgets/composer_decoration.dart'; + +// #1276: the DM composer drew a hard top border, the channel composer a soft +// shadow, so the line above the input looked different in the two chats. +void main() { + testWidgets('the composer bar has a soft shadow and no border', ( + tester, + ) async { + late BoxDecoration decoration; + await tester.pumpWidget( + MaterialApp( + home: Builder( + builder: (context) { + decoration = composerDecoration(context); + return const SizedBox(); + }, + ), + ), + ); + expect(decoration.border, isNull); + expect(decoration.boxShadow, isNotEmpty); + }); + + test('both chats build their composer bar from composerDecoration', () { + for (final (path, count) in [ + ('lib/screens/chat_screen.dart', 2), + ('lib/screens/channel_chat_screen.dart', 1), + ]) { + final src = File(path).readAsStringSync(); + expect( + 'composerDecoration(context)'.allMatches(src).length, + count, + reason: path, + ); + expect(src.contains('Border(top: BorderSide('), isFalse, reason: path); + } + }); +} From 55cae21d6af7402274940811d1baaa17c10ed8d8 Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sun, 29 Nov 2026 05:03:55 -0500 Subject: [PATCH 5/5] fix(#1277): plain and @-tagged messages follow the system text size A plain message rendered through flutter_linkify, whose Linkify and SelectableLinkify take only a linear textScaleFactor and default it to 1.0, overriding the system text size. A message with a mention or contact card rendered through Text.rich, which follows it. With a non-default text size the two came out at different sizes. buildLinkifyText now passes the factor the system scaler gives at the message's font size, which also matches non-linear (Android 14) scaling at that size. Regression test message_text_scale_test.dart: under a 1.5x linear and a non-linear scaler, a plain and a mention message draw the body text at the same size. Against dev the plain message stays at 16 while the mention message scales (24 / 22). Epic: #1272 Agent: StormyElk (session 088ce922) --- lib/helpers/link_handler.dart | 9 +++ test/widgets/message_text_scale_test.dart | 87 +++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 test/widgets/message_text_scale_test.dart diff --git a/lib/helpers/link_handler.dart b/lib/helpers/link_handler.dart index d2856ce7..e1be8678 100644 --- a/lib/helpers/link_handler.dart +++ b/lib/helpers/link_handler.dart @@ -80,6 +80,13 @@ class LinkHandler { }) { final effectiveLinkStyle = linkStyle ?? defaultLinkStyle(context, style); void onOpen(LinkableElement link) => handleLinkTap(context, link.url); + // Linkify takes only a linear factor and defaults it to 1.0, which + // ignores the system text size. Text.rich, used for messages with a + // mention or contact card, follows it, so the two rendered at different + // sizes. Pass the factor the system scaler gives at this font size. (#1277) + final fontSize = style.fontSize ?? 14; + final textScaleFactor = + MediaQuery.textScalerOf(context).scale(fontSize) / fontSize; if (PlatformInfo.isDesktop) { return SelectableLinkify( @@ -89,6 +96,7 @@ class LinkHandler { options: _options, linkifiers: _linkifiers, onOpen: onOpen, + textScaleFactor: textScaleFactor, ); } return Linkify( @@ -98,6 +106,7 @@ class LinkHandler { options: _options, linkifiers: _linkifiers, onOpen: onOpen, + textScaleFactor: textScaleFactor, ); } diff --git a/test/widgets/message_text_scale_test.dart b/test/widgets/message_text_scale_test.dart new file mode 100644 index 00000000..486bc676 --- /dev/null +++ b/test/widgets/message_text_scale_test.dart @@ -0,0 +1,87 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_linkify/flutter_linkify.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/l10n/app_localizations.dart'; +import 'package:meshcore_open/widgets/translated_message_content.dart'; + +// #1277: a plain message rendered through flutter_linkify, which fixes its +// text scale at 1.0; a message with an @-mention rendered through Text.rich, +// which follows the system text size. On a phone with a non-default text +// size the two came out at different sizes. + +/// A non-linear scaler, like Android 14 font scaling: +6 at every size. +class _PlusSix extends TextScaler { + const _PlusSix(); + @override + double scale(double fontSize) => fontSize + 6; + @override + double get textScaleFactor => 1.5; + @override + bool operator ==(Object other) => other is _PlusSix; + @override + int get hashCode => 6; +} + +const _fontSize = 16.0; + +Future _pump(WidgetTester tester, String text, TextScaler scaler) => + tester.pumpWidget( + MaterialApp( + localizationsDelegates: const [ + AppLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: AppLocalizations.supportedLocales, + home: Builder( + builder: (context) => MediaQuery( + data: MediaQuery.of(context).copyWith(textScaler: scaler), + child: Scaffold( + body: TranslatedMessageContent( + displayText: text, + style: const TextStyle(fontSize: _fontSize), + ), + ), + ), + ), + ), + ); + +/// The size the plain-message widget will draw [_fontSize] at. +double _plainSize(WidgetTester tester) { + final linkify = find.byWidgetPredicate( + (w) => w is Linkify || w is SelectableLinkify, + ); + final w = tester.widget(linkify); + final factor = w is Linkify + ? w.textScaleFactor + : (w as SelectableLinkify).textScaleFactor; + return _fontSize * factor; +} + +/// The size the mention-message paragraph draws [_fontSize] at. +double _mentionSize(WidgetTester tester) { + final paragraph = tester + .renderObjectList(find.byType(RichText)) + .firstWhere((p) => p.text.toPlainText().contains('hello')); + return paragraph.textScaler.scale(_fontSize); +} + +void main() { + for (final scaler in [const TextScaler.linear(1.5), const _PlusSix()]) { + testWidgets('plain and mention messages scale alike ($scaler)', ( + tester, + ) async { + await _pump(tester, 'hello world', scaler); + final plain = _plainSize(tester); + + await _pump(tester, '@[Bob] hello world', scaler); + final mention = _mentionSize(tester); + + expect(mention, scaler.scale(_fontSize)); + expect(plain, closeTo(mention, 0.001)); + }); + } +}