LCOV - code coverage report
Current view: top level - lib/pages/account - account_edit_page.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 40 0
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 'package:app_finance/_classes/herald/app_locale.dart';
       5              : import 'package:app_finance/_classes/structure/account_app_data.dart';
       6              : import 'package:app_finance/_configs/account_type.dart';
       7              : import 'package:app_finance/pages/account/account_add_page.dart';
       8              : import 'package:material_ui/material_ui.dart';
       9              : 
      10              : class AccountEditPage extends AccountAddPage {
      11              :   final String uuid;
      12              : 
      13            0 :   const AccountEditPage({
      14              :     super.key,
      15              :     required this.uuid,
      16              :   });
      17              : 
      18            0 :   @override
      19            0 :   AccountEditPageState createState() => AccountEditPageState();
      20              : }
      21              : 
      22              : class AccountEditPageState extends AccountAddPageState<AccountEditPage> {
      23              :   bool isFirstRun = true;
      24              : 
      25            0 :   void bindState() {
      26            0 :     if (!isFirstRun) {
      27              :       return;
      28              :     }
      29            0 :     setState(() {
      30            0 :       isFirstRun = false;
      31            0 :       final form = state.getByUuid(widget.uuid) as AccountAppData;
      32            0 :       title.text = form.title;
      33            0 :       description.text = form.description ?? '';
      34            0 :       type = form.type;
      35            0 :       balance.text = form.details != null ? form.details.toString() : '';
      36            0 :       color = form.color;
      37            0 :       currency = form.currency;
      38            0 :       icon = form.icon;
      39            0 :       validTillDate = form.closedAt;
      40            0 :       skip = form.skip;
      41            0 :       balanceUpdateDate = DateTime.now();
      42              :     });
      43              :   }
      44              : 
      45            0 :   @override
      46              :   void updateStorage() {
      47            0 :     super.state.update(
      48            0 :         widget.uuid,
      49            0 :         AccountAppData(
      50            0 :           uuid: widget.uuid,
      51            0 :           title: title.text,
      52            0 :           type: type ?? AppAccountType.cash.toString(),
      53            0 :           description: description.text,
      54            0 :           details: double.tryParse(balance.text) ?? 0.0,
      55              :           progress: 1.0,
      56            0 :           color: color ?? Colors.red,
      57            0 :           currency: currency,
      58              :           hidden: false,
      59            0 :           skip: skip,
      60            0 :           icon: icon,
      61            0 :           closedAt: validTillDate,
      62            0 :           createdAt: balanceUpdateDate,
      63              :         ));
      64              :   }
      65              : 
      66            0 :   @override
      67            0 :   String getTitle() => AppLocale.labels.editAccountHeader;
      68              : 
      69            0 :   @override
      70            0 :   String getButtonName() => AppLocale.labels.updateAccountTooltip;
      71              : 
      72            0 :   @override
      73              :   Widget buildContent(BuildContext context, BoxConstraints constraints) {
      74            0 :     WidgetsBinding.instance.addPostFrameCallback((_) => bindState());
      75            0 :     return super.buildContent(context, constraints);
      76              :   }
      77              : }
        

Generated by: LCOV version 2.0-1