LCOV - code coverage report
Current view: top level - lib/pages/goal - goal_page.dart Coverage Total Hit
Test: lcov.info Lines: 65.0 % 40 26
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/storage/app_data.dart';
       5              : import 'package:app_finance/_classes/herald/app_locale.dart';
       6              : import 'package:app_finance/_classes/structure/goal_app_data.dart';
       7              : import 'package:app_finance/_configs/theme_helper.dart';
       8              : import 'package:app_finance/_classes/structure/navigation/app_route.dart';
       9              : import 'package:app_finance/design/wrapper/background_wrapper.dart';
      10              : import 'package:app_finance/pages/_interfaces/abstract_page_state.dart';
      11              : import 'package:app_finance/pages/goal/widgets/goal_line_widget.dart';
      12              : import 'package:app_finance/pages/goal/widgets/header_widget.dart';
      13              : import 'package:app_finance/pages/goal/widgets/profit_widget.dart';
      14              : import 'package:material_ui/material_ui.dart';
      15              : 
      16              : class GoalPage extends StatefulWidget {
      17            2 :   const GoalPage({super.key});
      18              : 
      19            1 :   @override
      20            1 :   GoalPageState createState() => GoalPageState();
      21              : }
      22              : 
      23              : class GoalPageState extends AbstractPageState<GoalPage> {
      24            1 :   @override
      25              :   String getTitle() {
      26            2 :     return AppLocale.labels.goalHeadline;
      27              :   }
      28              : 
      29            1 :   @override
      30            2 :   String getButtonName() => AppLocale.labels.addGoalTooltip;
      31              : 
      32            1 :   @override
      33              :   Widget buildButton(BuildContext context, BoxConstraints constraints) {
      34            1 :     NavigatorState nav = Navigator.of(context);
      35            1 :     return FloatingActionButton(
      36              :       heroTag: 'goal_view_page',
      37            0 :       onPressed: () => nav.pushNamed(AppRoute.goalAddRoute),
      38            1 :       tooltip: getButtonName(),
      39              :       child: const Icon(Icons.add),
      40              :     );
      41              :   }
      42              : 
      43            1 :   @override
      44              :   Widget buildContent(BuildContext context, BoxConstraints constraints) {
      45            1 :     final width = ThemeHelper.getWidth(context, 4, constraints);
      46            2 :     final goals = state.getStream(AppDataType.goals);
      47            1 :     final widthCount = ThemeHelper.getWidthCount(constraints, context);
      48              : 
      49            1 :     return Padding(
      50            2 :       padding: EdgeInsets.all(ThemeHelper.getIndent()),
      51            1 :       child: Column(
      52            1 :         children: [
      53              :           ThemeHelper.hIndent,
      54            1 :           Align(
      55              :             alignment: Alignment.centerRight,
      56            3 :             child: ProfitWidget(store: state, width: width / widthCount),
      57              :           ),
      58              :           ThemeHelper.hIndent,
      59            1 :           if (widthCount > 1)
      60            1 :             HeaderWidget(
      61              :               count: widthCount,
      62              :               width: width,
      63              :             ),
      64            1 :           Expanded(
      65            1 :             child: ListView.builder(
      66              :               scrollDirection: Axis.vertical,
      67              :               shrinkWrap: true,
      68            1 :               itemCount: goals.length,
      69            0 :               itemBuilder: (_, int index) {
      70            0 :                 final goal = goals.next as GoalAppData?;
      71              :                 if (goal == null) {
      72              :                   return const SizedBox.shrink();
      73              :                 }
      74            0 :                 return BackgroundWrapper(
      75              :                   index: index,
      76            0 :                   child: GoalLineWidget(
      77            0 :                     title: goal.title,
      78              :                     width: width,
      79              :                     count: widthCount,
      80            0 :                     uuid: goal.uuid ?? '',
      81            0 :                     details: goal.details,
      82            0 :                     currency: goal.currency,
      83            0 :                     description: goal.closedAtFormatted,
      84            0 :                     color: goal.color ?? Colors.green.shade700,
      85            0 :                     icon: goal.icon ?? Icons.star,
      86            0 :                     hidden: goal.hidden,
      87            0 :                     progress: goal.progress,
      88              :                     route: AppRoute.goalViewRoute,
      89              :                   ),
      90              :                 );
      91              :               },
      92              :             ),
      93              :           ),
      94              :         ],
      95              :       ),
      96              :     );
      97              :   }
      98              : }
        

Generated by: LCOV version 2.0-1