LCOV - code coverage report
Current view: top level - lib/pages/bill/widgets - sliver_header_delegate.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 25 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:app_finance/_classes/herald/app_design.dart';
       5              : import 'package:app_finance/_configs/theme_helper.dart';
       6              : import 'package:app_finance/_ext/build_context_ext.dart';
       7              : import 'package:material_ui/material_ui.dart';
       8              : 
       9              : class SliverHeaderDelegate extends SliverPersistentHeaderDelegate {
      10              :   final key = GlobalKey();
      11              :   double closedHeight;
      12              :   double openHeight;
      13              :   String title;
      14              :   Function? callback;
      15              : 
      16            0 :   SliverHeaderDelegate(
      17              :     this.title, {
      18              :     this.closedHeight = 29,
      19              :     this.openHeight = 30,
      20              :     this.callback,
      21              :   });
      22              : 
      23            0 :   @override
      24            0 :   double get maxExtent => openHeight;
      25              : 
      26            0 :   @override
      27            0 :   double get minExtent => closedHeight;
      28              : 
      29            0 :   @override
      30              :   bool shouldRebuild(oldDelegate) => true;
      31              : 
      32            0 :   @override
      33              :   Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
      34            0 :     final tmp = key.currentContext;
      35              :     try {
      36            0 :       if (tmp != null && tmp.mounted && tmp.findRenderObject() is RenderBox) {
      37            0 :         callback?.call(title);
      38              :       }
      39              :     } catch (e) {
      40              :       // .. ignore inactive state
      41              :     }
      42            0 :     final indent = ThemeHelper.getIndent();
      43            0 :     final isPinned = shrinkOffset == maxExtent;
      44            0 :     return Container(
      45            0 :       padding: EdgeInsets.fromLTRB(indent, indent / 2, 0, 0),
      46            0 :       key: key,
      47            0 :       height: openHeight,
      48            0 :       decoration: BoxDecoration(
      49              :         color: isPinned
      50            0 :             ? Color.alphaBlend(context.colorScheme.inverseSurface.withValues(alpha: 0.1), context.colorScheme.surface)
      51            0 :             : context.colorScheme.surface,
      52              :         border: isPinned
      53              :             ? null
      54            0 :             : Border(
      55            0 :                 bottom: BorderSide(
      56            0 :                   color: context.colorScheme.secondary.withValues(alpha: 0.2),
      57              :                 ),
      58              :               ),
      59              :       ),
      60            0 :       child: Align(
      61            0 :         alignment: AppDesign.isRightToLeft() ? Alignment.centerRight : Alignment.centerLeft,
      62            0 :         child: Text(title, style: context.textTheme.bodySmall),
      63              :       ),
      64              :     );
      65              :   }
      66              : }
        

Generated by: LCOV version 2.0-1