|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import '../core/animated_svg_icon_base.dart'; |
| 3 | + |
| 4 | +/// Animated File Archive Icon - archive box lifts |
| 5 | +class FileArchiveIcon extends AnimatedSVGIcon { |
| 6 | + const FileArchiveIcon({ |
| 7 | + super.key, |
| 8 | + super.size = 40.0, |
| 9 | + super.color, |
| 10 | + super.hoverColor, |
| 11 | + super.animationDuration = const Duration(milliseconds: 650), |
| 12 | + super.strokeWidth = 2.0, |
| 13 | + super.reverseOnExit = false, |
| 14 | + super.enableTouchInteraction = true, |
| 15 | + super.infiniteLoop = false, |
| 16 | + super.onTap, |
| 17 | + super.interactive, |
| 18 | + super.controller, |
| 19 | + }); |
| 20 | + |
| 21 | + @override |
| 22 | + String get animationDescription => "archive box lifts"; |
| 23 | + |
| 24 | + @override |
| 25 | + CustomPainter createPainter({ |
| 26 | + required Color color, |
| 27 | + required double animationValue, |
| 28 | + required double strokeWidth, |
| 29 | + }) { |
| 30 | + return FileArchivePainter( |
| 31 | + color: color, |
| 32 | + animationValue: animationValue, |
| 33 | + strokeWidth: strokeWidth, |
| 34 | + ); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +class FileArchivePainter extends CustomPainter { |
| 39 | + final Color color; |
| 40 | + final double animationValue; |
| 41 | + final double strokeWidth; |
| 42 | + |
| 43 | + FileArchivePainter({ |
| 44 | + required this.color, |
| 45 | + required this.animationValue, |
| 46 | + required this.strokeWidth, |
| 47 | + }); |
| 48 | + |
| 49 | + @override |
| 50 | + void paint(Canvas canvas, Size size) { |
| 51 | + final paint = Paint() |
| 52 | + ..color = color |
| 53 | + ..strokeWidth = strokeWidth |
| 54 | + ..strokeCap = StrokeCap.round |
| 55 | + ..strokeJoin = StrokeJoin.round |
| 56 | + ..style = PaintingStyle.stroke; |
| 57 | + |
| 58 | + final scale = size.width / 24.0; |
| 59 | + final path0 = Path(); |
| 60 | + path0.moveTo(13.659 * scale, 22 * scale); |
| 61 | + path0.lineTo(18 * scale, 22 * scale); |
| 62 | + path0.arcToPoint(Offset(20 * scale, 20 * scale), |
| 63 | + radius: Radius.circular(2 * scale), clockwise: false); |
| 64 | + path0.lineTo(20 * scale, 8 * scale); |
| 65 | + path0.arcToPoint(Offset(19.294 * scale, 6.294 * scale), |
| 66 | + radius: Radius.circular(2.4 * scale), clockwise: false); |
| 67 | + path0.lineTo(15.706 * scale, 2.706 * scale); |
| 68 | + path0.arcToPoint(Offset(14 * scale, 2 * scale), |
| 69 | + radius: Radius.circular(2.4 * scale), clockwise: false); |
| 70 | + path0.lineTo(6 * scale, 2 * scale); |
| 71 | + path0.arcToPoint(Offset(4 * scale, 4 * scale), |
| 72 | + radius: Radius.circular(2 * scale), clockwise: false); |
| 73 | + path0.lineTo(4 * scale, 15.5 * scale); |
| 74 | + canvas.drawPath(path0, paint); |
| 75 | + final path1 = Path(); |
| 76 | + path1.moveTo(14 * scale, 2 * scale); |
| 77 | + path1.lineTo(14 * scale, 7 * scale); |
| 78 | + path1.arcToPoint(Offset(15 * scale, 8 * scale), |
| 79 | + radius: Radius.circular(1 * scale), clockwise: false); |
| 80 | + path1.lineTo(20 * scale, 8 * scale); |
| 81 | + canvas.drawPath(path1, paint); |
| 82 | + final pulse = 4 * animationValue * (1 - animationValue); |
| 83 | + final path2 = Path(); |
| 84 | + path2.moveTo(8 * scale, 12 * scale); |
| 85 | + path2.lineTo(8 * scale, 11 * scale); |
| 86 | + canvas.drawPath(path2, paint); |
| 87 | + final path3 = Path(); |
| 88 | + path3.moveTo(8 * scale, 18 * scale); |
| 89 | + path3.lineTo(8 * scale, 16 * scale); |
| 90 | + canvas.drawPath(path3, paint); |
| 91 | + final path4 = Path(); |
| 92 | + path4.moveTo(8 * scale, 7 * scale); |
| 93 | + path4.lineTo(8 * scale, 6 * scale); |
| 94 | + canvas.drawPath(path4, paint); |
| 95 | + canvas.save(); |
| 96 | + canvas.translate(0, -pulse * 2.2 * scale); |
| 97 | + canvas.drawCircle(Offset(8 * scale, 20 * scale), 2 * scale, paint); |
| 98 | + canvas.restore(); |
| 99 | + } |
| 100 | + |
| 101 | + @override |
| 102 | + bool shouldRepaint(FileArchivePainter oldDelegate) { |
| 103 | + return oldDelegate.color != color || |
| 104 | + oldDelegate.animationValue != animationValue || |
| 105 | + oldDelegate.strokeWidth != strokeWidth; |
| 106 | + } |
| 107 | +} |
0 commit comments