LCOV - code coverage report
Current view: top level - components/button - foss_button_painters.dart Coverage Total Hit
Test: fossui coverage Lines: 100.0 % 28 28
Test Date: 2026-11-29 09:15:47 Functions: - 0 0

            Line data    Source code
       1              : part of 'foss_button.dart';
       2              : 
       3              : /// Paints a 1px top-lit rim inside the button, the inner highlight on filled
       4              : /// variants. Brightest along the top edge, fading to nothing by the middle.
       5              : class _TopHighlightPainter extends CustomPainter {
       6            8 :   const _TopHighlightPainter({required this.color, required this.radius});
       7              : 
       8              :   final Color color;
       9              :   final double radius;
      10              : 
      11            8 :   @override
      12              :   void paint(Canvas canvas, Size size) {
      13            8 :     final rect = Offset.zero & size;
      14            8 :     final shape = RSuperellipse.fromRectAndRadius(
      15            8 :       rect.deflate(0.5),
      16           16 :       Radius.circular(radius),
      17              :     );
      18            8 :     final shader = LinearGradient(
      19              :       begin: Alignment.topCenter,
      20              :       end: Alignment.center,
      21           32 :       colors: [color, color.withValues(alpha: 0)],
      22            8 :     ).createShader(rect);
      23            8 :     final paint = Paint()
      24            8 :       ..shader = shader
      25            8 :       ..style = PaintingStyle.stroke
      26            8 :       ..strokeWidth = 1;
      27            8 :     canvas.drawRSuperellipse(shape, paint);
      28              :   }
      29              : 
      30            4 :   @override
      31              :   bool shouldRepaint(_TopHighlightPainter oldDelegate) =>
      32           24 :       oldDelegate.color != color || oldDelegate.radius != radius;
      33              : }
      34              : 
      35              : /// Paints the focus ring: a 2px superellipse outset just past the button edge,
      36              : /// matching its corner shape so it reads smooth, not circular.
      37              : class _FocusRingPainter extends CustomPainter {
      38            3 :   const _FocusRingPainter({required this.color, required this.radius});
      39              : 
      40              :   final Color color;
      41              :   final double radius;
      42              : 
      43            3 :   @override
      44              :   void paint(Canvas canvas, Size size) {
      45            6 :     final rect = (Offset.zero & size).inflate(2);
      46            3 :     final shape = RSuperellipse.fromRectAndRadius(
      47              :       rect,
      48            9 :       Radius.circular(radius + 2),
      49              :     );
      50            3 :     final paint = Paint()
      51            6 :       ..color = color
      52            3 :       ..style = PaintingStyle.stroke
      53            3 :       ..strokeWidth = 2;
      54            3 :     canvas.drawRSuperellipse(shape, paint);
      55              :   }
      56              : 
      57            1 :   @override
      58              :   bool shouldRepaint(_FocusRingPainter oldDelegate) =>
      59            6 :       oldDelegate.color != color || oldDelegate.radius != radius;
      60              : }
        

Generated by: LCOV version 2.0-1