New experiment checking method.
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2021-06-04 11:13:52 -07:00
parent 7351bd322a
commit f4f885fcea
12 changed files with 40 additions and 23 deletions

View File

@ -3,4 +3,4 @@ const dev_version = "development";
class EnvironmentConfig {
static const BUILD_VER = String.fromEnvironment('BUILD_VER', defaultValue: dev_version);
static const BUILD_DATE = String.fromEnvironment('BUILD_DATE', defaultValue: "now");
}
}

View File

@ -11,7 +11,7 @@
/// fonts:
/// - asset: assets/fonts/CwtchIcons.ttf
///
///
///
///
import 'package:flutter/widgets.dart';

View File

@ -480,9 +480,9 @@ class MessageState extends ChangeNotifier {
this.error = true;
}
} catch (e) {
this._overlay = -1;
this.loaded = true;
this.malformed = true;
this._overlay = -1;
this.loaded = true;
this.malformed = true;
}
});
}

View File

@ -16,7 +16,8 @@ class Settings extends ChangeNotifier {
Locale locale;
late PackageInfo packageInfo;
OpaqueThemeType theme;
late bool experimentsEnabled;
// explicitly set experiments to false until told otherwise...
bool experimentsEnabled = false;
HashMap<String, bool> experiments = HashMap.identity();
late bool blockUnknownConnections;
@ -38,6 +39,18 @@ class Settings extends ChangeNotifier {
return theme;
}
/// isExperimentEnabled can be used to safely check whether a particular
/// experiment is enabled
bool isExperimentEnabled(String experiment) {
if (this.experimentsEnabled) {
if (this.experiments.containsKey(experiment)) {
// We now know it cannot be null...
return this.experiments[experiment]! == true;
}
}
return false;
}
/// Called by the event bus. When new settings are loaded from a file the JSON will
/// be sent to the function and new settings will be instantiated based on the contents.
handleUpdate(dynamic settings) {

View File

@ -50,8 +50,8 @@ class _AddContactViewState extends State<AddContactView> {
Widget _buildForm() {
ctrlrOnion.text = Provider.of<ProfileInfoState>(context).onion;
/// We display a different number of tabs dependening on the experiment setup
bool groupsEnabled = Provider.of<Settings>(context).experimentsEnabled && Provider.of<Settings>(context).experiments[TapirGroupsExperiment]!;
/// We display a different number of tabs depending on the experiment setup
bool groupsEnabled = Provider.of<Settings>(context).isExperimentEnabled(TapirGroupsExperiment);
return Consumer<ErrorHandler>(builder: (context, globalErrorHandler, child) {
return DefaultTabController(
length: groupsEnabled ? 2 : 1,

View File

@ -142,7 +142,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
SwitchListTile(
title: Text(AppLocalizations.of(context)!.enableGroups, style: TextStyle(color: settings.current().mainTextColor())),
subtitle: Text(AppLocalizations.of(context)!.descriptionExperimentsGroups),
value: settings.experiments.containsKey(TapirGroupsExperiment) && settings.experiments[TapirGroupsExperiment]!,
value: settings.isExperimentEnabled(TapirGroupsExperiment),
onChanged: (bool value) {
if (value) {
settings.enableExperiment(TapirGroupsExperiment);

View File

@ -50,7 +50,10 @@ class _MessageViewState extends State<MessageView> {
//IconButton(icon: Icon(Icons.chat), onPressed: _pushContactSettings),
//IconButton(icon: Icon(Icons.list), onPressed: _pushContactSettings),
//IconButton(icon: Icon(Icons.push_pin), onPressed: _pushContactSettings),
IconButton(icon: Provider.of<ContactInfoState>(context, listen: false).isGroup == true ? Icon(CwtchIcons.group_settings_24px) : Icon(CwtchIcons.peer_settings_24px), tooltip: AppLocalizations.of(context)!.conversationSettings, onPressed: _pushContactSettings),
IconButton(
icon: Provider.of<ContactInfoState>(context, listen: false).isGroup == true ? Icon(CwtchIcons.group_settings_24px) : Icon(CwtchIcons.peer_settings_24px),
tooltip: AppLocalizations.of(context)!.conversationSettings,
onPressed: _pushContactSettings),
],
),
body: Padding(padding: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 108.0), child: MessageList()),

View File

@ -59,10 +59,13 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
Expanded(child: Text(AppLocalizations.of(context)!.titleManageProfiles, style: TextStyle(color: settings.current().mainTextColor())))
]),
actions: [
IconButton(icon: TorIcon(), onPressed: _pushTorStatus, tooltip: Provider.of<TorStatus>(context).progress == 100
? AppLocalizations.of(context)!.networkStatusOnline
: (Provider.of<TorStatus>(context).progress == 0 ? AppLocalizations.of(context)!.networkStatusDisconnected : AppLocalizations.of(context)!.networkStatusAttemptingTor),
),
IconButton(
icon: TorIcon(),
onPressed: _pushTorStatus,
tooltip: Provider.of<TorStatus>(context).progress == 100
? AppLocalizations.of(context)!.networkStatusOnline
: (Provider.of<TorStatus>(context).progress == 0 ? AppLocalizations.of(context)!.networkStatusDisconnected : AppLocalizations.of(context)!.networkStatusAttemptingTor),
),
IconButton(icon: Icon(Icons.bug_report_outlined), onPressed: _setLoggingLevelDebug),
IconButton(
icon: Icon(CwtchIcons.lock_open_24px),

View File

@ -1,7 +1,6 @@
import 'package:cwtch/cwtch_icons_icons.dart';
import 'package:flutter/material.dart';
final Color malformedColor = Color(0xFFE85DA1);
// MalformedBubble is displayed in the case of a malformed message
@ -38,7 +37,7 @@ class MalformedBubbleState extends State<MalformedBubble> {
padding: EdgeInsets.all(4),
child: Icon(
CwtchIcons.favorite_black_24dp_broken,
size: 24,
size: 24,
))),
Center(
widthFactor: 1.0,

View File

@ -31,10 +31,8 @@ class _MessageRowState extends State<MessageRow> {
fromMe = false;
}
Widget wdgBubble = Flexible(
flex: 3,
fit: FlexFit.loose,
child: Provider.of<MessageState>(context).loaded == true ? widgetForOverlay(Provider.of<MessageState>(context).overlay) : MessageLoadingBubble());
Widget wdgBubble =
Flexible(flex: 3, fit: FlexFit.loose, child: Provider.of<MessageState>(context).loaded == true ? widgetForOverlay(Provider.of<MessageState>(context).overlay) : MessageLoadingBubble());
Widget wdgIcons = Icon(Icons.delete_forever_outlined, color: Provider.of<Settings>(context).theme.dropShadowColor());
Widget wdgSpacer = Expanded(child: SizedBox(width: 60, height: 10));
var widgetRow = <Widget>[];

View File

@ -7,7 +7,7 @@ doNothing(String x) {}
// Provides a styled Text Field for use in Form Widgets.
// Callers must provide a text controller, label helper text and a validator.
class CwtchTextField extends StatefulWidget {
CwtchTextField({required this.controller, required this.labelText, this.validator = null, this.autofocus=false, this.onChanged = doNothing});
CwtchTextField({required this.controller, required this.labelText, this.validator = null, this.autofocus = false, this.onChanged = doNothing});
final TextEditingController controller;
final String labelText;
final FormFieldValidator? validator;

View File

@ -17,9 +17,10 @@ class _TorIconState extends State<TorIcon> {
@override
Widget build(BuildContext context) {
return RepaintBoundary(
child: Icon(Provider.of<TorStatus>(context).progress == 0 ? CwtchIcons.onion_off : (Provider.of<TorStatus>(context).progress == 100 ? CwtchIcons.onion_on: CwtchIcons.onion_waiting),
child: Icon(
Provider.of<TorStatus>(context).progress == 0 ? CwtchIcons.onion_off : (Provider.of<TorStatus>(context).progress == 100 ? CwtchIcons.onion_on : CwtchIcons.onion_waiting),
color: Provider.of<Settings>(context).theme.mainTextColor(),
semanticLabel: Provider.of<TorStatus>(context).progress == 100
semanticLabel: Provider.of<TorStatus>(context).progress == 100
? AppLocalizations.of(context)!.networkStatusOnline
: (Provider.of<TorStatus>(context).progress == 0 ? AppLocalizations.of(context)!.networkStatusDisconnected : AppLocalizations.of(context)!.networkStatusAttemptingTor),
));