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 : child: ConstrainedBox(
35 0 : constraints: BoxConstraints(minHeight: viewportConstraints.maxHeight, maxWidth: viewportConstraints.maxWidth),
36 0 : child: Container(
37 0 : color: settings.theme.backgroundPaneColor,
38 0 : child: Column(children: [
39 0 : AboutListTile(
40 : icon: appIcon,
41 0 : applicationIcon: Padding(padding: EdgeInsets.all(5), child: Icon(CwtchIcons.cwtch_knott)),
42 : applicationName: "Cwtch UI",
43 : applicationLegalese: '\u{a9} 2021-2024 Open Privacy Research Society',
44 0 : aboutBoxChildren: <Widget>[
45 0 : Padding(
46 0 : padding: EdgeInsets.fromLTRB(24.0 + 10.0 + (appIcon.size ?? 24.0), 16.0, 0.0, 0.0),
47 : // About has 24 padding (ln 389) and there appears to be another 10 of padding in the widget
48 0 : child: SelectableText(AppLocalizations.of(context)!.versionBuilddate.replaceAll("%1", EnvironmentConfig.BUILD_VER).replaceAll("%2", EnvironmentConfig.BUILD_DATE)),
49 : )
50 : ]),
51 0 : SwitchListTile(
52 : // TODO: Translate, Remove, OR Hide Prior to Release
53 0 : title: Text(AppLocalizations.of(context)!.settingsExperimentsShowPerformanceTitle),
54 0 : subtitle: Text(AppLocalizations.of(context)!.settingsExperimentsShowPerformanceDescription),
55 0 : value: settings.profileMode,
56 0 : onChanged: (bool value) {
57 0 : setState(() {
58 : if (value) {
59 0 : settings.profileMode = value;
60 : } else {
61 0 : settings.profileMode = value;
62 : }
63 : });
64 : },
65 0 : activeTrackColor: settings.theme.defaultButtonActiveColor,
66 0 : inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
67 0 : secondary: Icon(Icons.bar_chart, color: settings.current().mainTextColor),
68 : ),
69 0 : Visibility(
70 0 : visible: EnvironmentConfig.BUILD_VER == dev_version && !Platform.isAndroid,
71 0 : child: SwitchListTile(
72 0 : title: Text("Show Semantic Debugger"),
73 0 : subtitle: Text("Show Accessibility Debugging View"),
74 0 : value: settings.useSemanticDebugger,
75 0 : onChanged: (bool value) {
76 : if (value) {
77 0 : settings.useSemanticDebugger = value;
78 : } else {
79 0 : settings.useSemanticDebugger = value;
80 : }
81 0 : saveSettings(context);
82 : },
83 0 : activeTrackColor: settings.theme.defaultButtonActiveColor,
84 0 : inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
85 0 : secondary: Icon(Icons.settings_accessibility, color: settings.current().mainTextColor),
86 : )),
87 0 : Visibility(
88 0 : visible: EnvironmentConfig.BUILD_VER == dev_version && !Platform.isAndroid,
89 0 : child: FutureBuilder(
90 0 : future: EnvironmentConfig.BUILD_VER != dev_version || Platform.isAndroid ? null : Provider.of<FlwtchState>(context).cwtch.GetDebugInfo(),
91 0 : builder: (context, snapshot) {
92 0 : if (snapshot.hasData) {
93 0 : return Column(
94 0 : children: [
95 0 : Text("libCwtch Debug Info: " + snapshot.data.toString()),
96 0 : Text("Message Cache Size (Mb): " + (Provider.of<FlwtchState>(context).profs.cacheMemUsage() / (1024 * 1024)).toString())
97 : ],
98 : );
99 : } else {
100 0 : return Container();
101 : }
102 : },
103 : ),
104 : ),
105 0 : Visibility(
106 0 : visible: EnvironmentConfig.BUILD_VER == dev_version,
107 0 : child: FutureBuilder(
108 0 : future: Provider.of<FlwtchState>(context).cwtch.PlatformChannelInfo(),
109 0 : builder: (context, snapshot) {
110 0 : if (snapshot.hasData) {
111 0 : HashMap<String, String> data = snapshot.data as HashMap<String, String>;
112 0 : return getPlatformInfo(settings, data);
113 : }
114 0 : return Container();
115 : }))
116 : ])))));
117 : });
118 : });
119 : }
120 :
121 0 : getPlatformInfo(settings, HashMap<String, String> platformChannelInfo) {
122 0 : var sortedKeys = platformChannelInfo.keys.toList();
123 0 : sortedKeys.sort();
124 0 : var widgets = List<Widget>.empty(growable: true);
125 0 : sortedKeys.forEach((element) {
126 0 : widgets.add(ListTile(
127 0 : leading: Icon(Icons.android, color: settings.current().mainTextColor),
128 0 : title: Text(element),
129 0 : subtitle: Text(platformChannelInfo[element]!),
130 : ));
131 : });
132 0 : return Column(
133 : children: widgets,
134 : );
135 : }
136 :
137 : // TODO: deprecated ?
138 : /// Construct a version string from Package Info
139 0 : String constructVersionString(PackageInfo pinfo) {
140 0 : return pinfo.version + "." + pinfo.buildNumber;
141 : }
142 : }
|