feat: make sensor and tag lists refreshable
This commit is contained in:
@@ -40,25 +40,40 @@ 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(
|
||||||
children: [
|
onRefresh: () => ref.refresh(sensorsProvider.future),
|
||||||
if (unplaced.isNotEmpty) ...[
|
child: ListView(
|
||||||
_SectionHeader(
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
label: 'Unplaced', count: unplaced.length),
|
children: [
|
||||||
...unplaced.map((s) => _SensorTile(sensor: s)),
|
if (unplaced.isNotEmpty) ...[
|
||||||
|
_SectionHeader(
|
||||||
|
label: 'Unplaced', count: unplaced.length),
|
||||||
|
...unplaced.map((s) => _SensorTile(sensor: s)),
|
||||||
|
],
|
||||||
|
if (placed.isNotEmpty) ...[
|
||||||
|
_SectionHeader(
|
||||||
|
label: 'Placed', count: placed.length),
|
||||||
|
...placed.map((s) => _SensorTile(sensor: s)),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
if (placed.isNotEmpty) ...[
|
),
|
||||||
_SectionHeader(
|
|
||||||
label: 'Placed', count: placed.length),
|
|
||||||
...placed.map((s) => _SensorTile(sensor: s)),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -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(
|
||||||
children: list
|
onRefresh: () {
|
||||||
.map((t) => _TagTile(
|
ref.invalidate(roomOccupancyProvider);
|
||||||
tag: t,
|
return ref.refresh(tagsProvider.future);
|
||||||
roomId: tagRoomMap[t.tagId],
|
},
|
||||||
))
|
child: ListView(
|
||||||
.toList(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
children: list
|
||||||
|
.map((t) => _TagTile(
|
||||||
|
tag: t,
|
||||||
|
roomId: tagRoomMap[t.tagId],
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user