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
This commit is contained in:
Winston Lowe 2026-02-15 19:38:34 -08:00
parent 71152bd3eb
commit 52a578777d
7 changed files with 19 additions and 22 deletions

View file

@ -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),
);

View file

@ -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();
}
}

View file

@ -116,7 +116,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
canPop: allowBack,
child: Scaffold(
appBar: AppBar(
title: AppBarTitle(context.l10n.channels_title, null),
title: AppBarTitle(context.l10n.channels_title),
centerTitle: true,
automaticallyImplyLeading: false,
actions: [

View file

@ -241,8 +241,7 @@ class _ContactsScreenState extends State<ContactsScreen>
canPop: allowBack,
child: Scaffold(
appBar: AppBar(
//leading: ,
title: AppBarTitle(context.l10n.contacts_title, null),
title: AppBarTitle(context.l10n.contacts_title),
automaticallyImplyLeading: false,
actions: [
PopupMenuButton(

View file

@ -262,7 +262,7 @@ class _MapScreenState extends State<MapScreen> {
canPop: allowBack,
child: Scaffold(
appBar: AppBar(
title: AppBarTitle(context.l10n.map_title, null),
title: AppBarTitle(context.l10n.map_title),
centerTitle: true,
automaticallyImplyLeading: false,
actions: [

View file

@ -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: [

View file

@ -29,7 +29,10 @@ List<double> 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<SNRIndicator> {
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) {