LCOV - code coverage report
Current view: top level - lib/pages/settings/widgets/recover_tab - recover_webdav_form.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 68 0.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/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/simple_input.dart';
      11             : import 'package:app_finance/design/wrapper/required_widget.dart';
      12             : import 'package:app_finance/design/wrapper/text_wrapper.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:flutter/material.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 :         Row(
     120           0 :           children: [
     121           0 :             Checkbox(value: isEncrypted, onChanged: (value) => setState(() => isEncrypted = value!)),
     122           0 :             TextWrapper(AppLocale.labels.isEncrypted),
     123             :           ],
     124             :         ),
     125             :         ThemeHelper.hIndent,
     126           0 :         Row(
     127           0 :           children: [
     128           0 :             Checkbox(value: isCleaned, onChanged: (value) => setState(() => isCleaned = value!)),
     129           0 :             TextWrapper(AppLocale.labels.isCleaned),
     130             :           ],
     131             :         ),
     132             :         ThemeHelper.hIndent2x,
     133           0 :         SizedBox(
     134             :           width: double.infinity,
     135           0 :           child: FloatingActionButton(
     136             :             heroTag: 'recover_tab_recover',
     137           0 :             onPressed: () => webDav
     138           0 :                 .load(
     139           0 :                   WebDavData(
     140           0 :                     link: link.text,
     141           0 :                     username: username.text,
     142           0 :                     password: password.text,
     143           0 :                     path: path.text,
     144             :                   ),
     145           0 :                   isEncrypted,
     146           0 :                   isCleaned,
     147             :                 )
     148           0 :                 .then((_) => widget.cbFinal()),
     149           0 :             tooltip: AppLocale.labels.recoveryTooltip,
     150           0 :             child: Text(AppLocale.labels.recoveryTooltip),
     151             :           ),
     152             :         ),
     153             :       ],
     154             :     );
     155             :   }
     156             : }

Generated by: LCOV version 1.14