mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-27 14:06:38 +10:00
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:
@@ -3475,7 +3475,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
final isNewContact = !_knownContactKeys.contains(contactKeyHex);
|
final isNewContact = !_knownContactKeys.contains(contactKeyHex);
|
||||||
|
|
||||||
if (isNewContact) {
|
if (isNewContact) {
|
||||||
final newContect = Contact(
|
final newContact = Contact(
|
||||||
publicKey: publicKey,
|
publicKey: publicKey,
|
||||||
name: name,
|
name: name,
|
||||||
type: type,
|
type: type,
|
||||||
@@ -3485,8 +3485,8 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
longitude: longitude,
|
longitude: longitude,
|
||||||
lastSeen: DateTime.fromMillisecondsSinceEpoch(timestamp * 1000),
|
lastSeen: DateTime.fromMillisecondsSinceEpoch(timestamp * 1000),
|
||||||
);
|
);
|
||||||
_handleContactAdvert(newContect);
|
_handleContactAdvert(newContact);
|
||||||
_updateDirectRepeater(newContect, snr, path);
|
_updateDirectRepeater(newContact, snr, path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3546,7 +3546,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
if (isTracked.isNotEmpty) {
|
if (isTracked.isNotEmpty) {
|
||||||
final repeater = isTracked.first;
|
final repeater = isTracked.first;
|
||||||
repeater.update(snr);
|
repeater.update(snr);
|
||||||
} else if (isTracked.isEmpty && _directRepeaters.length < 5) {
|
} else if (_directRepeaters.length < 5) {
|
||||||
_directRepeaters.add(
|
_directRepeaters.add(
|
||||||
DirectRepeater(pubkeyFirstByte: pubkeyFirstByte, snr: snr),
|
DirectRepeater(pubkeyFirstByte: pubkeyFirstByte, snr: snr),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -258,9 +258,8 @@ class CayenneLpp {
|
|||||||
break;
|
break;
|
||||||
// Add more types as needed...
|
// Add more types as needed...
|
||||||
default:
|
default:
|
||||||
throw Exception(
|
//Stopped parsing to avoid misalignment
|
||||||
'Unsupported LPP type: ${type.toRadixString(16).padLeft(2, '0')}',
|
return channels.values.toList();
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||||||
canPop: allowBack,
|
canPop: allowBack,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: AppBarTitle(context.l10n.channels_title, null),
|
title: AppBarTitle(context.l10n.channels_title),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
actions: [
|
actions: [
|
||||||
|
|||||||
@@ -241,8 +241,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||||||
canPop: allowBack,
|
canPop: allowBack,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
//leading: ,
|
title: AppBarTitle(context.l10n.contacts_title),
|
||||||
title: AppBarTitle(context.l10n.contacts_title, null),
|
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
actions: [
|
actions: [
|
||||||
PopupMenuButton(
|
PopupMenuButton(
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ class _MapScreenState extends State<MapScreen> {
|
|||||||
canPop: allowBack,
|
canPop: allowBack,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: AppBarTitle(context.l10n.map_title, null),
|
title: AppBarTitle(context.l10n.map_title),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
actions: [
|
actions: [
|
||||||
|
|||||||
@@ -7,16 +7,9 @@ import 'snr_indicator.dart';
|
|||||||
|
|
||||||
class AppBarTitle extends StatelessWidget {
|
class AppBarTitle extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final TextStyle? style;
|
|
||||||
final Widget? leading;
|
final Widget? leading;
|
||||||
final Widget? trailing;
|
final Widget? trailing;
|
||||||
const AppBarTitle(
|
const AppBarTitle(this.title, {this.leading, this.trailing, super.key});
|
||||||
this.title,
|
|
||||||
this.style, {
|
|
||||||
this.leading,
|
|
||||||
this.trailing,
|
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -25,6 +18,7 @@ class AppBarTitle extends StatelessWidget {
|
|||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
leading ?? const SizedBox.shrink(),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ List<double> getSNRfromSF(int spreadingFactor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SNRUi snrUiFromSNR(double? snr, 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, '—');
|
return const SNRUi(Icons.signal_cellular_off, Colors.grey, '—');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +128,10 @@ class _SNRIndicatorState extends State<SNRIndicator> {
|
|||||||
String _formatLastUpdated(DateTime lastSeen) {
|
String _formatLastUpdated(DateTime lastSeen) {
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
final diff = now.difference(lastSeen);
|
final diff = now.difference(lastSeen);
|
||||||
|
if (diff.isNegative) {
|
||||||
if (diff.isNegative || diff.inMinutes < 1) {
|
return "0s";
|
||||||
|
}
|
||||||
|
if (diff.inMinutes < 1) {
|
||||||
return "${diff.inSeconds}s";
|
return "${diff.inSeconds}s";
|
||||||
}
|
}
|
||||||
if (diff.inMinutes < 60) {
|
if (diff.inMinutes < 60) {
|
||||||
|
|||||||
Reference in New Issue
Block a user