feat: render particle clouds for selected tags
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../domain/models/floor_plan_mode.dart';
|
||||
import '../../domain/models/sensor.dart';
|
||||
import '../../domain/models/tag.dart';
|
||||
import '../../providers.dart';
|
||||
import '../ble_provision/ble_provision_sheet.dart';
|
||||
import '../sensors/sensor_detail_sheet.dart';
|
||||
@@ -87,6 +88,7 @@ class _FloorPlanScreenState extends ConsumerState<FloorPlanScreen> {
|
||||
final roomsAsync = ref.watch(roomsProvider);
|
||||
final sensorsAsync = ref.watch(sensorsProvider);
|
||||
final placingSensor = ref.watch(sensorPlacementProvider);
|
||||
final trackedTag = ref.watch(trackedTagProvider);
|
||||
|
||||
ref.listen(roomsProvider, (_, next) {
|
||||
next.whenData((r) => _editorKey.currentState?.loadFloorPlan(r));
|
||||
@@ -112,8 +114,14 @@ class _FloorPlanScreenState extends ConsumerState<FloorPlanScreen> {
|
||||
ref.listen(tagPositionsProvider, (_, next) {
|
||||
next.whenData((t) => _editorKey.currentState?.updateTags(t));
|
||||
});
|
||||
ref.listen(particleCloudProvider, (_, next) {
|
||||
next.whenData((p) => _editorKey.currentState?.updateParticleCloud(p));
|
||||
if (trackedTag != null) {
|
||||
ref.listen(particleSnapshotProvider(trackedTag.tagId), (_, next) {
|
||||
next.whenData(
|
||||
(snap) => _editorKey.currentState?.updateParticleCloud(snap.particles));
|
||||
});
|
||||
}
|
||||
ref.listen(trackedTagProvider, (prev, next) {
|
||||
if (next == null) _editorKey.currentState?.updateParticleCloud([]);
|
||||
});
|
||||
ref.listen(sensorPlacementProvider, (prev, next) => _applyPlacementState());
|
||||
|
||||
@@ -244,6 +252,19 @@ class _FloorPlanScreenState extends ConsumerState<FloorPlanScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
// Tracking card overlay
|
||||
if (trackedTag != null && placingSensor == null)
|
||||
Positioned(
|
||||
top: 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
child: _TrackingCard(
|
||||
tag: trackedTag,
|
||||
onStop: () {
|
||||
ref.read(trackedTagProvider.notifier).state = null;
|
||||
},
|
||||
),
|
||||
),
|
||||
// Placement mode overlay
|
||||
if (placingSensor != null) ...[
|
||||
const Center(child: _PlacementDot()),
|
||||
@@ -390,6 +411,42 @@ class _PlacementDot extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _TrackingCard extends StatelessWidget {
|
||||
const _TrackingCard({required this.tag, required this.onStop});
|
||||
|
||||
final Tag tag;
|
||||
final VoidCallback onStop;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Card(
|
||||
elevation: 4,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.radar),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(tag.name, style: theme.textTheme.labelLarge),
|
||||
Text('Tracking particle cloud',
|
||||
style: theme.textTheme.bodySmall),
|
||||
],
|
||||
),
|
||||
),
|
||||
TextButton(onPressed: onStop, child: const Text('Stop')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PlacementCard extends StatelessWidget {
|
||||
const _PlacementCard({
|
||||
required this.sensor,
|
||||
|
||||
Reference in New Issue
Block a user