76 lines
1.7 KiB
Dart
76 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// A simple, stylized cloud used in the update check splash screen.
|
|
///
|
|
/// The cloud is drawn using a few overlapping circles (ovals) and a
|
|
/// horizontal base, giving a soft, layered cloud look.
|
|
class CloudOverlay extends StatelessWidget {
|
|
final Color color;
|
|
final double width;
|
|
final double height;
|
|
|
|
const CloudOverlay({
|
|
super.key,
|
|
required this.color,
|
|
required this.width,
|
|
required this.height,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CustomPaint(
|
|
size: Size(width, height),
|
|
painter: _CloudPainter(color),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _CloudPainter extends CustomPainter {
|
|
final Color color;
|
|
|
|
_CloudPainter(this.color);
|
|
|
|
@override
|
|
void paint(Canvas canvas, Size size) {
|
|
final paint = Paint()..color = color;
|
|
final w = size.width;
|
|
final h = size.height;
|
|
|
|
// Base ellipses
|
|
canvas.drawOval(
|
|
Rect.fromCenter(
|
|
center: Offset(w * 0.25, h * 0.55),
|
|
width: w * 0.55,
|
|
height: h * 0.6,
|
|
),
|
|
paint,
|
|
);
|
|
canvas.drawOval(
|
|
Rect.fromCenter(
|
|
center: Offset(w * 0.5, h * 0.45),
|
|
width: w * 0.6,
|
|
height: h * 0.7,
|
|
),
|
|
paint,
|
|
);
|
|
canvas.drawOval(
|
|
Rect.fromCenter(
|
|
center: Offset(w * 0.75, h * 0.55),
|
|
width: w * 0.55,
|
|
height: h * 0.6,
|
|
),
|
|
paint,
|
|
);
|
|
|
|
// base rectangle for cloud bottom
|
|
final bottomRect = Rect.fromLTWH(0, h * 0.55, w, h * 0.35);
|
|
canvas.drawRRect(
|
|
RRect.fromRectAndRadius(bottomRect, Radius.circular(h * 0.18)),
|
|
paint,
|
|
);
|
|
}
|
|
|
|
@override
|
|
bool shouldRepaint(covariant _CloudPainter old) => old.color != color;
|
|
}
|