LCOV - code coverage report
Current view: top level - lib/pages/settings/widgets/recover_tab - recover_webdav_form.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 68 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_design.dart';
       5              : import 'package:app_finance/_classes/herald/app_locale.dart';
       6              : import 'package:app_finance/_classes/storage/transaction_log/web_dav_data.dart';
       7              : import 'package:app_finance/_classes/storage/transaction_log/web_dav_protocol.dart';
       8              : import 'package:app_finance/_configs/theme_helper.dart';
       9              : import 'package:app_finance/_ext/build_context_ext.dart';
      10              : import 'package:app_finance/design/form/checkbox_input.dart';
      11              : import 'package:app_finance/design/form/simple_input.dart';
      12              : import 'package:app_finance/design/wrapper/required_widget.dart';
      13              : import 'package:app_finance/pages/settings/widgets/recover_tab/nav_button_widget.dart';
      14              : import 'package:app_finance/pages/settings/widgets/recover_tab/recovery_type.dart';
      15              : import 'package:material_ui/material_ui.dart';
      16              : 
      17              : class RecoverWebdavForm extends StatefulWidget {
      18              :   final Function cbMessage;
      19              :   final Function cbProgress;
      20              :   final Function cbType;
      21              :   final Function cbFinal;
      22              :   final String message;
      23              : 
      24            0 :   const RecoverWebdavForm({
      25              :     super.key,
      26              :     required this.cbMessage,
      27              :     required this.cbProgress,
      28              :     required this.cbType,
      29              :     required this.cbFinal,
      30              :     this.message = '',
      31              :   });
      32              : 
      33            0 :   @override
      34            0 :   RecoverWebdavFormState createState() => RecoverWebdavFormState();
      35              : }
      36              : 
      37              : class RecoverWebdavFormState extends State<RecoverWebdavForm> {
      38              :   late final WebDavProtocol webDav;
      39              :   final username = TextEditingController();
      40              :   final password = TextEditingController();
      41              :   final link = TextEditingController();
      42              :   final path = TextEditingController(text: 'tmp.log');
      43              :   bool isEncrypted = true;
      44              :   bool isCleaned = false;
      45              : 
      46            0 :   @override
      47              :   void initState() {
      48            0 :     webDav = WebDavProtocol(callbackMessage: widget.cbMessage, callbackProgress: widget.cbProgress);
      49            0 :     super.initState();
      50              :   }
      51              : 
      52            0 :   @override
      53              :   Widget build(BuildContext context) {
      54            0 :     final textTheme = context.textTheme;
      55            0 :     return Column(
      56            0 :       crossAxisAlignment: AppDesign.getAlignment(),
      57            0 :       children: [
      58              :         ThemeHelper.hIndent2x,
      59            0 :         NavButtonWidget(
      60            0 :           name: AppLocale.labels.webDav,
      61              :           nav: RecoveryType.none,
      62              :           icon: Icons.arrow_left,
      63            0 :           callback: widget.cbType,
      64              :         ),
      65            0 :         Text(
      66            0 :           widget.message,
      67            0 :           style: textTheme.headlineMedium?.copyWith(color: context.colorScheme.inversePrimary),
      68              :         ),
      69            0 :         RequiredWidget(
      70            0 :           title: AppLocale.labels.link,
      71            0 :           showError: widget.message != '' && link.text.isEmpty,
      72              :         ),
      73            0 :         SimpleInput(
      74            0 :           controller: link,
      75              :           type: TextInputType.url,
      76              :         ),
      77              :         ThemeHelper.hIndent2x,
      78            0 :         RequiredWidget(
      79            0 :           title: AppLocale.labels.username,
      80            0 :           showError: widget.message != '' && username.text.isEmpty,
      81              :         ),
      82            0 :         SimpleInput(
      83            0 :           controller: username,
      84              :         ),
      85              :         ThemeHelper.hIndent2x,
      86            0 :         RequiredWidget(
      87            0 :           title: AppLocale.labels.password,
      88            0 :           showError: widget.message != '' && password.text.isEmpty,
      89              :         ),
      90            0 :         SimpleInput(
      91            0 :           controller: password,
      92              :           type: TextInputType.visiblePassword,
      93              :           obscure: true,
      94              :         ),
      95              :         ThemeHelper.hIndent2x,
      96            0 :         RequiredWidget(
      97            0 :           title: AppLocale.labels.path,
      98            0 :           showError: widget.message != '' && path.text.isEmpty,
      99              :         ),
     100            0 :         SimpleInput(
     101            0 :           controller: path,
     102              :         ),
     103              :         ThemeHelper.hIndent4x,
     104            0 :         SizedBox(
     105              :           width: double.infinity,
     106            0 :           child: FloatingActionButton(
     107              :             heroTag: 'recover_tab_save',
     108            0 :             onPressed: () => webDav.save(WebDavData(
     109            0 :               link: link.text,
     110            0 :               username: username.text,
     111            0 :               password: password.text,
     112            0 :               path: path.text,
     113              :             )),
     114            0 :             tooltip: AppLocale.labels.saveTooltip,
     115            0 :             child: Text(AppLocale.labels.saveTooltip),
     116              :           ),
     117              :         ),
     118              :         ThemeHelper.hIndent4x,
     119            0 :         CheckboxInput(
     120            0 :           label: AppLocale.labels.isEncrypted,
     121            0 :           value: isEncrypted,
     122            0 :           onChanged: (value) => setState(() => isEncrypted = value),
     123              :         ),
     124              :         ThemeHelper.hIndent,
     125            0 :         CheckboxInput(
     126            0 :           label: AppLocale.labels.isCleaned,
     127            0 :           value: isCleaned,
     128            0 :           onChanged: (value) => setState(() => isCleaned = value),
     129              :         ),
     130              :         ThemeHelper.hIndent2x,
     131            0 :         SizedBox(
     132              :           width: double.infinity,
     133            0 :           child: FloatingActionButton(
     134              :             heroTag: 'recover_tab_recover',
     135            0 :             onPressed: () => webDav
     136            0 :                 .load(
     137            0 :                   WebDavData(
     138            0 :                     link: link.text,
     139            0 :                     username: username.text,
     140            0 :                     password: password.text,
     141            0 :                     path: path.text,
     142              :                   ),
     143            0 :                   isEncrypted,
     144            0 :                   isCleaned,
     145              :                 )
     146            0 :                 .then((_) => widget.cbFinal()),
     147            0 :             tooltip: AppLocale.labels.recoveryTooltip,
     148            0 :             child: Text(AppLocale.labels.recoveryTooltip),
     149              :           ),
     150              :         ),
     151              :       ],
     152              :     );
     153              :   }
     154              : }
        

Generated by: LCOV version 2.0-1