LCOV - code coverage report
Current view: top level - lib/views - globalsettingsaboutview.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 78 0.0 %
Date: 2024-02-26 20:09:01 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:collection';
       2             : import 'dart:io';
       3             : 
       4             : import 'package:flutter/material.dart';
       5             : import 'package:package_info_plus/package_info_plus.dart';
       6             : import 'package:provider/provider.dart';
       7             : import 'package:flutter_gen/gen_l10n/app_localizations.dart';
       8             : 
       9             : import '../config.dart';
      10             : import '../cwtch_icons_icons.dart';
      11             : import '../main.dart';
      12             : import '../settings.dart';
      13             : import 'globalsettingsview.dart';
      14             : 
      15             : class GlobalSettingsAboutView extends StatefulWidget {
      16           0 :   @override
      17           0 :   _GlobalSettingsAboutViewState createState() => _GlobalSettingsAboutViewState();
      18             : }
      19             : 
      20             : class _GlobalSettingsAboutViewState extends State<GlobalSettingsAboutView> {
      21             :   ScrollController settingsListScrollController = ScrollController();
      22             : 
      23           0 :   Widget build(BuildContext context) {
      24           0 :     return Consumer<Settings>(builder: (ccontext, settings, child) {
      25           0 :       return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
      26           0 :         var appIcon = Icon(Icons.info, color: settings.current().mainTextColor);
      27           0 :         return Scrollbar(
      28           0 :             key: Key("AboutSettingsView"),
      29             :             trackVisibility: true,
      30           0 :             controller: settingsListScrollController,
      31           0 :             child: SingleChildScrollView(
      32             :                 clipBehavior: Clip.antiAlias,
      33           0 :                 controller: settingsListScrollController,
      34           0 :                 padding: EdgeInsets.symmetric(vertical: 0, horizontal: 20),
      35           0 :                 child: ConstrainedBox(
      36           0 :                     constraints: BoxConstraints(
      37           0 :                       minHeight: viewportConstraints.maxHeight,
      38             :                     ),
      39           0 :                     child: Column(children: [
      40           0 :                       AboutListTile(
      41             :                           icon: appIcon,
      42           0 :                           applicationIcon: Padding(padding: EdgeInsets.all(5), child: Icon(CwtchIcons.cwtch_knott)),
      43             :                           applicationName: "Cwtch UI",
      44             :                           applicationLegalese: '\u{a9} 2021-2023 Open Privacy Research Society',
      45           0 :                           aboutBoxChildren: <Widget>[
      46           0 :                             Padding(
      47           0 :                               padding: EdgeInsets.fromLTRB(24.0 + 10.0 + (appIcon.size ?? 24.0), 16.0, 0.0, 0.0),
      48             :                               // About has 24 padding (ln 389) and there appears to be another 10 of padding in the widget
      49           0 :                               child: SelectableText(AppLocalizations.of(context)!.versionBuilddate.replaceAll("%1", EnvironmentConfig.BUILD_VER).replaceAll("%2", EnvironmentConfig.BUILD_DATE)),
      50             :                             )
      51             :                           ]),
      52           0 :                       SwitchListTile(
      53             :                         // TODO: Translate, Remove, OR Hide Prior to Release
      54           0 :                         title: Text(AppLocalizations.of(context)!.settingsExperimentsShowPerformanceTitle),
      55           0 :                         subtitle: Text(AppLocalizations.of(context)!.settingsExperimentsShowPerformanceDescription),
      56           0 :                         value: settings.profileMode,
      57           0 :                         onChanged: (bool value) {
      58           0 :                           setState(() {
      59             :                             if (value) {
      60           0 :                               settings.profileMode = value;
      61             :                             } else {
      62           0 :                               settings.profileMode = value;
      63             :                             }
      64             :                           });
      65             :                         },
      66           0 :                         activeTrackColor: settings.theme.defaultButtonActiveColor,
      67           0 :                         inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
      68           0 :                         secondary: Icon(Icons.bar_chart, color: settings.current().mainTextColor),
      69             :                       ),
      70           0 :                       Visibility(
      71           0 :                           visible: EnvironmentConfig.BUILD_VER == dev_version && !Platform.isAndroid,
      72           0 :                           child: SwitchListTile(
      73           0 :                             title: Text("Show Semantic Debugger"),
      74           0 :                             subtitle: Text("Show Accessibility Debugging View"),
      75           0 :                             value: settings.useSemanticDebugger,
      76           0 :                             onChanged: (bool value) {
      77             :                               if (value) {
      78           0 :                                 settings.useSemanticDebugger = value;
      79             :                               } else {
      80           0 :                                 settings.useSemanticDebugger = value;
      81             :                               }
      82           0 :                               saveSettings(context);
      83             :                             },
      84           0 :                             activeTrackColor: settings.theme.defaultButtonActiveColor,
      85           0 :                             inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
      86           0 :                             secondary: Icon(Icons.settings_accessibility, color: settings.current().mainTextColor),
      87             :                           )),
      88           0 :                       Visibility(
      89           0 :                         visible: EnvironmentConfig.BUILD_VER == dev_version && !Platform.isAndroid,
      90           0 :                         child: FutureBuilder(
      91           0 :                           future: EnvironmentConfig.BUILD_VER != dev_version || Platform.isAndroid ? null : Provider.of<FlwtchState>(context).cwtch.GetDebugInfo(),
      92           0 :                           builder: (context, snapshot) {
      93           0 :                             if (snapshot.hasData) {
      94           0 :                               return Column(
      95           0 :                                 children: [
      96           0 :                                   Text("libCwtch Debug Info: " + snapshot.data.toString()),
      97           0 :                                   Text("Message Cache Size (Mb): " + (Provider.of<FlwtchState>(context).profs.cacheMemUsage() / (1024 * 1024)).toString())
      98             :                                 ],
      99             :                               );
     100             :                             } else {
     101           0 :                               return Container();
     102             :                             }
     103             :                           },
     104             :                         ),
     105             :                       ),
     106           0 :                       Visibility(
     107           0 :                           visible: EnvironmentConfig.BUILD_VER == dev_version,
     108           0 :                           child: FutureBuilder(
     109           0 :                               future: Provider.of<FlwtchState>(context).cwtch.PlatformChannelInfo(),
     110           0 :                               builder: (context, snapshot) {
     111           0 :                                 if (snapshot.hasData) {
     112           0 :                                   HashMap<String, String> data = snapshot.data as HashMap<String, String>;
     113           0 :                                   return getPlatformInfo(settings, data);
     114             :                                 }
     115           0 :                                 return Container();
     116             :                               }))
     117             :                     ]))));
     118             :       });
     119             :     });
     120             :   }
     121             : 
     122           0 :   getPlatformInfo(settings, HashMap<String, String> platformChannelInfo) {
     123           0 :     var sortedKeys = platformChannelInfo.keys.toList();
     124           0 :     sortedKeys.sort();
     125           0 :     var widgets = List<Widget>.empty(growable: true);
     126           0 :     sortedKeys.forEach((element) {
     127           0 :       widgets.add(ListTile(
     128           0 :         leading: Icon(Icons.android, color: settings.current().mainTextColor),
     129           0 :         title: Text(element),
     130           0 :         subtitle: Text(platformChannelInfo[element]!),
     131             :       ));
     132             :     });
     133           0 :     return Column(
     134             :       children: widgets,
     135             :     );
     136             :   }
     137             : 
     138             :   // TODO: deprecated ?
     139             :   /// Construct a version string from Package Info
     140           0 :   String constructVersionString(PackageInfo pinfo) {
     141             :     if (pinfo == null) {
     142             :       return "";
     143             :     }
     144           0 :     return pinfo.version + "." + pinfo.buildNumber;
     145             :   }
     146             : }

Generated by: LCOV version 1.14