Add devices screen to the Flutter frontend

Lists devices with New/Registered/All filtering, pull-to-refresh,
device-type icons, and visual differentiation between new and registered
devices. Introduces a reusable StatusBadge widget for colour-coded labels.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-05-27 14:58:11 -04:00
co-authored by Claude Sonnet 4.6
parent 6d72ba7202
commit d0b9855bad
5 changed files with 280 additions and 1 deletions
+16
View File
@@ -4,6 +4,7 @@ import 'package:dio/dio.dart';
import 'package:encrypter/encrypter/xor.dart';
import 'package:flutter/foundation.dart';
import 'package:frontend/utils/pref_utils.dart';
import '../model/device.dart';
import '../model/notification.dart';
class BackendAPI {
@@ -82,6 +83,21 @@ class BackendAPI {
await _dio.post('/notifications/mark_all_as_old');
}
Future<List<Device>> listDevices({bool? isRegistered}) async {
debugPrint('About to call /devices');
final params = <String, dynamic>{};
if (isRegistered != null) params['is_registered'] = isRegistered;
final response = await _dio.get('/devices', queryParameters: params);
debugPrint('Received: ${response.data}');
return (response.data as List)
.map((item) => Device.fromJson(item as Map<String, dynamic>))
.toList();
}
Future<List<Notification>> listNotifications(bool? isNew, int offset) async {
debugPrint('About to call /notifications');