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); + }); +}