diff options
author | Lisandro Pérez Meyer <lpmeyer@ics.com> | 2023-11-28 13:40:59 -0300 |
---|---|---|
committer | Lisandro Perez Meyer <lpmeyer@ics.com> | 2023-11-28 17:17:09 +0000 |
commit | b9377beb28bb372f8fc29dfe3eeb9145462b716f (patch) | |
tree | dc8ee6133102bd5f789c0a550d7c26345142d1b5 /lib/presentation/screens/hvac/widgets/semi_circle_painter.dart | |
parent | 8558b640173de8fbfe37111b29e4fc68dbc80da1 (diff) |
Update HVAC fan.
This also removes commented out code.
Original by Sabin Sajeevan <ssajeevan@ics.com>.
Bug-AGL: SPEC-4971
Change-Id: I31c3b3046f6e3bdd9cc641d403467eda11144f31
Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/presentation/screens/hvac/widgets/semi_circle_painter.dart')
-rw-r--r-- | lib/presentation/screens/hvac/widgets/semi_circle_painter.dart | 83 |
1 files changed, 52 insertions, 31 deletions
diff --git a/lib/presentation/screens/hvac/widgets/semi_circle_painter.dart b/lib/presentation/screens/hvac/widgets/semi_circle_painter.dart index e2003c5..9756e7f 100644 --- a/lib/presentation/screens/hvac/widgets/semi_circle_painter.dart +++ b/lib/presentation/screens/hvac/widgets/semi_circle_painter.dart @@ -14,13 +14,17 @@ class AnimatedColorPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { // const strokeWidth = 25.0; - const borderWidth = 2.0; // Divide the arc into equal parts based on the number of colors const arcAngle = math.pi; const arcPart = arcAngle / 3; const gapAngle = arcAngle / 150; + // Define drop shadow properties + const shadowOffset = Offset(0, 0); + const shadowBlur = 12.0; + const shadowColor = AGLDemoColors.jordyBlueColor; + // Calculate the current color index based on animation progress and progress value final double normalizedProgress = progress * 3; int currentColorIndex = @@ -40,37 +44,50 @@ class AnimatedColorPainter extends CustomPainter { currentColor = backgroundColor; } + // Create paths for drop shadow and actual color + final shadowPath = Path() + ..addArc( + Rect.fromCircle( + center: Offset(size.width / 2, size.height / 2) + shadowOffset, + radius: size.width / 2, + ), + startAngle, + arcPart - 2 * gapAngle, + // Draw clockwise + ); + final colorPath = Path() + ..addArc( + Rect.fromCircle( + center: Offset(size.width / 2, size.height / 2), + radius: size.width / 2, + ), + startAngle, + arcPart - 2 * gapAngle, + // Draw clockwise + ); + + // Draw drop shadow using offset and blur + final shadowPaint = Paint() + ..color = shadowColor + ..style = PaintingStyle.fill + ..maskFilter = const MaskFilter.blur(BlurStyle.normal, shadowBlur); + if (currentColor == progressColor) { + canvas.drawPath(shadowPath, shadowPaint); + } + // Draw border final borderPaint = Paint() - ..strokeWidth = strokeWidth + borderWidth + ..strokeWidth = strokeWidth + 2.0 // Add border width ..style = PaintingStyle.stroke ..color = Colors.white12; - canvas.drawArc( - Rect.fromCircle( - center: Offset(size.width / 2, size.height / 2), - radius: size.width / 2, - ), - startAngle, - arcPart - 2 * gapAngle, - false, // Draw clockwise - borderPaint, - ); + canvas.drawPath(colorPath, borderPaint); // Draw inner color final colorPaint = Paint() ..strokeWidth = strokeWidth ..style = PaintingStyle.stroke - ..shader = _createColorShader(currentColor, size); - canvas.drawArc( - Rect.fromCircle( - center: Offset(size.width / 2, size.height / 2), - radius: size.width / 2, - ), - startAngle, - arcPart - 2 * gapAngle, - false, // Draw clockwise - colorPaint, - ); + ..shader = _createColorShader(currentColor, size, i); + canvas.drawPath(colorPath, colorPaint); startAngle += arcPart + gapAngle; } @@ -79,15 +96,19 @@ class AnimatedColorPainter extends CustomPainter { @override bool shouldRepaint(covariant CustomPainter oldDelegate) => true; - Shader _createColorShader(Color color, Size size) { + Shader _createColorShader(Color color, Size size, int index) { + Alignment alignment = index == 0 + ? const Alignment(-0.78, -0.38) + : index == 1 + ? const Alignment(0, -1) + : const Alignment(0.78, -0.38); if (color == progressColor) { - return const RadialGradient( - center: Alignment.center, - radius: 2, - tileMode: TileMode.repeated, - focal: Alignment.center, - focalRadius: 8, - colors: [ + return RadialGradient( + center: alignment, + radius: 0.35, + focal: alignment, + focalRadius: 0.02, + colors: const [ AGLDemoColors.blueGlowFillColor, AGLDemoColors.jordyBlueColor, AGLDemoColors.neonBlueColor |