LCOV - code coverage report
Current view: top level - lib/widget - progress_bar.dart Coverage Total Hit
Test: lcov.info Lines: 2.4 % 42 1
Test Date: 2025-05-10 20:26:13 Functions: - 0 0

            Line data    Source code
       1              : import 'dart:math';
       2              : 
       3              : import 'package:amadeus_proto/utils/color_extensions.dart';
       4              : import 'package:flutter/material.dart';
       5              : 
       6              : class ProgressBar extends StatelessWidget {
       7           24 :   const ProgressBar({
       8              :     super.key,
       9              :     required this.totalAmount,
      10              :     required this.progressAmount,
      11              :     this.height,
      12              :     this.width,
      13              :     this.stripeWidth,
      14              :     this.stripeSpacing,
      15              :     this.color = const Color.fromARGB(255, 144, 231, 124),
      16              :   });
      17              : 
      18              :   final num totalAmount;
      19              :   final num progressAmount;
      20              :   final double? height;
      21              :   final double? width;
      22              :   final double? stripeWidth;
      23              :   final double? stripeSpacing;
      24              :   final Color color;
      25              : 
      26            0 :   @override
      27              :   Widget build(BuildContext context) {
      28            0 :     final double progressFraction = progressAmount / totalAmount;
      29              : 
      30            0 :     return Container(
      31            0 :       decoration: BoxDecoration(
      32            0 :           borderRadius: BorderRadius.circular(16),
      33            0 :           color: Colors.grey.shade200,
      34            0 :           border: Border.all(color: const Color.fromARGB(255, 235, 235, 235))),
      35            0 :       height: height ?? 20,
      36            0 :       width: width ?? 300,
      37            0 :       child: TweenAnimationBuilder<double>(
      38              :         duration: const Duration(milliseconds: 250),
      39              :         curve: Curves.easeInOut,
      40            0 :         tween: Tween<double>(
      41              :           begin: 0,
      42              :           end: progressFraction,
      43              :         ),
      44            0 :         builder: (context, value, _) => Stack(
      45            0 :           children: [
      46            0 :             FractionallySizedBox(
      47              :               widthFactor: value,
      48            0 :               child: ClipRRect(
      49            0 :                 borderRadius: BorderRadius.circular(16),
      50            0 :                 child: Container(
      51            0 :                   color: color,
      52            0 :                   child: CustomPaint(
      53            0 :                     painter: StripedPainter(
      54            0 :                         color: color.darkerShade(0.03), stripeSpacing: 11),
      55            0 :                     child: Container(),
      56              :                   ),
      57              :                 ),
      58              :               ),
      59              :             ),
      60              :           ],
      61              :         ),
      62              :       ),
      63              :     );
      64              :   }
      65              : }
      66              : 
      67              : class StripedPainter extends CustomPainter {
      68            0 :   StripedPainter(
      69              :       {super.repaint,
      70              :       this.stripeWidth,
      71              :       this.stripeSpacing,
      72              :       required this.color});
      73              : 
      74              :   final double? stripeWidth;
      75              :   final double? stripeSpacing;
      76              :   final Color color;
      77              : 
      78            0 :   @override
      79              :   void paint(Canvas canvas, Size size) {
      80            0 :     final Paint paint = Paint()
      81            0 :       ..color = color
      82            0 :       ..style = PaintingStyle.fill;
      83              : 
      84            0 :     final double stripeWidth = this.stripeWidth ?? 10.0;
      85            0 :     final double stripeSpacing = this.stripeSpacing ?? 10.0;
      86              : 
      87            0 :     for (double x = -stripeWidth;
      88            0 :         x < size.width + stripeWidth + stripeSpacing;
      89            0 :         x += stripeWidth + stripeSpacing) {
      90            0 :       canvas.save();
      91            0 :       canvas.translate(x + stripeWidth / 2, size.height / 2);
      92              : 
      93            0 :       double angle = 30 * pi / 180;
      94            0 :       canvas.rotate(angle);
      95              : 
      96            0 :       canvas.drawRect(
      97            0 :         Rect.fromLTWH(
      98            0 :             -stripeWidth / 2, -size.height, stripeWidth, size.height * 2),
      99              :         paint,
     100              :       );
     101              : 
     102            0 :       canvas.restore();
     103              :     }
     104              :   }
     105              : 
     106            0 :   @override
     107              :   bool shouldRepaint(covariant CustomPainter oldDelegate) {
     108              :     return false;
     109              :   }
     110              : }
        

Generated by: LCOV version 2.3-1