LCOV - code coverage report
Current view: top level - lib/components/widgets - account_flow_chart.dart Coverage Total Hit
Test: lcov.info Lines: 2.8 % 36 1
Test Date: 2026-11-14 15:08:11 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 'dart:math';
       5              : 
       6              : import 'package:app_finance/_classes/herald/app_design.dart';
       7              : import 'package:app_finance/_classes/herald/app_locale.dart';
       8              : import 'package:app_finance/_classes/storage/app_data.dart';
       9              : import 'package:app_finance/_classes/storage/history_data.dart';
      10              : import 'package:app_finance/_classes/structure/account_app_data.dart';
      11              : import 'package:app_finance/_classes/structure/currency/exchange.dart';
      12              : import 'package:app_finance/_configs/theme_helper.dart';
      13              : import 'package:app_finance/_ext/build_context_ext.dart';
      14              : import 'package:app_finance/charts/data/data_handler.dart';
      15              : import 'package:app_finance/charts/interface/ohlc_data.dart';
      16              : import 'package:app_finance/charts/ohlc_chart.dart';
      17              : import 'package:app_finance/design/wrapper/row_widget.dart';
      18              : import 'package:app_finance/design/wrapper/text_wrapper.dart';
      19              : import 'package:material_ui/material_ui.dart';
      20              : import 'package:provider/provider.dart';
      21              : 
      22              : class AccountFlowChart extends StatelessWidget {
      23            1 :   const AccountFlowChart({super.key});
      24              : 
      25            0 :   List<OhlcData> getData(AppData store, List<AccountAppData> accounts, DateTime xMin) {
      26            0 :     final exchange = Exchange(store: store);
      27            0 :     return DataHandler.generateOhlcSummary(
      28            0 :       HistoryData.getMultiLog(accounts),
      29              :       exchange: exchange,
      30              :       cut: xMin,
      31              :     );
      32              :   }
      33              : 
      34            0 :   DateTime getMin() => DateTime(DateTime.now().year, DateTime.now().month - 5);
      35              : 
      36            0 :   @override
      37              :   Widget build(BuildContext context) {
      38            0 :     final TextTheme textTheme = context.textTheme;
      39            0 :     double indent = ThemeHelper.getIndent();
      40            0 :     return Consumer<AppData>(builder: (context, appState, _) {
      41            0 :       final accountList = appState.getList(AppDataType.accounts).cast<AccountAppData>();
      42            0 :       final xMin = getMin();
      43            0 :       final data = getData(appState, accountList, xMin);
      44            0 :       return LayoutBuilder(builder: (context, constraints) {
      45            0 :         final width = constraints.maxWidth - indent * 2;
      46            0 :         return Column(
      47            0 :           crossAxisAlignment: AppDesign.getAlignment(),
      48            0 :           children: [
      49            0 :             TextWrapper(
      50            0 :               '${AppLocale.labels.chartOHLC}, ${Exchange.defaultCurrency?.code}',
      51            0 :               style: textTheme.bodyLarge,
      52              :             ),
      53            0 :             OhlcChart(
      54              :               width: width,
      55            0 :               height: [constraints.maxHeight - 6 * indent, 200].reduce(min).toDouble(),
      56              :               indent: indent,
      57              :               xMin: xMin,
      58              :               data: data,
      59              :             ),
      60            0 :             RowWidget(
      61              :               maxWidth: width,
      62              :               indent: indent,
      63              :               chunk: const [null, null],
      64            0 :               children: [
      65            0 :                 [
      66            0 :                   Padding(
      67            0 :                     padding: EdgeInsets.only(left: indent * 2),
      68            0 :                     child: TextWrapper(
      69            0 :                       AppLocale.labels.raiseData,
      70            0 :                       style: textTheme.bodySmall?.copyWith(color: Colors.blue),
      71              :                     ),
      72              :                   ),
      73              :                 ],
      74            0 :                 [
      75            0 :                   Align(
      76              :                     alignment: Alignment.centerRight,
      77            0 :                     child: TextWrapper(
      78            0 :                       AppLocale.labels.failData,
      79            0 :                       style: textTheme.bodySmall?.copyWith(color: Colors.red),
      80              :                     ),
      81              :                   ),
      82              :                 ],
      83              :               ],
      84              :             ),
      85              :           ],
      86              :         );
      87              :       });
      88              :     });
      89              :   }
      90              : }
        

Generated by: LCOV version 2.0-1