feat: make sensor and tag lists refreshable

This commit is contained in:
2026-05-19 20:13:31 +02:00
parent 48264fb122
commit 845276bac7
2 changed files with 56 additions and 21 deletions
+17 -2
View File
@@ -40,13 +40,27 @@ class SensorListScreen extends ConsumerWidget {
error: (e, _) => Center(child: Text(e.toString())), error: (e, _) => Center(child: Text(e.toString())),
data: (list) { data: (list) {
if (list.isEmpty) { if (list.isEmpty) {
return const Center(child: Text('No sensors enrolled yet')); return RefreshIndicator(
onRefresh: () => ref.refresh(sensorsProvider.future),
child: const CustomScrollView(
physics: AlwaysScrollableScrollPhysics(),
slivers: [
SliverFillRemaining(
child: Center(
child: Text('No sensors enrolled yet')),
),
],
),
);
} }
final unplaced = final unplaced =
list.where((s) => !s.isPlaced).toList(); list.where((s) => !s.isPlaced).toList();
final placed = final placed =
list.where((s) => s.isPlaced).toList(); list.where((s) => s.isPlaced).toList();
return ListView( return RefreshIndicator(
onRefresh: () => ref.refresh(sensorsProvider.future),
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: [ children: [
if (unplaced.isNotEmpty) ...[ if (unplaced.isNotEmpty) ...[
_SectionHeader( _SectionHeader(
@@ -59,6 +73,7 @@ class SensorListScreen extends ConsumerWidget {
...placed.map((s) => _SensorTile(sensor: s)), ...placed.map((s) => _SensorTile(sensor: s)),
], ],
], ],
),
); );
}, },
), ),
+22 -2
View File
@@ -29,15 +29,35 @@ class TagListScreen extends ConsumerWidget {
error: (e, _) => Center(child: Text(e.toString())), error: (e, _) => Center(child: Text(e.toString())),
data: (list) { data: (list) {
if (list.isEmpty) { if (list.isEmpty) {
return const Center(child: Text('No tags enrolled yet')); return RefreshIndicator(
onRefresh: () {
ref.invalidate(roomOccupancyProvider);
return ref.refresh(tagsProvider.future);
},
child: const CustomScrollView(
physics: AlwaysScrollableScrollPhysics(),
slivers: [
SliverFillRemaining(
child: Center(child: Text('No tags enrolled yet')),
),
],
),
);
} }
return ListView( return RefreshIndicator(
onRefresh: () {
ref.invalidate(roomOccupancyProvider);
return ref.refresh(tagsProvider.future);
},
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: list children: list
.map((t) => _TagTile( .map((t) => _TagTile(
tag: t, tag: t,
roomId: tagRoomMap[t.tagId], roomId: tagRoomMap[t.tagId],
)) ))
.toList(), .toList(),
),
); );
}, },
), ),