LCOV - code coverage report
Current view: top level - lib/pages/start/widgets - about_tab.dart Coverage Total Hit
Test: lcov.info Lines: 70.4 % 27 19
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/app_data.dart';
       7              : import 'package:app_finance/_mixins/launcher_mixin.dart';
       8              : import 'package:app_finance/design/form/list_selector_item.dart';
       9              : import 'package:app_finance/_configs/theme_helper.dart';
      10              : import 'package:app_finance/design/wrapper/input_wrapper.dart';
      11              : import 'package:app_finance/design/wrapper/markdown_builder_wrapper.dart';
      12              : import 'package:app_finance/l10n/index.dart';
      13              : import 'package:app_finance/pages/start/widgets/abstract_tab.dart';
      14              : import 'package:material_ui/material_ui.dart';
      15              : import 'package:provider/provider.dart';
      16              : 
      17              : class AboutTab extends AbstractTab {
      18            1 :   const AboutTab({
      19              :     super.key,
      20              :     required super.setState,
      21              :     required super.setButton,
      22              :     super.isFirstBoot = true,
      23              :   });
      24              : 
      25            1 :   @override
      26            1 :   AboutTabState createState() => AboutTabState();
      27              : }
      28              : 
      29              : class AboutTabState<T extends AboutTab> extends AbstractTabState<T> with LauncherMixin {
      30              :   late AppLocale locale;
      31              :   late AppDesign design;
      32              :   late AppData state;
      33              : 
      34            2 :   final languages = languageList.map((e) => ListSelectorItem(id: e.id, name: e.name)).toList();
      35              : 
      36            0 :   Future<void> saveLocale(String value) async {
      37            0 :     await locale.set(value);
      38            0 :     await design.set(AppDesign.fromLocale(AppLocale.fromCode(value)));
      39            0 :     setState(() {});
      40              :   }
      41              : 
      42            1 :   @override
      43              :   String getButtonTitle() => '';
      44              : 
      45            1 :   @override
      46              :   Widget buildContent(BuildContext context, BoxConstraints constraints) {
      47            2 :     locale = Provider.of<AppLocale>(context, listen: false);
      48            2 :     design = Provider.of<AppDesign>(context, listen: false);
      49            2 :     state = Provider.of<AppData>(context, listen: true);
      50              : 
      51            1 :     return Column(
      52            1 :       crossAxisAlignment: AppDesign.getAlignment(),
      53            1 :       children: [
      54              :         ThemeHelper.hIndent2x,
      55            1 :         InputWrapper.select(
      56            2 :           title: AppLocale.labels.language,
      57            2 :           tooltip: AppLocale.labels.language,
      58              :           value: AppLocale.code,
      59            1 :           options: languages,
      60            0 :           onChange: (v) => saveLocale(v ?? AppLocale.code),
      61              :         ),
      62            1 :         Expanded(
      63            1 :           child: MarkdownBuilderWrapper(
      64            3 :             url: './assets/l10n/about_${locale.value!}.md',
      65            0 :             onTapLink: (_, link, __) => link != null && link.contains('https://')
      66            0 :                 ? openURL(link)
      67            0 :                 : saveLocale(link?.replaceFirst('./about_', '').replaceFirst('.md', '') ?? AppLocale.code),
      68              :           ),
      69              :         ),
      70              :       ],
      71              :     );
      72              :   }
      73              : }
        

Generated by: LCOV version 2.0-1