Refactor color opacity handling in map tab and remove heading text from compass painter

This commit is contained in:
Janez T
2025-10-13 23:04:11 +02:00
parent e153218b01
commit dd859d3458

View File

@@ -570,7 +570,7 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
rotate: false, // Don't rotate with map rotate: false, // Don't rotate with map
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.3), color: Colors.blue.withValues(alpha: 0.3),
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
child: Container( child: Container(
@@ -794,7 +794,7 @@ class _LegendItem extends StatelessWidget {
Container( Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1), padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color.withOpacity(0.2), color: color.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
child: Text( child: Text(
@@ -849,7 +849,7 @@ class _CompassWidget extends StatelessWidget {
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1), padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.black.withOpacity(0.7), color: Colors.black.withValues(alpha: 0.7),
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
), ),
child: Text( child: Text(
@@ -873,7 +873,7 @@ class _CompassRosePainter extends CustomPainter {
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
final paint = Paint() final paint = Paint()
..color = Colors.grey.withOpacity(0.3) ..color = Colors.grey.withValues(alpha: 0.3)
..style = PaintingStyle.stroke ..style = PaintingStyle.stroke
..strokeWidth = 1; ..strokeWidth = 1;
@@ -1254,7 +1254,7 @@ class _LargeCompassPainter extends CustomPainter {
// Draw outer circle // Draw outer circle
final circlePaint = Paint() final circlePaint = Paint()
..color = Colors.grey.withOpacity(0.2) ..color = Colors.grey.withValues(alpha: 0.2)
..style = PaintingStyle.stroke ..style = PaintingStyle.stroke
..strokeWidth = 2; ..strokeWidth = 2;
canvas.drawCircle(center, radius, circlePaint); canvas.drawCircle(center, radius, circlePaint);
@@ -1353,24 +1353,6 @@ class _LargeCompassPainter extends CustomPainter {
..close(); ..close();
canvas.drawPath(path, indicatorPaint); canvas.drawPath(path, indicatorPaint);
// Draw heading text
textPainter.text = TextSpan(
text: hasHeading ? '${heading.round()}°' : '--',
style: const TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.bold,
),
);
textPainter.layout();
textPainter.paint(
canvas,
Offset(
center.dx - textPainter.width / 2,
center.dy + 20,
),
);
} }
double _calculateBearing( double _calculateBearing(