Simplify and modularize device, notification, and settings screens

Extract inline widget closures into named StatelessWidgets (_DeviceCard,
_DeviceFilterSheet, _NotificationCard), replace magic ints and hardcoded
repeated widgets with enum-driven loops, fix the InputDecorator/DropdownButton
hack in device_actions, merge symmetric _markAsRead/_markAsNew into _setRead,
and remove dead _isLoading/_isSaving state in settings where operations are
synchronous.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-05-28 11:14:29 -04:00
co-authored by Claude Sonnet 4.6
parent e1287e5a0f
commit e6ec771f3b
6 changed files with 535 additions and 586 deletions
+18 -25
View File
@@ -124,10 +124,7 @@ class _SectionHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text(
title,
style: Theme.of(context).textTheme.titleMedium,
);
return Text(title, style: Theme.of(context).textTheme.titleMedium);
}
}
@@ -141,7 +138,11 @@ class _DeviceHeader extends StatelessWidget {
final theme = Theme.of(context);
return Row(
children: [
Icon(device.deviceType.icon, size: 48, color: theme.colorScheme.onSurface),
Icon(
device.deviceType.icon,
size: 48,
color: theme.colorScheme.onSurface,
),
const SizedBox(width: 16),
Expanded(
child: Column(
@@ -172,30 +173,22 @@ class _DeviceInfoCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final formatter = FriendlyDateFormatter();
final rows = <(String, String)>[
('MAC Address', device.macAddress),
('IP Address', device.ipv4Address),
('Vendor', device.vendor.isEmpty ? '' : device.vendor),
('Last Seen', formatter.format(device.lastSeen)),
('Device Type', device.deviceType.label),
('Owner', device.owner.isEmpty ? '' : device.owner),
];
return Card(
child: Column(
children: [
_InfoRow(label: 'MAC Address', value: device.macAddress),
const Divider(height: 1),
_InfoRow(label: 'IP Address', value: device.ipv4Address),
const Divider(height: 1),
_InfoRow(
label: 'Vendor',
value: device.vendor.isEmpty ? '' : device.vendor,
),
const Divider(height: 1),
_InfoRow(
label: 'Last Seen',
value: formatter.format(device.lastSeen),
),
const Divider(height: 1),
_InfoRow(label: 'Device Type', value: device.deviceType.label),
const Divider(height: 1),
_InfoRow(
label: 'Owner',
value: device.owner.isEmpty ? '' : device.owner,
),
for (var i = 0; i < rows.length; i++) ...[
_InfoRow(label: rows[i].$1, value: rows[i].$2),
if (i < rows.length - 1) const Divider(height: 1),
],
],
),
);