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