LCOV - code coverage report
Current view: top level - lib/pages/settings/widgets - recover_tab.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 51 2.0 %
Date: 2024-10-04 11:12:13 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_design.dart';
       5             : import 'package:app_finance/_classes/herald/app_locale.dart';
       6             : import 'package:app_finance/_classes/controller/focus_controller.dart';
       7             : import 'package:app_finance/_classes/storage/app_data.dart';
       8             : import 'package:app_finance/_configs/theme_helper.dart';
       9             : import 'package:app_finance/design/generic/loading_widget.dart';
      10             : import 'package:app_finance/pages/settings/widgets/recover_tab/nav_button_widget.dart';
      11             : import 'package:app_finance/pages/settings/widgets/recover_tab/recover_file_form.dart';
      12             : import 'package:app_finance/pages/settings/widgets/recover_tab/recover_webdav_form.dart';
      13             : import 'package:app_finance/pages/settings/widgets/recover_tab/recovery_type.dart';
      14             : import 'package:app_finance/design/wrapper/single_scroll_wrapper.dart';
      15             : import 'package:flutter/material.dart';
      16             : import 'package:provider/provider.dart';
      17             : 
      18             : class RecoverTab extends StatefulWidget {
      19           1 :   const RecoverTab({super.key});
      20             : 
      21           0 :   @override
      22           0 :   SyncTabState createState() => SyncTabState();
      23             : }
      24             : 
      25             : class SyncTabState extends State<RecoverTab> {
      26             :   late FocusController focus;
      27             :   late AppData state;
      28             :   String message = '';
      29             :   bool inProgress = false;
      30             :   RecoveryType type = RecoveryType.none;
      31             : 
      32           0 :   @override
      33             :   void initState() {
      34           0 :     focus = FocusController();
      35           0 :     super.initState();
      36             :   }
      37             : 
      38           0 :   @override
      39             :   void dispose() {
      40           0 :     focus.dispose();
      41           0 :     super.dispose();
      42             :   }
      43             : 
      44           0 :   void cbType(RecoveryType value) => setState(() {
      45           0 :         type = value;
      46           0 :         message = '';
      47             :       });
      48             : 
      49           0 :   void cbMessage(String mssg) => setState(() => message = mssg);
      50             : 
      51           0 :   void cbProgress(bool state) => setState(() => inProgress = state);
      52             : 
      53           0 :   @override
      54             :   Widget build(BuildContext context) {
      55           0 :     double indent = ThemeHelper.getIndent(2);
      56             :     Function form;
      57           0 :     if (inProgress) {
      58           0 :       form = () => Column(
      59           0 :             crossAxisAlignment: AppDesign.getAlignment(),
      60           0 :             children: [
      61           0 :               SizedBox(height: ThemeHelper.getIndent(12)),
      62           0 :               LoadingWidget(isLoading: inProgress),
      63             :             ],
      64             :           );
      65             :     } else {
      66           0 :       form = () => switch (type) {
      67           0 :             RecoveryType.webdav => RecoverWebdavForm(
      68           0 :                 cbFinal: state.flush,
      69           0 :                 cbMessage: cbMessage,
      70           0 :                 cbProgress: cbProgress,
      71           0 :                 cbType: cbType,
      72           0 :                 message: message,
      73             :               ),
      74           0 :             RecoveryType.file => RecoverFileForm(
      75           0 :                 cbFinal: state.flush,
      76           0 :                 cbMessage: cbMessage,
      77           0 :                 cbProgress: cbProgress,
      78           0 :                 cbType: cbType,
      79           0 :                 message: message,
      80             :               ),
      81           0 :             _ => Column(
      82           0 :                 crossAxisAlignment: AppDesign.getAlignment(),
      83           0 :                 children: [
      84             :                   ThemeHelper.hIndent2x,
      85           0 :                   NavButtonWidget(
      86           0 :                     name: AppLocale.labels.webDav,
      87             :                     nav: RecoveryType.webdav,
      88           0 :                     callback: cbType,
      89             :                   ),
      90             :                   ThemeHelper.hIndent2x,
      91           0 :                   NavButtonWidget(
      92           0 :                     name: AppLocale.labels.transactionFile,
      93             :                     nav: RecoveryType.file,
      94           0 :                     callback: cbType,
      95             :                   ),
      96             :                 ],
      97             :               ),
      98             :           };
      99             :     }
     100           0 :     return Consumer<AppData>(builder: (context, appState, _) {
     101           0 :       state = appState;
     102           0 :       return SingleScrollWrapper(
     103           0 :         controller: focus,
     104           0 :         child: Padding(
     105           0 :           padding: EdgeInsets.all(indent),
     106           0 :           child: form(),
     107             :         ),
     108             :       );
     109             :     });
     110             :   }
     111             : }

Generated by: LCOV version 1.14