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

            Line data    Source code
       1              : // Copyright 2024 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/controller/flow_state_machine.dart';
       5              : import 'package:app_finance/_classes/herald/app_design.dart';
       6              : import 'package:app_finance/_classes/herald/app_locale.dart';
       7              : import 'package:app_finance/_classes/storage/app_data.dart';
       8              : import 'package:app_finance/_classes/structure/bill_app_data.dart';
       9              : import 'package:app_finance/_classes/structure/invoice_app_data.dart';
      10              : import 'package:app_finance/_classes/structure/navigation/app_route.dart';
      11              : import 'package:app_finance/_classes/structure/payment_app_data.dart';
      12              : import 'package:app_finance/_configs/automation_type.dart';
      13              : import 'package:app_finance/_configs/screen_helper.dart';
      14              : import 'package:app_finance/_configs/theme_helper.dart';
      15              : import 'package:app_finance/_ext/data_ext.dart';
      16              : import 'package:app_finance/components/widgets/payment_list_widget.dart';
      17              : import 'package:app_finance/design/generic/base_line_widget.dart';
      18              : import 'package:app_finance/design/generic/base_list_infinite_widget.dart';
      19              : import 'package:app_finance/design/generic/base_swipe_widget.dart';
      20              : import 'package:app_finance/design/wrapper/confirmation_wrapper.dart';
      21              : import 'package:app_finance/pages/_interfaces/abstract_page_state.dart';
      22              : import 'package:material_ui/material_ui.dart';
      23              : 
      24              : class PaymentViewPage extends StatefulWidget {
      25              :   final String uuid;
      26              : 
      27            0 :   const PaymentViewPage({
      28              :     super.key,
      29              :     required this.uuid,
      30              :   });
      31              : 
      32            0 :   @override
      33            0 :   PaymentViewPageState createState() => PaymentViewPageState();
      34              : }
      35              : 
      36              : class PaymentViewPageState extends AbstractPageState<PaymentViewPage> {
      37              :   late double width;
      38              : 
      39            0 :   @override
      40              :   String getButtonName() => '';
      41              : 
      42            0 :   @override
      43            0 :   String getTitle() => AutomationType.getLabel((state.getByUuid(widget.uuid) as PaymentAppData).title);
      44              : 
      45            0 :   @override
      46              :   Widget buildButton(BuildContext context, BoxConstraints constraints) {
      47            0 :     double indent = ThemeHelper.getIndent(4);
      48            0 :     NavigatorState nav = Navigator.of(context);
      49            0 :     return Container(
      50            0 :       margin: EdgeInsets.only(left: 2 * indent, right: 2 * indent),
      51            0 :       child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
      52            0 :         FloatingActionButton(
      53              :           heroTag: 'payment_view_page_edit',
      54            0 :           onPressed: () =>
      55            0 :               nav.pushNamed(AppRoute.automationPaymentEditRoute, arguments: {routeArguments.uuid: widget.uuid}),
      56            0 :           tooltip: AppLocale.labels.editPaymentTooltip,
      57              :           child: const Icon(Icons.edit),
      58              :         ),
      59            0 :         FloatingActionButton(
      60              :           heroTag: 'payment_view_page_deactivate',
      61            0 :           onPressed: () => ConfirmationWrapper.show(
      62              :             context,
      63            0 :             () => FlowStateMachine.deactivate(nav, store: super.state, uuid: widget.uuid),
      64              :           ),
      65            0 :           tooltip: AppLocale.labels.deletePaymentTooltip,
      66              :           child: const Icon(Icons.delete),
      67              :         ),
      68              :       ]),
      69              :     );
      70              :   }
      71              : 
      72            0 :   Widget buildListWidget(item, BuildContext context) {
      73            0 :     String routeList = item is BillAppData ? AppRoute.billViewRoute : AppRoute.invoiceViewRoute;
      74            0 :     return BaseSwipeWidget(
      75            0 :       routePath: routeList.replaceAll('/view', '/edit'),
      76            0 :       uuid: item.uuid,
      77            0 :       child: BaseLineWidget(
      78            0 :         uuid: item.uuid ?? '',
      79            0 :         title: item.title,
      80            0 :         description: item.description ?? '',
      81            0 :         details: item.detailsFormatted,
      82            0 :         progress: item.progress,
      83            0 :         color: item.color ?? Colors.transparent,
      84            0 :         icon: item.icon ?? Icons.radio_button_unchecked_sharp,
      85            0 :         hidden: item.hidden,
      86            0 :         skip: item.skip,
      87            0 :         width: width,
      88              :         route: routeList,
      89              :       ),
      90              :     );
      91              :   }
      92              : 
      93            0 :   @override
      94              :   Widget buildContent(BuildContext context, BoxConstraints constraints) {
      95            0 :     width = ThemeHelper.getWidth(context, 2);
      96            0 :     final isLeft = ScreenHelper.state().isLeftBar;
      97              :     if (isLeft) {
      98            0 :       width -= ThemeHelper.barHeight;
      99              :     }
     100            0 :     final indent = ThemeHelper.getIndent();
     101            0 :     final item = state.getByUuid(widget.uuid) as PaymentAppData;
     102            0 :     final obj = item.data.toDataObject(state);
     103            0 :     return Container(
     104            0 :       padding: EdgeInsets.fromLTRB(0, indent * 1.5, 0, indent),
     105            0 :       child: Column(
     106            0 :         crossAxisAlignment: AppDesign.getAlignment(),
     107            0 :         children: [
     108            0 :           PaymentListWidget(item: item, state: state, width: width),
     109            0 :           Expanded(
     110            0 :             child: BaseListInfiniteWidget(
     111            0 :               stream: state.getStream(
     112            0 :                 obj is InvoiceAppData ? AppDataType.invoice : AppDataType.bills,
     113            0 :                 filter: (item) => item.payment != widget.uuid,
     114              :               ),
     115            0 :               width: width,
     116            0 :               buildListWidget: buildListWidget,
     117              :             ),
     118              :           ),
     119              :         ],
     120              :       ),
     121              :     );
     122              :   }
     123              : }
        

Generated by: LCOV version 2.0-1