Files
dmc/app/lib/ui/widgets/home_point_icon.dart
Constantin Leue 6b7977eca1 Show distance to home as a fourth field in the fly-mode details pill
Adds computeDistanceToHomeM() (mission_stats.dart) alongside the
existing rubber-band-target helper, wired through MissionFooterBar ->
BottomStatsBar the same way flyMissionStatus already is. Only appears
once a home point is known, as the last field after waypoint/distance/
duration.

Generalized HomePointIcon to take an optional strokeColor: the map
marker keeps its dark-fill-plus-white-outline look, while the details
pill uses a plain white fill (strokeColor: null) to match the existing
monochrome flag/ruler/clock icons instead of looking like a dropped-in
map pin.
2026-08-09 21:49:03 +02:00

84 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
/// Homepoint-Pentagon-Haus-Form aus design/homepoint-pentagon.svg - nativ
/// als [CustomPainter] statt als SVG-Asset nachgebaut (Format bewusst
/// geaendert, dasselbe Muster wie DroneMarkerIcon/PaperPlaneIcon: ein
/// einzelnes Polygon lohnt keine zusaetzliche SVG-Renderer-Abhaengigkeit).
///
/// Zwei Anwendungsfaelle mit unterschiedlichem Stil teilen sich dieselbe
/// Geometrie: als Kartenmarker im Fly-Modus (Doku: "den auf der Drohne
/// gelockten Homepoint abfragen ... benutze dieses Icon") mit dunkler
/// Fuellung + weissem Rand wie die anderen Kartenmarker, und als schlichtes
/// einfarbiges Inline-Icon in der Details-Pille (Doku: "gleiche Pentagon
/// Form, aber im Style von den anderen icons") ohne Rand, passend zu den
/// dortigen Material-Icons (flag/straighten/access_time). [strokeColor]
/// null waehlt Letzteres.
class HomePointIcon extends StatelessWidget {
const HomePointIcon({
super.key,
this.size = 32,
this.color = const Color(0xFF161616),
this.strokeColor = Colors.white,
});
final double size;
final Color color;
final Color? strokeColor;
@override
Widget build(BuildContext context) {
return CustomPaint(
size: Size.square(size),
painter: _HomePointPainter(fill: color, stroke: strokeColor),
);
}
}
class _HomePointPainter extends CustomPainter {
const _HomePointPainter({required this.fill, required this.stroke});
final Color fill;
final Color? stroke;
// 1:1 aus design/homepoint-pentagon.svg uebernommene Koordinaten (viewBox
// 0 0 72 72): Haus-Silhouette (Fuenfeck) mit spitzem Dach.
static const _viewBoxSize = 72.0;
static const _points = [
Offset(20, 52),
Offset(20, 34),
Offset(36, 16),
Offset(52, 34),
Offset(52, 52),
];
static const _strokeWidth = 3.0;
@override
void paint(Canvas canvas, Size size) {
final scale = size.width / _viewBoxSize;
Offset s(Offset p) => p * scale;
final path = Path()..moveTo(s(_points.first).dx, s(_points.first).dy);
for (final point in _points.skip(1)) {
path.lineTo(s(point).dx, s(point).dy);
}
path.close();
canvas.drawPath(path, Paint()..color = fill);
final strokeColor = stroke;
if (strokeColor != null) {
canvas.drawPath(
path,
Paint()
..color = strokeColor
..style = PaintingStyle.stroke
..strokeWidth = _strokeWidth * scale
..strokeJoin = StrokeJoin.round,
);
}
}
@override
bool shouldRepaint(covariant _HomePointPainter oldDelegate) =>
oldDelegate.fill != fill || oldDelegate.stroke != stroke;
}