LCOV - code coverage report
Current view: top level - lib/pages/start/widgets - abstract_tab.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 19 5.3 %
Date: 2024-10-04 11:09:33 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/_configs/theme_helper.dart';
       6             : import 'package:app_finance/design/button/full_sized_button_widget.dart';
       7             : import 'package:flutter/material.dart';
       8             : 
       9             : abstract class AbstractTab<T> extends StatefulWidget {
      10             :   final bool isFirstBoot;
      11             :   final Function() setState;
      12             :   final Function(Widget btn) setButton;
      13             : 
      14           5 :   const AbstractTab({
      15             :     super.key,
      16             :     required this.setState,
      17             :     required this.setButton,
      18             :     required this.isFirstBoot,
      19             :   });
      20             : }
      21             : 
      22             : abstract class AbstractTabState<T extends AbstractTab> extends State<T> {
      23             :   String getButtonTitle();
      24             : 
      25             :   Widget buildContent(BuildContext context, BoxConstraints constraints);
      26             : 
      27           0 :   void updateState() => widget.setState();
      28             : 
      29           0 :   IconData getButtonIcon() => Icons.navigate_next;
      30             : 
      31           0 :   Widget buildButton(BuildContext context, BoxConstraints constraints) {
      32           0 :     return FullSizedButtonWidget(
      33             :       constraints: constraints,
      34           0 :       onPressed: updateState,
      35           0 :       title: getButtonTitle() != ''
      36           0 :           ? '${getButtonTitle()} (${AppLocale.labels.goNextTooltip})'
      37           0 :           : AppLocale.labels.goNextTooltip,
      38           0 :       icon: getButtonIcon(),
      39             :     );
      40             :   }
      41             : 
      42           0 :   @override
      43             :   Widget build(BuildContext context) {
      44           0 :     double indent = ThemeHelper.getIndent(2);
      45           0 :     return LayoutBuilder(builder: (context, constraints) {
      46           0 :       if (widget.isFirstBoot) {
      47           0 :         WidgetsBinding.instance.addPostFrameCallback((_) {
      48           0 :           widget.setButton(buildButton(context, constraints));
      49             :         });
      50             :         return ThemeHelper.emptyBox;
      51             :       }
      52           0 :       return Container(
      53           0 :         margin: EdgeInsets.all(indent),
      54           0 :         child: buildContent(context, constraints),
      55             :       );
      56             :     });
      57             :   }
      58             : }

Generated by: LCOV version 1.14