LCOV - code coverage report
Current view: top level - lib/pages/bill - bill_view_page.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 61 0
Test Date: 2026-12-05 10:54: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_locale.dart';
       5              : import 'package:app_finance/_classes/controller/flow_state_machine.dart';
       6              : import 'package:app_finance/_classes/storage/app_data.dart';
       7              : import 'package:app_finance/_classes/structure/bill_app_data.dart';
       8              : import 'package:app_finance/_configs/theme_helper.dart';
       9              : import 'package:app_finance/_classes/structure/navigation/app_route.dart';
      10              : import 'package:app_finance/design/button/full_sized_button_widget.dart';
      11              : import 'package:app_finance/design/wrapper/background_wrapper.dart';
      12              : import 'package:app_finance/pages/_interfaces/abstract_page_state.dart';
      13              : import 'package:app_finance/pages/bill/widgets/bill_header_widget.dart';
      14              : import 'package:app_finance/design/wrapper/confirmation_wrapper.dart';
      15              : import 'package:app_finance/pages/bill/widgets/bill_line_widget.dart';
      16              : import 'package:app_finance/pages/bill/bill_split_page.dart';
      17              : import 'package:app_finance/pages/tags/widgets/tags_chips_widget.dart';
      18              : import 'package:material_ui/material_ui.dart';
      19              : 
      20              : class BillViewPage extends StatefulWidget {
      21              :   final String uuid;
      22              : 
      23            0 :   const BillViewPage({
      24              :     super.key,
      25              :     required this.uuid,
      26              :   });
      27              : 
      28            0 :   @override
      29            0 :   BillViewPageState createState() => BillViewPageState();
      30              : }
      31              : 
      32              : class BillViewPageState extends AbstractPageState<BillViewPage> {
      33            0 :   @override
      34              :   void initState() {
      35            0 :     super.initState();
      36              :   }
      37              : 
      38            0 :   @override
      39            0 :   String getTitle() => (state.getByUuid(widget.uuid) as BillAppData).title;
      40              : 
      41            0 :   @override
      42              :   String getButtonName() => '';
      43              : 
      44            0 :   @override
      45              :   Widget buildButton(BuildContext context, BoxConstraints constraints) {
      46            0 :     double indent = ThemeHelper.getIndent(4);
      47            0 :     NavigatorState nav = Navigator.of(context);
      48            0 :     return Container(
      49            0 :       margin: EdgeInsets.only(left: 2 * indent, right: 2 * indent),
      50            0 :       child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
      51            0 :         FloatingActionButton(
      52              :           heroTag: 'bill_view_page_edit',
      53            0 :           onPressed: () => nav.pushNamed(AppRoute.billEditRoute, arguments: {routeArguments.uuid: widget.uuid}),
      54            0 :           tooltip: AppLocale.labels.editBillTooltip,
      55              :           child: const Icon(Icons.edit),
      56              :         ),
      57            0 :         FloatingActionButton(
      58              :           heroTag: 'bill_view_page_deactivate',
      59            0 :           onPressed: () => ConfirmationWrapper.show(
      60              :             context,
      61            0 :             () => FlowStateMachine.deactivate(nav, store: super.state, uuid: widget.uuid),
      62              :           ),
      63            0 :           tooltip: AppLocale.labels.deleteBillTooltip,
      64              :           child: const Icon(Icons.delete),
      65              :         ),
      66              :       ]),
      67              :     );
      68              :   }
      69              : 
      70            0 :   @override
      71              :   Widget buildContent(BuildContext context, BoxConstraints constraints) {
      72            0 :     final indent = ThemeHelper.getIndent();
      73            0 :     final item = state.getByUuid(widget.uuid) as BillAppData;
      74            0 :     final width = ThemeHelper.getWidth(context, 2, constraints);
      75            0 :     final bills = state
      76            0 :         .getStream<BillAppData>(AppDataType.bills, filter: (e) => e.childOf != widget.uuid)
      77            0 :         .toList()
      78            0 :         .cast<BillAppData>();
      79            0 :     return SingleChildScrollView(
      80            0 :       padding: EdgeInsets.only(top: indent),
      81            0 :       child: Column(
      82            0 :         children: [
      83            0 :           BillHeaderWidget(
      84              :             item: item,
      85              :             width: width,
      86              :           ),
      87            0 :           TagsChipsWidget(tags: item.tags),
      88              :           ThemeHelper.hIndent05,
      89              :           const Divider(height: 2),
      90            0 :           Padding(
      91            0 :             padding: EdgeInsets.all(indent),
      92            0 :             child: Column(
      93            0 :               children: [
      94            0 :                 ListView.builder(
      95              :                   scrollDirection: Axis.vertical,
      96              :                   shrinkWrap: true,
      97              :                   physics: const NeverScrollableScrollPhysics(),
      98            0 :                   itemCount: bills.length,
      99            0 :                   itemBuilder: (_, int index) {
     100            0 :                     BillAppData item = bills[index];
     101            0 :                     final account = state.getByUuid(item.account);
     102            0 :                     final budget = state.getByUuid(item.category);
     103            0 :                     return BackgroundWrapper(
     104              :                       index: index,
     105            0 :                       child: BillLineWidget(
     106            0 :                         width: width - 2 * indent,
     107            0 :                         uuid: item.uuid ?? '',
     108            0 :                         title: item.title,
     109            0 :                         details: item.detailsFormatted,
     110            0 :                         description: item.description,
     111            0 :                         color: item.color ?? Colors.transparent,
     112            0 :                         icon: item.icon ?? Icons.question_mark,
     113            0 :                         descriptionColor: account?.color ?? Colors.transparent,
     114            0 :                         iconTooltip: budget?.title ?? '?',
     115              :                       ),
     116              :                     );
     117              :                   },
     118              :                 ),
     119            0 :                 FullSizedButtonWidget(
     120            0 :                   onPressed: () => Navigator.of(context).push(
     121            0 :                     MaterialPageRoute(
     122            0 :                       builder: (context) => BillSplitPage(uuid: widget.uuid),
     123              :                     ),
     124              :                   ),
     125            0 :                   title: AppLocale.labels.splitHeadline,
     126              :                   icon: Icons.account_balance_wallet_outlined,
     127              :                 ),
     128              :                 const Divider(),
     129              :                 // Images
     130              :                 ThemeHelper.formEndBox,
     131              :               ],
     132              :             ),
     133              :           ),
     134              :         ],
     135              :       ),
     136              :     );
     137              :   }
     138              : }
        

Generated by: LCOV version 2.0-1