feat: Implement auto-zoom functionality for preselected contacts and SAR markers in DetailedCompassDialog

This commit is contained in:
Janez T
2025-10-15 10:47:33 +02:00
parent 3c3db22eb0
commit d69a83fded
2 changed files with 19 additions and 5 deletions

View File

@@ -299,11 +299,11 @@ class _LargeCompassPainter extends CustomPainter {
..style = PaintingStyle.fill;
canvas.drawCircle(Offset(dotX, dotY), dotSize, dotPaint);
// Draw white border
// Draw darker shade border (same color family)
final borderPaint = Paint()
..color = Colors.white
..color = Colors.blue.shade800
..style = PaintingStyle.stroke
..strokeWidth = 2;
..strokeWidth = 2.5;
canvas.drawCircle(Offset(dotX, dotY), dotSize, borderPaint);
// Draw distance label near the contact (only if not too crowded)
@@ -388,21 +388,27 @@ class _LargeCompassPainter extends CustomPainter {
// Determine color based on SAR marker type
Color markerColor;
Color borderColor;
switch (marker.type) {
case SarMarkerType.foundPerson:
markerColor = Colors.green;
borderColor = Colors.green.shade900;
break;
case SarMarkerType.fire:
markerColor = Colors.red;
borderColor = Colors.red.shade900;
break;
case SarMarkerType.stagingArea:
markerColor = Colors.orange;
borderColor = Colors.orange.shade900;
break;
case SarMarkerType.object:
markerColor = Colors.purple;
borderColor = Colors.purple.shade900;
break;
case SarMarkerType.unknown:
markerColor = Colors.grey;
borderColor = Colors.grey.shade900;
break;
}
@@ -424,9 +430,9 @@ class _LargeCompassPainter extends CustomPainter {
..style = PaintingStyle.fill;
canvas.drawCircle(Offset(dotX, dotY), dotSize, dotPaint);
// Draw white border
// Draw darker shade border (same color family)
final borderPaint = Paint()
..color = Colors.white
..color = borderColor
..style = PaintingStyle.stroke
..strokeWidth = 2.5;
canvas.drawCircle(Offset(dotX, dotY), dotSize, borderPaint);

View File

@@ -63,6 +63,14 @@ class _DetailedCompassDialogState extends State<DetailedCompassDialog> {
_selectedContact = widget.preSelectedContact;
_selectedSarMarker = widget.preSelectedSarMarker;
// Auto-zoom if item is preselected
if (_selectedContact != null || _selectedSarMarker != null) {
// Use post-frame callback to ensure position is set
WidgetsBinding.instance.addPostFrameCallback((_) {
_autoZoomForSelection();
});
}
// Subscribe to compass updates
final compassStream = FlutterCompass.events;
if (compassStream != null) {