LCOV - code coverage report
Current view: top level - lib/pages/start/widgets - account_tab.dart Coverage Total Hit
Test: lcov.info Lines: 84.6 % 26 22
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/storage/app_preferences.dart';
       6              : import 'package:app_finance/_classes/storage/app_data.dart';
       7              : import 'package:app_finance/_configs/theme_helper.dart';
       8              : import 'package:app_finance/design/button/full_sized_button_widget.dart';
       9              : import 'package:app_finance/pages/account/account_add_page.dart';
      10              : import 'package:material_ui/material_ui.dart';
      11              : import 'package:provider/provider.dart';
      12              : 
      13              : class AccountTab extends AccountAddPage {
      14              :   final bool isFirstBoot;
      15              :   final Function() setState;
      16              :   final Function(Widget btn) setButton;
      17              : 
      18            1 :   const AccountTab({
      19              :     super.key,
      20              :     required this.isFirstBoot,
      21              :     required this.setState,
      22              :     required this.setButton,
      23              :   });
      24              : 
      25            1 :   @override
      26            1 :   AccountTabState createState() => AccountTabState();
      27              : }
      28              : 
      29              : class AccountTabState extends AccountAddPageState<AccountTab> {
      30            1 :   @override
      31              :   void triggerActionButton(NavigatorState nav) {
      32            2 :     setState(() {
      33            1 :       if (hasFormErrors()) {
      34              :         return;
      35              :       }
      36            1 :       updateStorage();
      37            5 :       AppPreferences.set(AppPreferences.prefAccount, super.state.getList(AppDataType.accounts).first?.uuid);
      38            3 :       widget.setState();
      39              :     });
      40              :   }
      41              : 
      42            0 :   Widget _nextButton(BuildContext context, BoxConstraints constraints) => FullSizedButtonWidget(
      43              :         constraints: constraints,
      44            0 :         controller: focus,
      45            0 :         onPressed: () => widget.setState(),
      46            0 :         title: AppLocale.labels.goNextTooltip,
      47              :         icon: Icons.exit_to_app_rounded,
      48              :       );
      49              : 
      50            1 :   @override
      51              :   Widget build(BuildContext context) {
      52            2 :     return Consumer<AppData>(builder: (context, appState, _) {
      53            1 :       state = appState;
      54            3 :       final isCreated = state.getList(AppDataType.accounts).isNotEmpty;
      55            1 :       return Padding(
      56            2 :         padding: EdgeInsets.only(top: ThemeHelper.getIndent(2)),
      57            2 :         child: LayoutBuilder(builder: (context, constraints) {
      58            2 :           if (widget.isFirstBoot) {
      59            3 :             WidgetsBinding.instance.addPostFrameCallback((_) {
      60            3 :               widget.setButton(
      61            1 :                 isCreated ? _nextButton(context, constraints) : buildButton(context, constraints),
      62              :               );
      63              :             });
      64              :             return ThemeHelper.emptyBox;
      65              :           }
      66              :           if (isCreated) {
      67            4 :             return Center(child: Text(AppLocale.labels.isCreated));
      68              :           }
      69            1 :           return buildContent(context, constraints);
      70              :         }),
      71              :       );
      72              :     });
      73              :   }
      74              : }
        

Generated by: LCOV version 2.0-1