mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-14 22:55:12 +10:00
Refactor UI code for better readability and consistency
- Improved formatting of ListTile icons and text styles in settings_screen.dart, telemetry_screen.dart, usb_screen.dart, gif_picker.dart, path_editor_sheet.dart, repeater_login_dialog.dart, and room_login_dialog.dart for better readability. - Consolidated TextStyle definitions into single lines where applicable. - Updated notification_service.dart to enhance readability of notification ID assignment. - Simplified function signatures in routing_sheet.dart for clarity. - Cleaned up test assertions in usb_flow_test.dart for conciseness. - Removed unused translations in untranslated.json to streamline localization files.
This commit is contained in:
@@ -180,7 +180,10 @@ class _GifPickerState extends State<GifPicker> {
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
context.l10n.gifPicker_poweredBy,
|
||||
style: TextStyle(fontSize: 11, color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -197,11 +200,18 @@ class _GifPickerState extends State<GifPicker> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.error_outline, size: 64, color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
Icon(
|
||||
Icons.error_outline,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
_error!,
|
||||
style: TextStyle(fontSize: 16, color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton.icon(
|
||||
@@ -219,11 +229,18 @@ class _GifPickerState extends State<GifPicker> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.search_off, size: 64, color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
Icon(
|
||||
Icons.search_off,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
context.l10n.gifPicker_noGifsFound,
|
||||
style: TextStyle(fontSize: 16, color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -119,7 +119,9 @@ class _PathEditorSheetState extends State<PathEditorSheet> {
|
||||
_hexError = null;
|
||||
_hops
|
||||
..clear()
|
||||
..addAll(tokens.map((t) => _Hop(_nextHopId++, int.parse(t, radix: 16))));
|
||||
..addAll(
|
||||
tokens.map((t) => _Hop(_nextHopId++, int.parse(t, radix: 16))),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -287,10 +289,7 @@ class _PathEditorSheetState extends State<PathEditorSheet> {
|
||||
),
|
||||
const Divider(),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.pathEditor_addHops,
|
||||
style: theme.textTheme.titleSmall,
|
||||
),
|
||||
Text(l10n.pathEditor_addHops, style: theme.textTheme.titleSmall),
|
||||
const SizedBox(height: 8),
|
||||
TextField(
|
||||
onChanged: (value) => setState(() => _search = value),
|
||||
|
||||
@@ -466,7 +466,10 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
repeater.pathLabel(context.l10n),
|
||||
style: TextStyle(fontSize: 11, color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
|
||||
@@ -395,7 +395,10 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
repeater.pathLabel(context.l10n),
|
||||
style: TextStyle(fontSize: 11, color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
|
||||
@@ -150,10 +150,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _forgetPath(
|
||||
MeshCoreConnector connector,
|
||||
Contact contact,
|
||||
) async {
|
||||
Future<void> _forgetPath(MeshCoreConnector connector, Contact contact) async {
|
||||
await connector.clearContactPath(contact);
|
||||
if (!mounted) return;
|
||||
setState(() => _syncStatus = context.l10n.chat_pathCleared);
|
||||
@@ -235,7 +232,8 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
case _RoutingMode.auto:
|
||||
if (contact.pathLength < 0) return l10n.routing_noPathYet;
|
||||
if (contact.pathLength == 0) return l10n.routing_directNoHops;
|
||||
if (contact.path.isEmpty) return l10n.chat_hopsCount(contact.pathLength);
|
||||
if (contact.path.isEmpty)
|
||||
return l10n.chat_hopsCount(contact.pathLength);
|
||||
return PathHelper.resolvePathNames(contact.path, connector.allContacts);
|
||||
}
|
||||
}
|
||||
@@ -325,7 +323,8 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
int failureCount,
|
||||
int lastTripTimeMs,
|
||||
DateTime? lastUsed,
|
||||
})? floodStats,
|
||||
})?
|
||||
floodStats,
|
||||
) {
|
||||
final l10n = context.l10n;
|
||||
final theme = Theme.of(context);
|
||||
@@ -347,7 +346,10 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
color: scheme.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(l10n.routing_currentRoute, style: theme.textTheme.titleSmall),
|
||||
Text(
|
||||
l10n.routing_currentRoute,
|
||||
style: theme.textTheme.titleSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -418,7 +420,8 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
int failureCount,
|
||||
int lastTripTimeMs,
|
||||
DateTime? lastUsed,
|
||||
}) stats,
|
||||
})
|
||||
stats,
|
||||
) {
|
||||
final l10n = context.l10n;
|
||||
final parts = <String>[
|
||||
@@ -441,7 +444,8 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
int failureCount,
|
||||
int lastTripTimeMs,
|
||||
DateTime? lastUsed,
|
||||
}) stats,
|
||||
})
|
||||
stats,
|
||||
) {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
@@ -487,7 +491,10 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
final scheme = theme.colorScheme;
|
||||
|
||||
final (Color bg, Color fg) = switch (quality) {
|
||||
_PathQuality.strong => (scheme.primaryContainer, scheme.onPrimaryContainer),
|
||||
_PathQuality.strong => (
|
||||
scheme.primaryContainer,
|
||||
scheme.onPrimaryContainer,
|
||||
),
|
||||
_PathQuality.good => (
|
||||
scheme.secondaryContainer,
|
||||
scheme.onSecondaryContainer,
|
||||
@@ -504,7 +511,8 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
};
|
||||
|
||||
final hasBytes = record.pathBytes.isNotEmpty;
|
||||
final inUse = hasBytes &&
|
||||
final inUse =
|
||||
hasBytes &&
|
||||
((mode == _RoutingMode.manual &&
|
||||
listEquals(record.pathBytes, contact.pathOverrideBytes)) ||
|
||||
(mode == _RoutingMode.auto &&
|
||||
@@ -596,19 +604,24 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
|
||||
|
||||
final rankedRepeaters = List.of(connector.directRepeaters)
|
||||
..sort((a, b) => b.ranking.compareTo(a.ranking));
|
||||
final entries = pathService
|
||||
.getRecentPaths(contact.publicKeyHex)
|
||||
.map((r) => (quality: _qualityOf(r, rankedRepeaters), record: r))
|
||||
.toList()
|
||||
..sort((a, b) {
|
||||
final byQuality = a.quality.index.compareTo(b.quality.index);
|
||||
if (byQuality != 0) return byQuality;
|
||||
final aTime =
|
||||
a.record.timestamp ?? DateTime.fromMillisecondsSinceEpoch(0);
|
||||
final bTime =
|
||||
b.record.timestamp ?? DateTime.fromMillisecondsSinceEpoch(0);
|
||||
return bTime.compareTo(aTime);
|
||||
});
|
||||
final entries =
|
||||
pathService
|
||||
.getRecentPaths(contact.publicKeyHex)
|
||||
.map(
|
||||
(r) => (quality: _qualityOf(r, rankedRepeaters), record: r),
|
||||
)
|
||||
.toList()
|
||||
..sort((a, b) {
|
||||
final byQuality = a.quality.index.compareTo(b.quality.index);
|
||||
if (byQuality != 0) return byQuality;
|
||||
final aTime =
|
||||
a.record.timestamp ??
|
||||
DateTime.fromMillisecondsSinceEpoch(0);
|
||||
final bTime =
|
||||
b.record.timestamp ??
|
||||
DateTime.fromMillisecondsSinceEpoch(0);
|
||||
return bTime.compareTo(aTime);
|
||||
});
|
||||
|
||||
return ListView(
|
||||
controller: widget.scrollController,
|
||||
|
||||
Reference in New Issue
Block a user