LCOV - code coverage report
Current view: top level - lib/pages/goal - goal_view_page.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 54 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_locale.dart';
       5              : import 'package:app_finance/_classes/controller/flow_state_machine.dart';
       6              : import 'package:app_finance/_classes/structure/bill_app_data.dart';
       7              : import 'package:app_finance/_classes/structure/goal_app_data.dart';
       8              : import 'package:app_finance/_classes/storage/app_preferences.dart';
       9              : import 'package:app_finance/_configs/theme_helper.dart';
      10              : import 'package:app_finance/_classes/structure/navigation/app_route.dart';
      11              : import 'package:app_finance/pages/_interfaces/abstract_page_state.dart';
      12              : import 'package:app_finance/design/generic/base_line_widget.dart';
      13              : import 'package:app_finance/design/wrapper/confirmation_wrapper.dart';
      14              : import 'package:material_ui/material_ui.dart';
      15              : import 'package:flutter_currency_picker/flutter_currency_picker.dart';
      16              : 
      17              : class GoalViewPage extends StatefulWidget {
      18              :   final String uuid;
      19              : 
      20            0 :   const GoalViewPage({
      21              :     super.key,
      22              :     required this.uuid,
      23              :   });
      24              : 
      25            0 :   @override
      26            0 :   GoalViewPageState createState() => GoalViewPageState();
      27              : }
      28              : 
      29              : class GoalViewPageState extends AbstractPageState<GoalViewPage> {
      30              :   late String defaultAccount;
      31              : 
      32            0 :   @override
      33              :   void initState() {
      34            0 :     defaultAccount = AppPreferences.get(AppPreferences.prefAccount) ?? '';
      35            0 :     super.initState();
      36              :   }
      37              : 
      38            0 :   @override
      39              :   String getTitle() {
      40            0 :     final data = super.state.getByUuid(widget.uuid) as GoalAppData;
      41            0 :     return data.title;
      42              :   }
      43              : 
      44            0 :   void completeGoal(GoalAppData data, NavigatorState nav) {
      45            0 :     var newBill = BillAppData(
      46            0 :       account: defaultAccount,
      47              :       category: '',
      48            0 :       title: '${AppLocale.labels.completeGoalTooltip}: ${data.title}',
      49            0 :       details: data.details,
      50            0 :       currency: data.currency,
      51              :     );
      52            0 :     newBill = super.state.add(newBill);
      53            0 :     FlowStateMachine.deactivate(nav, store: super.state, data: data);
      54            0 :     nav.popAndPushNamed(AppRoute.billEditRoute, arguments: {routeArguments.uuid: newBill.uuid ?? ''});
      55              :   }
      56              : 
      57            0 :   @override
      58              :   String getButtonName() => '';
      59              : 
      60            0 :   @override
      61              :   Widget buildButton(BuildContext context, BoxConstraints constraints) {
      62            0 :     final data = super.state.getByUuid(widget.uuid) as GoalAppData;
      63            0 :     double indent = ThemeHelper.getIndent(4);
      64            0 :     NavigatorState nav = Navigator.of(context);
      65            0 :     return Container(
      66            0 :       margin: EdgeInsets.only(left: 2 * indent, right: 2 * indent),
      67            0 :       child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
      68            0 :         FloatingActionButton(
      69              :           heroTag: 'goal_view_page_edit',
      70            0 :           onPressed: () => nav.pushNamed(AppRoute.goalEditRoute, arguments: {routeArguments.uuid: widget.uuid}),
      71            0 :           tooltip: AppLocale.labels.editGoalTooltip,
      72              :           child: const Icon(Icons.edit),
      73              :         ),
      74            0 :         data.progress == 1.0
      75            0 :             ? FloatingActionButton(
      76              :                 heroTag: 'goal_view_page_check',
      77            0 :                 onPressed: () => completeGoal(data, nav),
      78            0 :                 tooltip: AppLocale.labels.completeGoalTooltip,
      79              :                 child: const Icon(Icons.check),
      80              :               )
      81            0 :             : FloatingActionButton(
      82              :                 heroTag: 'goal_view_page_deactivate',
      83            0 :                 onPressed: () => ConfirmationWrapper.show(
      84              :                   context,
      85            0 :                   () => FlowStateMachine.deactivate(nav, store: super.state, data: data),
      86              :                 ),
      87            0 :                 tooltip: AppLocale.labels.deleteGoalTooltip,
      88              :                 child: const Icon(Icons.delete),
      89              :               ),
      90              :       ]),
      91              :     );
      92              :   }
      93              : 
      94            0 :   @override
      95              :   Widget buildContent(BuildContext context, BoxConstraints constraints) {
      96            0 :     final item = super.state.getByUuid(widget.uuid) as GoalAppData;
      97            0 :     return Padding(
      98            0 :       padding: EdgeInsets.only(top: ThemeHelper.getIndent()),
      99            0 :       child: Column(
     100            0 :         children: [
     101            0 :           BaseLineWidget(
     102            0 :             title: item.title,
     103            0 :             width: ThemeHelper.getWidth(context, 2, constraints),
     104            0 :             uuid: widget.uuid,
     105            0 :             details: (item.details as double).toCurrency(currency: item.currency, withPattern: false),
     106            0 :             description: item.closedAtFormatted,
     107            0 :             color: item.color ?? Colors.green.shade700,
     108            0 :             icon: item.icon ?? Icons.radio_button_unchecked_sharp,
     109            0 :             hidden: item.hidden,
     110            0 :             skip: item.skip,
     111            0 :             progress: item.progress,
     112              :           )
     113              :         ],
     114              :       ),
     115              :     );
     116              :   }
     117              : }
        

Generated by: LCOV version 2.0-1