LCOV - code coverage report
Current view: top level - lib/design/wrapper - dots_indicator_decoration.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 21 0
Test Date: 2026-11-14 15:04:37 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2023 The terCAD team. All rights reserved.
       2              : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3              : 
       4              : import 'package:material_ui/material_ui.dart';
       5              : 
       6              : class DotsIndicatorDecoration extends Decoration {
       7              :   final PageController controller;
       8              :   final int itemCount;
       9              :   final Color color;
      10              :   final double dotSize;
      11              :   final double _spacing;
      12              : 
      13            0 :   const DotsIndicatorDecoration({
      14              :     required this.controller,
      15              :     required this.itemCount,
      16              :     required this.color,
      17              :     required this.dotSize,
      18              :     double? spacing,
      19              :   }) : _spacing = spacing ?? dotSize;
      20              : 
      21            0 :   @override
      22              :   BoxPainter createBoxPainter([VoidCallback? onChanged]) {
      23            0 :     return _CustomTabIndicatorPainter(
      24            0 :       controller: controller,
      25            0 :       itemCount: itemCount,
      26            0 :       color: color,
      27            0 :       dotSize: dotSize,
      28            0 :       spacing: _spacing,
      29              :       onChanged: onChanged,
      30              :     );
      31              :   }
      32              : }
      33              : 
      34              : class _CustomTabIndicatorPainter extends BoxPainter {
      35              :   final PageController controller;
      36              :   final int itemCount;
      37              :   final Color color;
      38              :   final double dotSize;
      39              :   final double spacing;
      40              : 
      41            0 :   _CustomTabIndicatorPainter({
      42              :     required this.controller,
      43              :     required this.itemCount,
      44              :     required this.color,
      45              :     required this.dotSize,
      46              :     required this.spacing,
      47              :     VoidCallback? onChanged,
      48            0 :   }) : super(onChanged);
      49              : 
      50            0 :   @override
      51              :   void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
      52            0 :     if (itemCount <= 1) {
      53              :       return;
      54              :     }
      55            0 :     final activeIndex = controller.page?.round() ?? controller.initialPage;
      56            0 :     final active = Paint()..color = color;
      57            0 :     final inactive = Paint()..color = color.withValues(alpha: 0.3);
      58            0 :     for (int i = 0; i < itemCount; i++) {
      59            0 :       double xPos = spacing + i * (dotSize + spacing);
      60            0 :       double yPos = spacing * 0.6;
      61            0 :       if (i == activeIndex) {
      62            0 :         canvas.drawCircle(Offset(xPos, yPos), dotSize / 2, active);
      63              :       } else {
      64            0 :         canvas.drawCircle(Offset(xPos, yPos), dotSize / 2, inactive);
      65              :       }
      66              :     }
      67              :   }
      68              : }
        

Generated by: LCOV version 2.0-1