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:flutter/material.dart'; 15 : import 'package:provider/provider.dart'; 16 : 17 : class AboutTab extends AbstractTab { 18 0 : const AboutTab({ 19 : super.key, 20 : required super.setState, 21 : required super.setButton, 22 : super.isFirstBoot = true, 23 : }); 24 : 25 0 : @override 26 0 : 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 : 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 0 : @override 43 : String getButtonTitle() => ''; 44 : 45 0 : @override 46 : Widget buildContent(BuildContext context, BoxConstraints constraints) { 47 0 : locale = Provider.of<AppLocale>(context, listen: false); 48 0 : design = Provider.of<AppDesign>(context, listen: false); 49 0 : state = Provider.of<AppData>(context, listen: true); 50 : 51 0 : return Column( 52 0 : crossAxisAlignment: AppDesign.getAlignment(), 53 0 : children: [ 54 : ThemeHelper.hIndent2x, 55 0 : InputWrapper.select( 56 0 : title: AppLocale.labels.language, 57 0 : tooltip: AppLocale.labels.language, 58 0 : value: AppLocale.code, 59 0 : options: languages, 60 0 : onChange: (v) => saveLocale(v ?? AppLocale.code), 61 : ), 62 0 : Expanded( 63 0 : child: MarkdownBuilderWrapper( 64 0 : 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 : }