LCOV - code coverage report
Current view: top level - lib/design/generic - base_line_widget.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 37 40 92.5 %
Date: 2024-10-04 11:12:13 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/_classes/structure/navigation/app_route.dart';
       6             : import 'package:app_finance/_ext/build_context_ext.dart';
       7             : import 'package:app_finance/charts/bar_vertical_single.dart';
       8             : import 'package:app_finance/_configs/custom_text_theme.dart';
       9             : import 'package:app_finance/design/wrapper/number_wrapper.dart';
      10             : import 'package:app_finance/design/wrapper/row_widget.dart';
      11             : import 'package:app_finance/design/wrapper/tap_widget.dart';
      12             : import 'package:app_finance/_configs/theme_helper.dart';
      13             : import 'package:app_finance/design/wrapper/text_wrapper.dart';
      14             : import 'package:flutter/material.dart';
      15             : 
      16             : class BaseLineWidget extends StatelessWidget {
      17             :   final String uuid;
      18             :   final String title;
      19             :   final String details;
      20             :   final String description;
      21             :   final double progress;
      22             :   final Color color;
      23             :   final IconData? icon;
      24             :   final double width;
      25             :   final String route;
      26             :   final bool hidden;
      27             :   final bool showDivider;
      28             :   final Widget? error;
      29             : 
      30           1 :   const BaseLineWidget({
      31             :     super.key,
      32             :     required this.uuid,
      33             :     required this.title,
      34             :     required this.details,
      35             :     required this.description,
      36             :     required this.color,
      37             :     required this.width,
      38             :     this.icon = Icons.question_mark,
      39             :     this.error,
      40             :     this.hidden = false,
      41             :     this.progress = 1,
      42             :     this.route = '',
      43             :     this.showDivider = true,
      44             :   });
      45             : 
      46           1 :   @override
      47             :   Widget build(BuildContext context) {
      48           1 :     if (hidden) {
      49             :       return ThemeHelper.emptyBox;
      50             :     }
      51           1 :     final textTheme = context.textTheme;
      52           1 :     final indent = ThemeHelper.getIndent();
      53           4 :     final txtWidth = ThemeHelper.getTextWidth(Text(details, style: textTheme.numberMedium));
      54             : 
      55           1 :     return TapWidget(
      56             :       tooltip: '',
      57           4 :       toWrap: route != '' && uuid != '',
      58           4 :       route: RouteSettings(name: route, arguments: {routeArguments.uuid: uuid}),
      59           1 :       child: Column(
      60           1 :         crossAxisAlignment: AppDesign.getAlignment(),
      61           1 :         children: [
      62           1 :           RowWidget(
      63             :             indent: indent,
      64           1 :             alignment: AppDesign.getAlignment<MainAxisAlignment>(),
      65           1 :             maxWidth: width,
      66           7 :             chunk: [ThemeHelper.isWearable ? 0 : indent * 1.5, null, txtWidth + 2 * indent, if (error != null) 22],
      67           1 :             children: [
      68           1 :               [
      69           1 :                 Padding(
      70           1 :                   padding: EdgeInsets.only(left: indent),
      71           4 :                   child: BarVerticalSingle(value: progress, height: 32.0, width: indent / 2, color: color),
      72             :                 ),
      73             :               ],
      74           1 :               [
      75           1 :                 ThemeHelper.isWearable
      76           0 :                     ? Tooltip(
      77           0 :                         message: title,
      78           0 :                         child: Icon(icon, color: color),
      79             :                       )
      80           1 :                     : Column(
      81           1 :                         crossAxisAlignment: AppDesign.getAlignment(),
      82           1 :                         children: [
      83           1 :                           TextWrapper(
      84           1 :                             title,
      85           1 :                             style: textTheme.headlineMedium,
      86             :                           ),
      87           1 :                           TextWrapper(
      88           1 :                             description,
      89           1 :                             style: textTheme.bodySmall,
      90             :                           ),
      91             :                         ],
      92             :                       ),
      93             :               ],
      94           1 :               [
      95           1 :                 Align(
      96             :                   alignment: Alignment.centerRight,
      97           4 :                   child: NumberWidget(details, colorScheme: context.colorScheme, style: textTheme.numberMedium),
      98             :                 ),
      99             :               ],
     100           3 :               if (error != null) [error!],
     101             :             ],
     102             :           ),
     103           2 :           if (showDivider) const Divider(),
     104             :         ],
     105             :       ),
     106             :     );
     107             :   }
     108             : }

Generated by: LCOV version 1.14