Add mDNS scanner status to Status and Home screens

Add an mDNS Scanner status card to the Status screen mirroring the ARP
card, and replace the ARP card on the Home screen with a combined Status
card that summarizes both scanners in one line each. Extract the shared
duration formatting helper into utils/duration_formatter.dart.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-05-29 10:19:50 -04:00
co-authored by Claude Sonnet 4.6
parent c6fdf9e181
commit 75f597bfe4
9 changed files with 372 additions and 27 deletions
+7 -20
View File
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../model/arp_scanner_status.dart';
import '../utils/duration_formatter.dart';
import '../utils/oott_api.dart';
class ArpScannerCard extends StatefulWidget {
@@ -25,16 +26,10 @@ class _ArpScannerCardState extends State<ArpScannerCard> {
void initState() {
super.initState();
_load();
_refreshTimer = Timer.periodic(
const Duration(seconds: 5),
(_) => _load(),
);
_tickTimer = Timer.periodic(
const Duration(seconds: 1),
(_) {
if (mounted) setState(() {});
},
);
_refreshTimer = Timer.periodic(const Duration(seconds: 5), (_) => _load());
_tickTimer = Timer.periodic(const Duration(seconds: 1), (_) {
if (mounted) setState(() {});
});
}
@override
@@ -130,7 +125,7 @@ class _ArpScannerCardState extends State<ArpScannerCard> {
if (_status!.isRunning) {
final sub = _status!.runningForSeconds != null
? 'Running for ${_formatSeconds(_status!.runningForSeconds! + elapsed)}'
? 'Running for ${formatSeconds(_status!.runningForSeconds! + elapsed)}'
: null;
return (Colors.green, 'Running', sub);
}
@@ -142,17 +137,9 @@ class _ArpScannerCardState extends State<ArpScannerCard> {
return (
Colors.amber,
'Waiting for next run',
'Next run in ${_formatSeconds(remaining)}',
'Next run in ${formatSeconds(remaining)}',
);
}
return (Colors.grey, 'Not yet started', null);
}
}
String _formatSeconds(double seconds) {
final total = seconds.round().clamp(0, double.maxFinite.toInt());
if (total < 60) return '${total}s';
final m = total ~/ 60;
final s = total % 60;
return '${m}m ${s}s';
}