58 lines
1.8 KiB
Dart
58 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Einfarbig gefuellte Papierflieger-Silhouette (design/B_paperplane.svg,
|
|
/// dieselben Koordinaten wie DroneMarkerIcon/DroneFollowIcon) in beliebiger
|
|
/// Farbe - fuer kleine Statusanzeigen, in denen die Farbe selbst die
|
|
/// Information traegt (siehe _DroneStatusPill in bottom_stats_bar.dart),
|
|
/// statt der zweifarbigen bzw. fest pinken Varianten der beiden anderen
|
|
/// Verwendungsstellen.
|
|
class PaperPlaneIcon extends StatelessWidget {
|
|
const PaperPlaneIcon({super.key, required this.size, required this.color});
|
|
|
|
final double size;
|
|
final Color color;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: size,
|
|
height: size,
|
|
child: CustomPaint(painter: _PaperPlaneFillPainter(color: color)),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _PaperPlaneFillPainter extends CustomPainter {
|
|
_PaperPlaneFillPainter({required this.color});
|
|
|
|
final Color color;
|
|
|
|
// Gleiche Koordinaten wie DroneMarkerIcon._PaperPlanePainter (viewBox
|
|
// 0 0 200 200, design/B_paperplane.svg): Spitze oben, zwei Fluegel unten,
|
|
// Heckkerbe dazwischen.
|
|
static const _viewBoxSize = 200.0;
|
|
static const _nose = Offset(100, 22);
|
|
static const _rightWing = Offset(164, 172);
|
|
static const _tailNotch = Offset(100, 138);
|
|
static const _leftWing = Offset(36, 172);
|
|
|
|
@override
|
|
void paint(Canvas canvas, Size size) {
|
|
final scale = size.width / _viewBoxSize;
|
|
Offset s(Offset p) => p * scale;
|
|
|
|
final outline = Path()
|
|
..moveTo(s(_nose).dx, s(_nose).dy)
|
|
..lineTo(s(_rightWing).dx, s(_rightWing).dy)
|
|
..lineTo(s(_tailNotch).dx, s(_tailNotch).dy)
|
|
..lineTo(s(_leftWing).dx, s(_leftWing).dy)
|
|
..close();
|
|
|
|
canvas.drawPath(outline, Paint()..color = color);
|
|
}
|
|
|
|
@override
|
|
bool shouldRepaint(covariant _PaperPlaneFillPainter oldDelegate) =>
|
|
oldDelegate.color != color;
|
|
}
|