From 52a578777d7c9356bdd28ea04e3c0f9cd9566b8e Mon Sep 17 00:00:00 2001 From: Winston Lowe Date: Sun, 15 Feb 2026 19:38:34 -0800 Subject: [PATCH] Refactor AppBarTitle widget to remove unused style parameter; update related screens to reflect changes Improve SNR handling by adding validation for spreading factor range in snrUiFromSNR function Update contact handling in MeshCoreConnector to fix variable naming and improve readability Stop parsing unsupported LPP types in CayenneLpp to avoid misalignment --- lib/connector/meshcore_connector.dart | 8 ++++---- lib/helpers/cayenne_lpp.dart | 5 ++--- lib/screens/channels_screen.dart | 2 +- lib/screens/contacts_screen.dart | 3 +-- lib/screens/map_screen.dart | 2 +- lib/widgets/app_bar.dart | 10 ++-------- lib/widgets/snr_indicator.dart | 11 ++++++++--- 7 files changed, 19 insertions(+), 22 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 3e9778a..410adb4 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -3475,7 +3475,7 @@ class MeshCoreConnector extends ChangeNotifier { final isNewContact = !_knownContactKeys.contains(contactKeyHex); if (isNewContact) { - final newContect = Contact( + final newContact = Contact( publicKey: publicKey, name: name, type: type, @@ -3485,8 +3485,8 @@ class MeshCoreConnector extends ChangeNotifier { longitude: longitude, lastSeen: DateTime.fromMillisecondsSinceEpoch(timestamp * 1000), ); - _handleContactAdvert(newContect); - _updateDirectRepeater(newContect, snr, path); + _handleContactAdvert(newContact); + _updateDirectRepeater(newContact, snr, path); return; } @@ -3546,7 +3546,7 @@ class MeshCoreConnector extends ChangeNotifier { if (isTracked.isNotEmpty) { final repeater = isTracked.first; repeater.update(snr); - } else if (isTracked.isEmpty && _directRepeaters.length < 5) { + } else if (_directRepeaters.length < 5) { _directRepeaters.add( DirectRepeater(pubkeyFirstByte: pubkeyFirstByte, snr: snr), ); diff --git a/lib/helpers/cayenne_lpp.dart b/lib/helpers/cayenne_lpp.dart index e6e1f01..07909e6 100644 --- a/lib/helpers/cayenne_lpp.dart +++ b/lib/helpers/cayenne_lpp.dart @@ -258,9 +258,8 @@ class CayenneLpp { break; // Add more types as needed... default: - throw Exception( - 'Unsupported LPP type: ${type.toRadixString(16).padLeft(2, '0')}', - ); + //Stopped parsing to avoid misalignment + return channels.values.toList(); } } diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index 0f9b49b..26062de 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -116,7 +116,7 @@ class _ChannelsScreenState extends State canPop: allowBack, child: Scaffold( appBar: AppBar( - title: AppBarTitle(context.l10n.channels_title, null), + title: AppBarTitle(context.l10n.channels_title), centerTitle: true, automaticallyImplyLeading: false, actions: [ diff --git a/lib/screens/contacts_screen.dart b/lib/screens/contacts_screen.dart index 0f0c9bf..d470107 100644 --- a/lib/screens/contacts_screen.dart +++ b/lib/screens/contacts_screen.dart @@ -241,8 +241,7 @@ class _ContactsScreenState extends State canPop: allowBack, child: Scaffold( appBar: AppBar( - //leading: , - title: AppBarTitle(context.l10n.contacts_title, null), + title: AppBarTitle(context.l10n.contacts_title), automaticallyImplyLeading: false, actions: [ PopupMenuButton( diff --git a/lib/screens/map_screen.dart b/lib/screens/map_screen.dart index 069ec7d..f65bd99 100644 --- a/lib/screens/map_screen.dart +++ b/lib/screens/map_screen.dart @@ -262,7 +262,7 @@ class _MapScreenState extends State { canPop: allowBack, child: Scaffold( appBar: AppBar( - title: AppBarTitle(context.l10n.map_title, null), + title: AppBarTitle(context.l10n.map_title), centerTitle: true, automaticallyImplyLeading: false, actions: [ diff --git a/lib/widgets/app_bar.dart b/lib/widgets/app_bar.dart index 61a7d57..aae0526 100644 --- a/lib/widgets/app_bar.dart +++ b/lib/widgets/app_bar.dart @@ -7,16 +7,9 @@ import 'snr_indicator.dart'; class AppBarTitle extends StatelessWidget { final String title; - final TextStyle? style; final Widget? leading; final Widget? trailing; - const AppBarTitle( - this.title, - this.style, { - this.leading, - this.trailing, - super.key, - }); + const AppBarTitle(this.title, {this.leading, this.trailing, super.key}); @override Widget build(BuildContext context) { @@ -25,6 +18,7 @@ class AppBarTitle extends StatelessWidget { return Row( mainAxisAlignment: MainAxisAlignment.start, children: [ + leading ?? const SizedBox.shrink(), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/widgets/snr_indicator.dart b/lib/widgets/snr_indicator.dart index 1e28212..8a07f02 100644 --- a/lib/widgets/snr_indicator.dart +++ b/lib/widgets/snr_indicator.dart @@ -29,7 +29,10 @@ List getSNRfromSF(int spreadingFactor) { } SNRUi snrUiFromSNR(double? snr, int? spreadingFactor) { - if (snr == null || spreadingFactor == null) { + if (snr == null || + spreadingFactor == null || + spreadingFactor < 7 || + spreadingFactor > 12) { return const SNRUi(Icons.signal_cellular_off, Colors.grey, '—'); } @@ -125,8 +128,10 @@ class _SNRIndicatorState extends State { String _formatLastUpdated(DateTime lastSeen) { final now = DateTime.now(); final diff = now.difference(lastSeen); - - if (diff.isNegative || diff.inMinutes < 1) { + if (diff.isNegative) { + return "0s"; + } + if (diff.inMinutes < 1) { return "${diff.inSeconds}s"; } if (diff.inMinutes < 60) {