60 lines
1.7 KiB
Dart
60 lines
1.7 KiB
Dart
import 'dart:math' as math;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// Stilisiertes Bergkuppe-Icon mit zwei Zacken, fuer den
|
|
/// Hoehenprofil-Toggle-Knopf in der Fusszeile (siehe
|
|
/// [MountainPeakToggleButton] in mission_footer_bar.dart). Um 180 Grad
|
|
/// gedreht zeigen die Zacken nach unten - das signalisiert "einklappen",
|
|
/// waehrend die aufrechte Ausrichtung "ausklappen" signalisiert.
|
|
class MountainPeakIcon extends StatelessWidget {
|
|
const MountainPeakIcon({
|
|
super.key,
|
|
this.size = 16,
|
|
this.color = Colors.white,
|
|
this.upsideDown = false,
|
|
});
|
|
|
|
final double size;
|
|
final Color color;
|
|
final bool upsideDown;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Transform.rotate(
|
|
angle: upsideDown ? math.pi : 0,
|
|
child: CustomPaint(
|
|
size: Size.square(size),
|
|
painter: _MountainPeakPainter(color: color),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _MountainPeakPainter extends CustomPainter {
|
|
const _MountainPeakPainter({required this.color});
|
|
|
|
final Color color;
|
|
|
|
@override
|
|
void paint(Canvas canvas, Size size) {
|
|
final w = size.width;
|
|
final h = size.height;
|
|
// Zwei Zacken: hoher Hauptgipfel links, niedrigerer Nebengipfel rechts,
|
|
// mit einer Senke dazwischen - Silhouette bleibt in beiden Drehlagen
|
|
// (aufrecht/kopfueber) als Bergkuppe erkennbar.
|
|
final path = Path()
|
|
..moveTo(0, h)
|
|
..lineTo(w * 0.36, h * 0.1)
|
|
..lineTo(w * 0.55, h * 0.45)
|
|
..lineTo(w * 0.74, h * 0.24)
|
|
..lineTo(w, h)
|
|
..close();
|
|
canvas.drawPath(path, Paint()..color = color);
|
|
}
|
|
|
|
@override
|
|
bool shouldRepaint(covariant _MountainPeakPainter oldDelegate) =>
|
|
oldDelegate.color != color;
|
|
}
|