formatting with -l 200
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Dan Ballard 2024-02-02 18:08:21 -08:00 committed by Gitea
parent a8c957e679
commit 74a9656216
9 changed files with 641 additions and 999 deletions

View File

@ -57,7 +57,6 @@ class CwtchGomobile implements Cwtch {
cwtchNotifier.setMessageSeenCallback((String profile, int conversation, DateTime time) => {this.SetConversationAttribute(profile, conversation, LastMessageSeenTimeKey, time.toIso8601String())}); cwtchNotifier.setMessageSeenCallback((String profile, int conversation, DateTime time) => {this.SetConversationAttribute(profile, conversation, LastMessageSeenTimeKey, time.toIso8601String())});
androidHomeDirectory = getApplicationDocumentsDirectory(); androidHomeDirectory = getApplicationDocumentsDirectory();
androidLibraryDir = appInfoPlatform.invokeMethod('getNativeLibDir'); androidLibraryDir = appInfoPlatform.invokeMethod('getNativeLibDir');
// Method channel to receive libcwtch-go events via Kotlin and dispatch them to _handleAppbusEvent (sends to cwtchNotifier) // Method channel to receive libcwtch-go events via Kotlin and dispatch them to _handleAppbusEvent (sends to cwtchNotifier)

View File

@ -132,7 +132,9 @@ abstract class OpaqueThemeType {
get chatImageColor => red; get chatImageColor => red;
get chatImage => null; get chatImage => null;
ImageProvider loadImage(String key, {BuildContext? context}) { return AssetImage(""); } ImageProvider loadImage(String key, {BuildContext? context}) {
return AssetImage("");
}
// Sizes // Sizes
double contactOnionTextSize() { double contactOnionTextSize() {
@ -199,7 +201,6 @@ ThemeData mkThemeData(Settings opaque) {
)), )),
), ),
), ),
scrollbarTheme: ScrollbarThemeData(thumbVisibility: MaterialStateProperty.all(false), thumbColor: MaterialStateProperty.all(opaque.current().scrollbarDefaultColor)), scrollbarTheme: ScrollbarThemeData(thumbVisibility: MaterialStateProperty.all(false), thumbColor: MaterialStateProperty.all(opaque.current().scrollbarDefaultColor)),
tabBarTheme: TabBarTheme( tabBarTheme: TabBarTheme(
labelColor: opaque.current().mainTextColor, labelColor: opaque.current().mainTextColor,
@ -250,14 +251,10 @@ ThemeData mkThemeData(Settings opaque) {
textSelectionTheme: TextSelectionThemeData( textSelectionTheme: TextSelectionThemeData(
cursorColor: opaque.current().defaultButtonActiveColor, selectionColor: opaque.current().defaultButtonActiveColor, selectionHandleColor: opaque.current().defaultButtonActiveColor), cursorColor: opaque.current().defaultButtonActiveColor, selectionColor: opaque.current().defaultButtonActiveColor, selectionHandleColor: opaque.current().defaultButtonActiveColor),
popupMenuTheme: PopupMenuThemeData( popupMenuTheme: PopupMenuThemeData(
color: opaque color: opaque.current().backgroundPaneColor.withOpacity(0.9),
.current()
.backgroundPaneColor
.withOpacity(0.9),
), ),
snackBarTheme: SnackBarThemeData( snackBarTheme: SnackBarThemeData(
backgroundColor: opaque.current().snackbarBackgroundColor, backgroundColor: opaque.current().snackbarBackgroundColor,
contentTextStyle: TextStyle(color: opaque.current().snackbarTextColor), contentTextStyle: TextStyle(color: opaque.current().snackbarTextColor),
) ));
);
} }

View File

@ -41,7 +41,6 @@ Future<Map<String, Map<String, OpaqueThemeType>>> loadBuiltinThemes() async {
} }
Future<Map<String, Map<String, OpaqueThemeType>>> loadCustomThemes(String themesDirPath) async { Future<Map<String, Map<String, OpaqueThemeType>>> loadCustomThemes(String themesDirPath) async {
Map<String, Map<String, OpaqueThemeType>> themes = Map(); Map<String, Map<String, OpaqueThemeType>> themes = Map();
Directory themesDir = Directory(themesDirPath); Directory themesDir = Directory(themesDirPath);
@ -97,7 +96,6 @@ Future<Map<String, OpaqueThemeType>?> loadFileYamlTheme(String themefile, String
return loadYamlTheme(yml, assetsDir); return loadYamlTheme(yml, assetsDir);
} }
Future<Map<String, OpaqueThemeType>?> loadYamlTheme(YamlMap yml, [String? assetsDir]) async { Future<Map<String, OpaqueThemeType>?> loadYamlTheme(YamlMap yml, [String? assetsDir]) async {
Map<String, OpaqueThemeType> subthemes = Map(); Map<String, OpaqueThemeType> subthemes = Map();
if ((yml["themes"] as YamlMap).containsKey(mode_dark)) { if ((yml["themes"] as YamlMap).containsKey(mode_dark)) {
@ -219,10 +217,7 @@ class YmlTheme extends OpaqueThemeType {
} }
if (context != null) { if (context != null) {
File af = File(path.join(Provider File af = File(path.join(Provider.of<FlwtchState>(context, listen: false).cwtch.getAssetsDir(), key));
.of<FlwtchState>(context, listen: false)
.cwtch
.getAssetsDir(), key));
if (af.existsSync()) { if (af.existsSync()) {
return FileImage(af); return FileImage(af);
} }

View File

@ -19,16 +19,12 @@ class GlobalSettingsAboutView extends StatefulWidget {
} }
class _GlobalSettingsAboutViewState extends State<GlobalSettingsAboutView> { class _GlobalSettingsAboutViewState extends State<GlobalSettingsAboutView> {
ScrollController settingsListScrollController = ScrollController(); ScrollController settingsListScrollController = ScrollController();
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<Settings>(builder: (ccontext, settings, child) { return Consumer<Settings>(builder: (ccontext, settings, child) {
return LayoutBuilder( return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
builder: (BuildContext context, BoxConstraints viewportConstraints) { var appIcon = Icon(Icons.info, color: settings.current().mainTextColor);
var appIcon = Icon(Icons.info, color: settings
.current()
.mainTextColor);
return Scrollbar( return Scrollbar(
key: Key("AboutSettingsView"), key: Key("AboutSettingsView"),
trackVisibility: true, trackVisibility: true,
@ -44,34 +40,20 @@ class _GlobalSettingsAboutViewState extends State<GlobalSettingsAboutView> {
child: Column(children: [ child: Column(children: [
AboutListTile( AboutListTile(
icon: appIcon, icon: appIcon,
applicationIcon: Padding( applicationIcon: Padding(padding: EdgeInsets.all(5), child: Icon(CwtchIcons.cwtch_knott)),
padding: EdgeInsets.all(5),
child: Icon(CwtchIcons.cwtch_knott)),
applicationName: "Cwtch UI", applicationName: "Cwtch UI",
applicationLegalese: applicationLegalese: '\u{a9} 2021-2023 Open Privacy Research Society',
'\u{a9} 2021-2023 Open Privacy Research Society',
aboutBoxChildren: <Widget>[ aboutBoxChildren: <Widget>[
Padding( Padding(
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(24.0 + 10.0 + (appIcon.size ?? 24.0), 16.0, 0.0, 0.0),
24.0 + 10.0 + (appIcon.size ?? 24.0),
16.0,
0.0,
0.0),
// About has 24 padding (ln 389) and there appears to be another 10 of padding in the widget // About has 24 padding (ln 389) and there appears to be another 10 of padding in the widget
child: SelectableText( child: SelectableText(AppLocalizations.of(context)!.versionBuilddate.replaceAll("%1", EnvironmentConfig.BUILD_VER).replaceAll("%2", EnvironmentConfig.BUILD_DATE)),
AppLocalizations.of(context)!
.versionBuilddate
.replaceAll(
"%1", EnvironmentConfig.BUILD_VER)
.replaceAll("%2",
EnvironmentConfig.BUILD_DATE)),
) )
]), ]),
SwitchListTile( SwitchListTile(
// TODO: Translate, Remove, OR Hide Prior to Release // TODO: Translate, Remove, OR Hide Prior to Release
title: Text("Show Performance Overlay"), title: Text("Show Performance Overlay"),
subtitle: subtitle: Text("Display an overlay graph of render time."),
Text("Display an overlay graph of render time."),
value: settings.profileMode, value: settings.profileMode,
onChanged: (bool value) { onChanged: (bool value) {
setState(() { setState(() {
@ -82,23 +64,15 @@ class _GlobalSettingsAboutViewState extends State<GlobalSettingsAboutView> {
} }
}); });
}, },
activeTrackColor: activeTrackColor: settings.theme.defaultButtonActiveColor,
settings.theme.defaultButtonActiveColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: secondary: Icon(Icons.bar_chart, color: settings.current().mainTextColor),
settings.theme.defaultButtonDisabledColor,
secondary: Icon(Icons.bar_chart,
color: settings
.current()
.mainTextColor),
), ),
Visibility( Visibility(
visible: visible: EnvironmentConfig.BUILD_VER == dev_version && !Platform.isAndroid,
EnvironmentConfig.BUILD_VER == dev_version &&
!Platform.isAndroid,
child: SwitchListTile( child: SwitchListTile(
title: Text("Show Semantic Debugger"), title: Text("Show Semantic Debugger"),
subtitle: subtitle: Text("Show Accessibility Debugging View"),
Text("Show Accessibility Debugging View"),
value: settings.useSemanticDebugger, value: settings.useSemanticDebugger,
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
@ -108,40 +82,20 @@ class _GlobalSettingsAboutViewState extends State<GlobalSettingsAboutView> {
} }
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: activeTrackColor: settings.theme.defaultButtonActiveColor,
settings.theme.defaultButtonActiveColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: secondary: Icon(Icons.settings_accessibility, color: settings.current().mainTextColor),
settings.theme.defaultButtonDisabledColor,
secondary: Icon(Icons.settings_accessibility,
color: settings
.current()
.mainTextColor),
)), )),
Visibility( Visibility(
visible: EnvironmentConfig.BUILD_VER == dev_version && visible: EnvironmentConfig.BUILD_VER == dev_version && !Platform.isAndroid,
!Platform.isAndroid,
child: FutureBuilder( child: FutureBuilder(
future: future: EnvironmentConfig.BUILD_VER != dev_version || Platform.isAndroid ? null : Provider.of<FlwtchState>(context).cwtch.GetDebugInfo(),
EnvironmentConfig.BUILD_VER != dev_version ||
Platform.isAndroid
? null
: Provider
.of<FlwtchState>(context)
.cwtch
.GetDebugInfo(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
return Column( return Column(
children: [ children: [
Text("libCwtch Debug Info: " + Text("libCwtch Debug Info: " + snapshot.data.toString()),
snapshot.data.toString()), Text("Message Cache Size (Mb): " + (Provider.of<FlwtchState>(context).profs.cacheMemUsage() / (1024 * 1024)).toString())
Text("Message Cache Size (Mb): " +
(Provider
.of<FlwtchState>(context)
.profs
.cacheMemUsage() /
(1024 * 1024))
.toString())
], ],
); );
} else { } else {
@ -153,14 +107,10 @@ class _GlobalSettingsAboutViewState extends State<GlobalSettingsAboutView> {
Visibility( Visibility(
visible: EnvironmentConfig.BUILD_VER == dev_version, visible: EnvironmentConfig.BUILD_VER == dev_version,
child: FutureBuilder( child: FutureBuilder(
future: Provider future: Provider.of<FlwtchState>(context).cwtch.PlatformChannelInfo(),
.of<FlwtchState>(context)
.cwtch
.PlatformChannelInfo(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
HashMap<String, String> data = snapshot.data HashMap<String, String> data = snapshot.data as HashMap<String, String>;
as HashMap<String, String>;
return getPlatformInfo(settings, data); return getPlatformInfo(settings, data);
} }
return Container(); return Container();

View File

@ -27,8 +27,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<Settings>(builder: (ccontext, settings, child) { return Consumer<Settings>(builder: (ccontext, settings, child) {
return LayoutBuilder( return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return Scrollbar( return Scrollbar(
key: Key("AppearanceSettingsView"), key: Key("AppearanceSettingsView"),
trackVisibility: true, trackVisibility: true,
@ -43,91 +42,57 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
), ),
child: Column(children: [ child: Column(children: [
ListTile( ListTile(
title: Text( title: Text(AppLocalizations.of(context)!.settingLanguage),
AppLocalizations.of(context)!.settingLanguage), leading: Icon(CwtchIcons.change_language, color: settings.current().mainTextColor),
leading: Icon(CwtchIcons.change_language,
color: settings
.current()
.mainTextColor),
trailing: Container( trailing: Container(
width: MediaQuery width: MediaQuery.of(context).size.width / 4,
.of(context)
.size
.width / 4,
child: DropdownButton( child: DropdownButton(
key: Key("languagelist"), key: Key("languagelist"),
isExpanded: true, isExpanded: true,
value: Provider value: Provider.of<Settings>(context).locale.toString(),
.of<Settings>(context)
.locale
.toString(),
onChanged: (String? newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
EnvironmentConfig.debugLog( EnvironmentConfig.debugLog("setting language: $newValue");
"setting language: $newValue");
settings.switchLocaleByCode(newValue!); settings.switchLocaleByCode(newValue!);
saveSettings(context); saveSettings(context);
}); });
}, },
items: AppLocalizations.supportedLocales items: AppLocalizations.supportedLocales.map<DropdownMenuItem<String>>((Locale value) {
.map<DropdownMenuItem<String>>(
(Locale value) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
value: value.toString(), value: value.toString(),
child: Text( child: Text(
key: Key("dropdownLanguage" + key: Key("dropdownLanguage" + value.languageCode),
value.languageCode), getLanguageFull(context, value.languageCode, value.countryCode),
getLanguageFull( style: settings.scaleFonts(defaultDropDownMenuItemTextStyle),
context,
value.languageCode,
value.countryCode),
style: settings.scaleFonts(
defaultDropDownMenuItemTextStyle),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
); );
}).toList()))), }).toList()))),
SwitchListTile( SwitchListTile(
title: title: Text(AppLocalizations.of(context)!.settingTheme),
Text(AppLocalizations.of(context)!.settingTheme), value: settings.current().mode == mode_light,
value: settings
.current()
.mode == mode_light,
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
settings.setTheme( settings.setTheme(settings.theme.theme, mode_light);
settings.theme.theme, mode_light);
} else { } else {
settings.setTheme( settings.setTheme(settings.theme.theme, mode_dark);
settings.theme.theme, mode_dark);
} }
// Save Settings... // Save Settings...
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: settings.theme.defaultButtonColor, activeTrackColor: settings.theme.defaultButtonColor,
inactiveTrackColor: inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
settings.theme.defaultButtonDisabledColor, secondary: Icon(CwtchIcons.change_theme, color: settings.current().mainTextColor),
secondary: Icon(CwtchIcons.change_theme,
color: settings
.current()
.mainTextColor),
), ),
ListTile( ListTile(
title: Text( title: Text(AppLocalizations.of(context)!.themeColorLabel),
AppLocalizations.of(context)!.themeColorLabel),
trailing: Container( trailing: Container(
width: MediaQuery width: MediaQuery.of(context).size.width / 4,
.of(context)
.size
.width / 4,
child: DropdownButton<String>( child: DropdownButton<String>(
key: Key("DropdownTheme"), key: Key("DropdownTheme"),
isExpanded: true, isExpanded: true,
value: Provider value: Provider.of<Settings>(context).theme.theme,
.of<Settings>(context)
.theme
.theme,
onChanged: (String? newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
settings.setTheme(newValue!, settings.theme.mode); settings.setTheme(newValue!, settings.theme.mode);
@ -189,128 +154,72 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
), ),
ListTile( ListTile(
title: Text(AppLocalizations.of(context)!.settingUIColumnPortrait), title: Text(AppLocalizations.of(context)!.settingUIColumnPortrait),
leading: Icon(Icons.table_chart, color: settings leading: Icon(Icons.table_chart, color: settings.current().mainTextColor),
.current()
.mainTextColor),
trailing: Container( trailing: Container(
width: MediaQuery width: MediaQuery.of(context).size.width / 4,
.of(context)
.size
.width / 4,
child: DropdownButton( child: DropdownButton(
isExpanded: true, isExpanded: true,
value: settings.uiColumnModePortrait value: settings.uiColumnModePortrait.toString(),
.toString(),
onChanged: (String? newValue) { onChanged: (String? newValue) {
settings.uiColumnModePortrait = settings.uiColumnModePortrait = Settings.uiColumnModeFromString(newValue!);
Settings.uiColumnModeFromString(
newValue!);
saveSettings(context); saveSettings(context);
}, },
items: Settings.uiColumnModeOptions(false) items: Settings.uiColumnModeOptions(false).map<DropdownMenuItem<String>>((DualpaneMode value) {
.map<DropdownMenuItem<String>>(
(DualpaneMode value) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
value: value.toString(), value: value.toString(),
child: Text( child: Text(Settings.uiColumnModeToString(value, context), style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)),
Settings.uiColumnModeToString(
value, context),
style: settings.scaleFonts(
defaultDropDownMenuItemTextStyle)),
); );
}).toList()))), }).toList()))),
ListTile( ListTile(
title: Text( title: Text(
AppLocalizations.of(context)! AppLocalizations.of(context)!.settingUIColumnLandscape,
.settingUIColumnLandscape,
textWidthBasis: TextWidthBasis.longestLine, textWidthBasis: TextWidthBasis.longestLine,
softWrap: true, softWrap: true,
), ),
leading: Icon(Icons.stay_primary_landscape, leading: Icon(Icons.stay_primary_landscape, color: settings.current().mainTextColor),
color: settings
.current()
.mainTextColor),
trailing: Container( trailing: Container(
width: MediaQuery width: MediaQuery.of(context).size.width / 4,
.of(context)
.size
.width / 4,
child: Container( child: Container(
width: width: MediaQuery.of(context).size.width / 4,
MediaQuery
.of(context)
.size
.width / 4,
child: DropdownButton( child: DropdownButton(
isExpanded: true, isExpanded: true,
value: settings.uiColumnModeLandscape value: settings.uiColumnModeLandscape.toString(),
.toString(),
onChanged: (String? newValue) { onChanged: (String? newValue) {
settings.uiColumnModeLandscape = settings.uiColumnModeLandscape = Settings.uiColumnModeFromString(newValue!);
Settings.uiColumnModeFromString(
newValue!);
saveSettings(context); saveSettings(context);
}, },
items: items: Settings.uiColumnModeOptions(true).map<DropdownMenuItem<String>>((DualpaneMode value) {
Settings.uiColumnModeOptions(true)
.map<DropdownMenuItem<String>>(
(DualpaneMode value) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
value: value.toString(), value: value.toString(),
child: Text( child: Text(Settings.uiColumnModeToString(value, context), overflow: TextOverflow.ellipsis, style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)),
Settings.uiColumnModeToString(
value, context),
overflow: TextOverflow.ellipsis,
style: settings.scaleFonts(
defaultDropDownMenuItemTextStyle)),
); );
}).toList())))), }).toList())))),
ListTile( ListTile(
title: Text( title: Text(AppLocalizations.of(context)!.defaultScalingText),
AppLocalizations.of(context)!.defaultScalingText), subtitle: Text(AppLocalizations.of(context)!.fontScalingDescription),
subtitle: Text(AppLocalizations.of(context)!
.fontScalingDescription),
trailing: Container( trailing: Container(
width: MediaQuery width: MediaQuery.of(context).size.width / 4,
.of(context)
.size
.width / 4,
child: Slider( child: Slider(
onChanged: (double value) { onChanged: (double value) {
settings.fontScaling = value; settings.fontScaling = value;
// Save Settings... // Save Settings...
saveSettings(context); saveSettings(context);
EnvironmentConfig.debugLog( EnvironmentConfig.debugLog("Font Scaling: $value");
"Font Scaling: $value");
}, },
min: 0.5, min: 0.5,
divisions: 12, divisions: 12,
max: 2.0, max: 2.0,
label: '${settings.fontScaling * 100}%', label: '${settings.fontScaling * 100}%',
activeColor: activeColor: settings.current().defaultButtonColor,
settings thumbColor: settings.current().mainTextColor,
.current() overlayColor: MaterialStateProperty.all(settings.current().mainTextColor),
.defaultButtonColor, inactiveColor: settings.theme.defaultButtonDisabledColor,
thumbColor: settings
.current()
.mainTextColor,
overlayColor: MaterialStateProperty.all(
settings
.current()
.mainTextColor),
inactiveColor:
settings.theme.defaultButtonDisabledColor,
value: settings.fontScaling)), value: settings.fontScaling)),
leading: Icon(Icons.format_size, leading: Icon(Icons.format_size, color: settings.current().mainTextColor),
color: settings
.current()
.mainTextColor),
), ),
SwitchListTile( SwitchListTile(
title: Text( title: Text(AppLocalizations.of(context)!.streamerModeLabel),
AppLocalizations.of(context)!.streamerModeLabel), subtitle: Text(AppLocalizations.of(context)!.descriptionStreamerMode),
subtitle: Text(AppLocalizations.of(context)!
.descriptionStreamerMode),
value: settings.streamerMode, value: settings.streamerMode,
onChanged: (bool value) { onChanged: (bool value) {
settings.setStreamerMode(value); settings.setStreamerMode(value);
@ -318,20 +227,13 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: settings.theme.defaultButtonColor, activeTrackColor: settings.theme.defaultButtonColor,
inactiveTrackColor: inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
settings.theme.defaultButtonDisabledColor, secondary: Icon(CwtchIcons.streamer_bunnymask, color: settings.current().mainTextColor),
secondary: Icon(CwtchIcons.streamer_bunnymask,
color: settings
.current()
.mainTextColor),
), ),
SwitchListTile( SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.formattingExperiment),
.formattingExperiment), subtitle: Text(AppLocalizations.of(context)!.messageFormattingDescription),
subtitle: Text(AppLocalizations.of(context)! value: settings.isExperimentEnabled(FormattingExperiment),
.messageFormattingDescription),
value: settings
.isExperimentEnabled(FormattingExperiment),
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
settings.enableExperiment(FormattingExperiment); settings.enableExperiment(FormattingExperiment);
@ -340,14 +242,9 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
} }
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: activeTrackColor: settings.theme.defaultButtonActiveColor,
settings.theme.defaultButtonActiveColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: secondary: Icon(Icons.text_fields, color: settings.current().mainTextColor),
settings.theme.defaultButtonDisabledColor,
secondary: Icon(Icons.text_fields,
color: settings
.current()
.mainTextColor),
), ),
])))); ]))));
}); });

View File

@ -20,7 +20,6 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
static const androidSettingsChannel = const MethodChannel('androidSettings'); static const androidSettingsChannel = const MethodChannel('androidSettings');
static const androidSettingsChangeChannel = const MethodChannel('androidSettingsChanged'); static const androidSettingsChangeChannel = const MethodChannel('androidSettingsChanged');
ScrollController settingsListScrollController = ScrollController(); ScrollController settingsListScrollController = ScrollController();
bool powerExempt = false; bool powerExempt = false;
@ -51,8 +50,7 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
//* Android Only Requests //* Android Only Requests
Future<bool> isBatteryExempt() async { Future<bool> isBatteryExempt() async {
return await androidSettingsChannel.invokeMethod('isBatteryExempt', {}) ?? return await androidSettingsChannel.invokeMethod('isBatteryExempt', {}) ?? false;
false;
} }
Future<void> requestBatteryExemption() async { Future<void> requestBatteryExemption() async {
@ -62,11 +60,9 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
//* End Android Only Requests //* End Android Only Requests
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<Settings>(builder: (ccontext, settings, child) { return Consumer<Settings>(builder: (ccontext, settings, child) {
return LayoutBuilder( return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return Scrollbar( return Scrollbar(
key: Key("BehaviourSettingsView"), key: Key("BehaviourSettingsView"),
trackVisibility: true, trackVisibility: true,
@ -83,10 +79,8 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
Visibility( Visibility(
visible: Platform.isAndroid, visible: Platform.isAndroid,
child: SwitchListTile( child: SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.settingAndroidPowerExemption),
.settingAndroidPowerExemption), subtitle: Text(AppLocalizations.of(context)!.settingAndroidPowerExemptionDescription),
subtitle: Text(AppLocalizations.of(context)!
.settingAndroidPowerExemptionDescription),
value: powerExempt, value: powerExempt,
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
@ -97,17 +91,13 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
} }
}, },
activeTrackColor: settings.theme.defaultButtonColor, activeTrackColor: settings.theme.defaultButtonColor,
inactiveTrackColor: inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
settings.theme.defaultButtonDisabledColor, secondary: Icon(Icons.power, color: settings.current().mainTextColor),
secondary: Icon(Icons.power,
color: settings.current().mainTextColor),
), ),
), ),
ListTile( ListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.notificationPolicySettingLabel),
.notificationPolicySettingLabel), subtitle: Text(AppLocalizations.of(context)!.notificationPolicySettingDescription),
subtitle: Text(AppLocalizations.of(context)!
.notificationPolicySettingDescription),
trailing: Container( trailing: Container(
width: MediaQuery.of(context).size.width / 4, width: MediaQuery.of(context).size.width / 4,
child: DropdownButton( child: DropdownButton(
@ -117,27 +107,17 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
settings.notificationPolicy = newValue!; settings.notificationPolicy = newValue!;
saveSettings(context); saveSettings(context);
}, },
items: NotificationPolicy.values.map< items: NotificationPolicy.values.map<DropdownMenuItem<NotificationPolicy>>((NotificationPolicy value) {
DropdownMenuItem<NotificationPolicy>>(
(NotificationPolicy value) {
return DropdownMenuItem<NotificationPolicy>( return DropdownMenuItem<NotificationPolicy>(
value: value, value: value,
child: Text( child: Text(Settings.notificationPolicyToString(value, context), overflow: TextOverflow.ellipsis, style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)),
Settings.notificationPolicyToString(
value, context),
overflow: TextOverflow.ellipsis,
style: settings.scaleFonts(
defaultDropDownMenuItemTextStyle)),
); );
}).toList())), }).toList())),
leading: Icon(CwtchIcons.chat_bubble_empty_24px, leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
color: settings.current().mainTextColor),
), ),
ListTile( ListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.notificationContentSettingLabel),
.notificationContentSettingLabel), subtitle: Text(AppLocalizations.of(context)!.notificationContentSettingDescription),
subtitle: Text(AppLocalizations.of(context)!
.notificationContentSettingDescription),
trailing: Container( trailing: Container(
width: MediaQuery.of(context).size.width / 4, width: MediaQuery.of(context).size.width / 4,
child: DropdownButton( child: DropdownButton(
@ -147,29 +127,17 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
settings.notificationContent = newValue!; settings.notificationContent = newValue!;
saveSettings(context); saveSettings(context);
}, },
items: NotificationContent.values.map< items: NotificationContent.values.map<DropdownMenuItem<NotificationContent>>((NotificationContent value) {
DropdownMenuItem< return DropdownMenuItem<NotificationContent>(
NotificationContent>>(
(NotificationContent value) {
return DropdownMenuItem<
NotificationContent>(
value: value, value: value,
child: Text( child: Text(Settings.notificationContentToString(value, context), overflow: TextOverflow.ellipsis, style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)),
Settings.notificationContentToString(
value, context),
overflow: TextOverflow.ellipsis,
style: settings.scaleFonts(
defaultDropDownMenuItemTextStyle)),
); );
}).toList())), }).toList())),
leading: Icon(CwtchIcons.chat_bubble_empty_24px, leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
color: settings.current().mainTextColor),
), ),
SwitchListTile( SwitchListTile(
title: Text( title: Text(AppLocalizations.of(context)!.blockUnknownLabel),
AppLocalizations.of(context)!.blockUnknownLabel), subtitle: Text(AppLocalizations.of(context)!.descriptionBlockUnknownConnections),
subtitle: Text(AppLocalizations.of(context)!
.descriptionBlockUnknownConnections),
value: settings.blockUnknownConnections, value: settings.blockUnknownConnections,
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
@ -182,16 +150,12 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: settings.theme.defaultButtonColor, activeTrackColor: settings.theme.defaultButtonColor,
inactiveTrackColor: inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
settings.theme.defaultButtonDisabledColor, secondary: Icon(CwtchIcons.block_unknown, color: settings.current().mainTextColor),
secondary: Icon(CwtchIcons.block_unknown,
color: settings.current().mainTextColor),
), ),
SwitchListTile( SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.defaultPreserveHistorySetting),
.defaultPreserveHistorySetting), subtitle: Text(AppLocalizations.of(context)!.preserveHistorySettingDescription),
subtitle: Text(AppLocalizations.of(context)!
.preserveHistorySettingDescription),
value: settings.preserveHistoryByDefault, value: settings.preserveHistoryByDefault,
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
@ -204,10 +168,8 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: settings.theme.defaultButtonColor, activeTrackColor: settings.theme.defaultButtonColor,
inactiveTrackColor: inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
settings.theme.defaultButtonDisabledColor, secondary: Icon(CwtchIcons.peer_history, color: settings.current().mainTextColor),
secondary: Icon(CwtchIcons.peer_history,
color: settings.current().mainTextColor),
), ),
])))); ]))));
}); });
@ -224,8 +186,7 @@ class _GlobalSettingsBehaviourViewState extends State<GlobalSettingsBehaviourVie
// set up the AlertDialog // set up the AlertDialog
AlertDialog alert = AlertDialog( AlertDialog alert = AlertDialog(
title: title: Text(AppLocalizations.of(context)!.settingsAndroidPowerReenablePopup),
Text(AppLocalizations.of(context)!.settingsAndroidPowerReenablePopup),
actions: [ actions: [
okButton, okButton,
], ],

View File

@ -19,13 +19,11 @@ class GlobalSettingsExperimentsView extends StatefulWidget {
} }
class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperimentsView> { class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperimentsView> {
ScrollController settingsListScrollController = ScrollController(); ScrollController settingsListScrollController = ScrollController();
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<Settings>(builder: (ccontext, settings, child) { return Consumer<Settings>(builder: (ccontext, settings, child) {
return LayoutBuilder( return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return Scrollbar( return Scrollbar(
key: Key("ExperimentsSettingsView"), key: Key("ExperimentsSettingsView"),
trackVisibility: true, trackVisibility: true,
@ -40,10 +38,8 @@ class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperiment
), ),
child: Column(children: [ child: Column(children: [
SwitchListTile( SwitchListTile(
title: Text( title: Text(AppLocalizations.of(context)!.experimentsEnabled),
AppLocalizations.of(context)!.experimentsEnabled), subtitle: Text(AppLocalizations.of(context)!.descriptionExperiments),
subtitle: Text(AppLocalizations.of(context)!
.descriptionExperiments),
value: settings.experimentsEnabled, value: settings.experimentsEnabled,
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
@ -55,187 +51,109 @@ class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperiment
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: settings.theme.defaultButtonColor, activeTrackColor: settings.theme.defaultButtonColor,
inactiveTrackColor: inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
settings.theme.defaultButtonDisabledColor, secondary: Icon(CwtchIcons.enable_experiments, color: settings.current().mainTextColor),
secondary: Icon(CwtchIcons.enable_experiments,
color: settings
.current()
.mainTextColor),
), ),
Visibility( Visibility(
visible: settings.experimentsEnabled, visible: settings.experimentsEnabled,
child: Column( child: Column(
children: [ children: [
SwitchListTile( SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.enableGroups),
.enableGroups), subtitle: Text(AppLocalizations.of(context)!.descriptionExperimentsGroups),
subtitle: Text(AppLocalizations.of(context)! value: settings.isExperimentEnabled(TapirGroupsExperiment),
.descriptionExperimentsGroups),
value: settings.isExperimentEnabled(
TapirGroupsExperiment),
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
settings.enableExperiment( settings.enableExperiment(TapirGroupsExperiment);
TapirGroupsExperiment);
} else { } else {
settings.disableExperiment( settings.disableExperiment(TapirGroupsExperiment);
TapirGroupsExperiment);
} }
// Save Settings... // Save Settings...
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: activeTrackColor: settings.theme.defaultButtonColor,
settings.theme.defaultButtonColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: secondary: Icon(CwtchIcons.enable_groups, color: settings.current().mainTextColor),
settings.theme.defaultButtonDisabledColor,
secondary: Icon(CwtchIcons.enable_groups,
color: settings
.current()
.mainTextColor),
), ),
Visibility( Visibility(
visible: visible: !Platform.isAndroid && !Platform.isIOS,
!Platform.isAndroid && !Platform.isIOS,
child: SwitchListTile( child: SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.settingServers),
.settingServers), subtitle: Provider.of<FlwtchState>(context, listen: false).cwtch.IsServersCompiled()
subtitle: Provider ? Text(AppLocalizations.of(context)!.settingServersDescription)
.of<FlwtchState>( : Text("This version of Cwtch has been compiled without support for the server hosting experiment."),
context, value: Provider.of<FlwtchState>(context, listen: false).cwtch.IsServersCompiled() && settings.isExperimentEnabled(ServerManagementExperiment),
listen: false) onChanged: Provider.of<FlwtchState>(context, listen: false).cwtch.IsServersCompiled()
.cwtch
.IsServersCompiled()
? Text(AppLocalizations.of(context)!
.settingServersDescription)
: Text(
"This version of Cwtch has been compiled without support for the server hosting experiment."),
value: Provider
.of<FlwtchState>(context,
listen: false)
.cwtch
.IsServersCompiled() &&
settings.isExperimentEnabled(
ServerManagementExperiment),
onChanged: Provider
.of<FlwtchState>(
context,
listen: false)
.cwtch
.IsServersCompiled()
? (bool value) { ? (bool value) {
Provider.of<ServerListState>( Provider.of<ServerListState>(context, listen: false).clear();
context,
listen: false)
.clear();
if (value) { if (value) {
settings.enableExperiment( settings.enableExperiment(ServerManagementExperiment);
ServerManagementExperiment);
} else { } else {
settings.disableExperiment( settings.disableExperiment(ServerManagementExperiment);
ServerManagementExperiment);
} }
// Save Settings... // Save Settings...
saveSettings(context); saveSettings(context);
} }
: null, : null,
activeTrackColor: activeTrackColor: settings.theme.defaultButtonColor,
settings.theme.defaultButtonColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: settings inactiveThumbColor: settings.theme.defaultButtonDisabledColor,
.theme.defaultButtonDisabledColor,
inactiveThumbColor: settings
.theme.defaultButtonDisabledColor,
secondary: Icon(CwtchIcons.dns_24px), secondary: Icon(CwtchIcons.dns_24px),
)), )),
SwitchListTile( SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.settingFileSharing),
.settingFileSharing), subtitle: Text(AppLocalizations.of(context)!.descriptionFileSharing),
subtitle: Text(AppLocalizations.of(context)! value: settings.isExperimentEnabled(FileSharingExperiment),
.descriptionFileSharing),
value: settings.isExperimentEnabled(
FileSharingExperiment),
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
if (checkDownloadDirectory( if (checkDownloadDirectory(context, settings)) {
context, settings)) { settings.enableExperiment(FileSharingExperiment);
settings.enableExperiment(
FileSharingExperiment);
} else { } else {
settings.enableExperiment( settings.enableExperiment(FileSharingExperiment);
FileSharingExperiment); settings.disableExperiment(ImagePreviewsExperiment);
settings.disableExperiment(
ImagePreviewsExperiment);
} }
} else { } else {
settings.disableExperiment( settings.disableExperiment(FileSharingExperiment);
FileSharingExperiment); settings.disableExperiment(ImagePreviewsExperiment);
settings.disableExperiment(
ImagePreviewsExperiment);
} }
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: activeTrackColor: settings.theme.defaultButtonColor,
settings.theme.defaultButtonColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: secondary: Icon(CwtchIcons.attached_file_3, color: settings.current().mainTextColor),
settings.theme.defaultButtonDisabledColor,
secondary: Icon(CwtchIcons.attached_file_3,
color: settings
.current()
.mainTextColor),
), ),
Visibility( Visibility(
visible: settings.isExperimentEnabled( visible: settings.isExperimentEnabled(FileSharingExperiment),
FileSharingExperiment),
child: Column(children: [ child: Column(children: [
SwitchListTile( SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.settingImagePreviews),
.settingImagePreviews), subtitle: Text(AppLocalizations.of(context)!.settingImagePreviewsDescription),
subtitle: Text( value: settings.isExperimentEnabled(ImagePreviewsExperiment),
AppLocalizations.of(context)!
.settingImagePreviewsDescription),
value: settings.isExperimentEnabled(
ImagePreviewsExperiment),
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
if (checkDownloadDirectory( if (checkDownloadDirectory(context, settings)) {
context, settings)) { settings.enableExperiment(ImagePreviewsExperiment);
settings.enableExperiment(
ImagePreviewsExperiment);
} else { } else {
settings.disableExperiment( settings.disableExperiment(ImagePreviewsExperiment);
ImagePreviewsExperiment);
} }
} else { } else {
settings.disableExperiment( settings.disableExperiment(ImagePreviewsExperiment);
ImagePreviewsExperiment);
} }
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: settings activeTrackColor: settings.theme.defaultButtonActiveColor,
.theme.defaultButtonActiveColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: settings secondary: Icon(Icons.photo, color: settings.current().mainTextColor),
.theme.defaultButtonDisabledColor,
secondary: Icon(Icons.photo,
color:
settings
.current()
.mainTextColor),
), ),
Visibility( Visibility(
visible: settings.isExperimentEnabled( visible: settings.isExperimentEnabled(ImagePreviewsExperiment) && !Platform.isAndroid,
ImagePreviewsExperiment) &&
!Platform.isAndroid,
child: CwtchFolderPicker( child: CwtchFolderPicker(
testKey: Key("DownloadFolderPicker"), testKey: Key("DownloadFolderPicker"),
label: AppLocalizations.of(context)! label: AppLocalizations.of(context)!.settingDownloadFolder,
.settingDownloadFolder,
initialValue: settings.downloadPath, initialValue: settings.downloadPath,
textStyle: settings.scaleFonts( textStyle: settings.scaleFonts(defaultDropDownMenuItemTextStyle),
defaultDropDownMenuItemTextStyle), description: AppLocalizations.of(context)!.fileSharingSettingsDownloadFolderDescription,
description: AppLocalizations.of( tooltip: AppLocalizations.of(context)!.fileSharingSettingsDownloadFolderTooltip,
context)!
.fileSharingSettingsDownloadFolderDescription,
tooltip: AppLocalizations.of(context)!
.fileSharingSettingsDownloadFolderTooltip,
onSave: (newVal) { onSave: (newVal) {
settings.downloadPath = newVal; settings.downloadPath = newVal;
saveSettings(context); saveSettings(context);
@ -245,68 +163,34 @@ class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperiment
]), ]),
), ),
SwitchListTile( SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.blodeuweddExperimentEnable),
.blodeuweddExperimentEnable), subtitle: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported()
subtitle: Provider ? Text(AppLocalizations.of(context)!.blodeuweddDescription)
.of<FlwtchState>(context, : Text(AppLocalizations.of(context)!.blodeuweddNotSupported),
listen: false) value: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment),
.cwtch onChanged: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported()
.IsBlodeuweddSupported()
? Text(AppLocalizations.of(context)!
.blodeuweddDescription)
: Text(AppLocalizations.of(context)!
.blodeuweddNotSupported),
value: Provider
.of<FlwtchState>(context,
listen: false)
.cwtch
.IsBlodeuweddSupported() &&
settings.isExperimentEnabled(
BlodeuweddExperiment),
onChanged: Provider
.of<FlwtchState>(context,
listen: false)
.cwtch
.IsBlodeuweddSupported()
? (bool value) { ? (bool value) {
if (value) { if (value) {
settings.enableExperiment( settings.enableExperiment(BlodeuweddExperiment);
BlodeuweddExperiment);
} else { } else {
settings.disableExperiment( settings.disableExperiment(BlodeuweddExperiment);
BlodeuweddExperiment);
} }
saveSettings(context); saveSettings(context);
} }
: null, : null,
activeTrackColor: activeTrackColor: settings.theme.defaultButtonColor,
settings.theme.defaultButtonColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: inactiveThumbColor: settings.theme.defaultButtonDisabledColor,
settings.theme.defaultButtonDisabledColor, secondary: Icon(Icons.assistant, color: settings.current().mainTextColor),
inactiveThumbColor:
settings.theme.defaultButtonDisabledColor,
secondary: Icon(Icons.assistant,
color: settings
.current()
.mainTextColor),
), ),
Visibility( Visibility(
visible: Provider visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment),
.of<FlwtchState>(context,
listen: false)
.cwtch
.IsBlodeuweddSupported() &&
settings.isExperimentEnabled(
BlodeuweddExperiment),
child: CwtchFolderPicker( child: CwtchFolderPicker(
testKey: Key("DownloadFolderPicker"), testKey: Key("DownloadFolderPicker"),
label: AppLocalizations.of(context)! label: AppLocalizations.of(context)!.settingDownloadFolder,
.settingDownloadFolder,
initialValue: settings.blodeuweddPath, initialValue: settings.blodeuweddPath,
description: AppLocalizations.of(context)! description: AppLocalizations.of(context)!.blodeuweddPath,
.blodeuweddPath, tooltip: AppLocalizations.of(context)!.blodeuweddPath,
tooltip: AppLocalizations.of(context)!
.blodeuweddPath,
onSave: (newVal) { onSave: (newVal) {
settings.blodeuweddPath = newVal; settings.blodeuweddPath = newVal;
saveSettings(context); saveSettings(context);
@ -318,40 +202,27 @@ class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperiment
Visibility( Visibility(
visible: settings.experimentsEnabled, visible: settings.experimentsEnabled,
child: SwitchListTile( child: SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.enableExperimentClickableLinks),
.enableExperimentClickableLinks), subtitle: Text(AppLocalizations.of(context)!.experimentClickableLinksDescription),
subtitle: Text(AppLocalizations.of(context)! value: settings.isExperimentEnabled(ClickableLinksExperiment),
.experimentClickableLinksDescription),
value: settings.isExperimentEnabled(
ClickableLinksExperiment),
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
settings.enableExperiment( settings.enableExperiment(ClickableLinksExperiment);
ClickableLinksExperiment);
} else { } else {
settings.disableExperiment( settings.disableExperiment(ClickableLinksExperiment);
ClickableLinksExperiment);
} }
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: activeTrackColor: settings.theme.defaultButtonActiveColor,
settings.theme.defaultButtonActiveColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: secondary: Icon(Icons.link, color: settings.current().mainTextColor),
settings.theme.defaultButtonDisabledColor,
secondary: Icon(Icons.link,
color: settings
.current()
.mainTextColor),
)), )),
Visibility( Visibility(
visible: settings.experimentsEnabled, visible: settings.experimentsEnabled,
child: SwitchListTile( child: SwitchListTile(
title: Text(AppLocalizations.of(context)! title: Text(AppLocalizations.of(context)!.enableExperimentQRCode),
.enableExperimentQRCode), subtitle: Text(AppLocalizations.of(context)!.experimentQRCodeDescription),
subtitle: Text(AppLocalizations.of(context)! value: settings.isExperimentEnabled(QRCodeExperiment),
.experimentQRCodeDescription),
value: settings
.isExperimentEnabled(QRCodeExperiment),
onChanged: (bool value) { onChanged: (bool value) {
if (value) { if (value) {
settings.enableExperiment(QRCodeExperiment); settings.enableExperiment(QRCodeExperiment);
@ -360,14 +231,9 @@ class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperiment
} }
saveSettings(context); saveSettings(context);
}, },
activeTrackColor: activeTrackColor: settings.theme.defaultButtonActiveColor,
settings.theme.defaultButtonActiveColor, inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
inactiveTrackColor: secondary: Icon(Icons.qr_code, color: settings.current().mainTextColor),
settings.theme.defaultButtonDisabledColor,
secondary: Icon(Icons.qr_code,
color: settings
.current()
.mainTextColor),
)), )),
])))); ]))));
}); });
@ -379,9 +245,7 @@ class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperiment
if (settings.downloadPath != "") { if (settings.downloadPath != "") {
} else { } else {
// check if the default download path exists // check if the default download path exists
var path = Provider.of<FlwtchState>(context, listen: false) var path = Provider.of<FlwtchState>(context, listen: false).cwtch.defaultDownloadPath();
.cwtch
.defaultDownloadPath();
if (path != null) { if (path != null) {
settings.downloadPath = path; settings.downloadPath = path;
} else { } else {
@ -393,8 +257,7 @@ class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperiment
return true; return true;
} else { } else {
final snackBar = SnackBar( final snackBar = SnackBar(
content: Text( content: Text(AppLocalizations.of(context)!.errorDownloadDirectoryDoesNotExist),
AppLocalizations.of(context)!.errorDownloadDirectoryDoesNotExist),
); );
ScaffoldMessenger.of(context).showSnackBar(snackBar); ScaffoldMessenger.of(context).showSnackBar(snackBar);
return false; return false;

View File

@ -27,7 +27,6 @@ class GlobalSettingsView extends StatefulWidget {
} }
class _GlobalSettingsViewState extends State<GlobalSettingsView> { class _GlobalSettingsViewState extends State<GlobalSettingsView> {
ScrollController settingsListScrollController = ScrollController(); ScrollController settingsListScrollController = ScrollController();
@override @override
@ -35,7 +34,6 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DefaultTabController( return DefaultTabController(
@ -46,23 +44,10 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
bottom: TabBar( bottom: TabBar(
isScrollable: true, isScrollable: true,
tabs: [ tabs: [
Tab( Tab(key: Key("OpenSettingsAppearance"), icon: Icon(Icons.palette), text: AppLocalizations.of(context)!.settingsGroupAppearance),
key: Key("OpenSettingsAppearance"), Tab(key: Key("OpenSettingsBehaviour"), icon: Icon(Icons.settings), text: AppLocalizations.of(context)!.settingGroupBehaviour),
icon: Icon(Icons.palette), Tab(key: Key("OpenSettingsExperiments"), icon: Icon(CwtchIcons.enable_experiments), text: AppLocalizations.of(context)!.settingsGroupExperiments),
text: AppLocalizations.of(context)! Tab(icon: Icon(Icons.info), text: AppLocalizations.of(context)!.settingsGroupAbout),
.settingsGroupAppearance),
Tab(
key: Key("OpenSettingsBehaviour"),
icon: Icon(Icons.settings),
text:
AppLocalizations.of(context)!.settingGroupBehaviour),
Tab(
key: Key("OpenSettingsExperiments"),
icon: Icon(CwtchIcons.enable_experiments),
text: AppLocalizations.of(context)!
.settingsGroupExperiments),
Tab(icon: Icon(Icons.info), text: AppLocalizations.of(context)!
.settingsGroupAbout),
], ],
)), )),
body: _buildSettingsList(), body: _buildSettingsList(),
@ -71,15 +56,11 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
Widget _buildSettingsList() { Widget _buildSettingsList() {
return Consumer<Settings>(builder: (ccontext, settings, child) { return Consumer<Settings>(builder: (ccontext, settings, child) {
return LayoutBuilder( return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return TabBarView(children: [ return TabBarView(children: [
GlobalSettingsAppearanceView(), GlobalSettingsAppearanceView(),
GlobalSettingsBehaviourView(), GlobalSettingsBehaviourView(),
GlobalSettingsExperimentsView(), GlobalSettingsExperimentsView(),
GlobalSettingsAboutView(), GlobalSettingsAboutView(),
]); ]);
}); });
@ -90,7 +71,5 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
/// Send an UpdateGlobalSettings to the Event Bus /// Send an UpdateGlobalSettings to the Event Bus
saveSettings(context) { saveSettings(context) {
var settings = Provider.of<Settings>(context, listen: false); var settings = Provider.of<Settings>(context, listen: false);
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateSettings(jsonEncode(settings.asJson()));
.cwtch
.UpdateSettings(jsonEncode(settings.asJson()));
} }

View File

@ -17,7 +17,8 @@ class CwtchFolderPicker extends StatefulWidget {
final Key? testKey; final Key? testKey;
final TextStyle? textStyle; final TextStyle? textStyle;
final IconData icon; final IconData icon;
const CwtchFolderPicker({Key? key, this.testKey, this.textStyle, this.label = "", this.tooltip = "", this.initialValue = "", this.onSave, this.description = "", this.icon = Icons.file_download}) : super(key: key); const CwtchFolderPicker({Key? key, this.testKey, this.textStyle, this.label = "", this.tooltip = "", this.initialValue = "", this.onSave, this.description = "", this.icon = Icons.file_download})
: super(key: key);
@override @override
_CwtchFolderPickerState createState() => _CwtchFolderPickerState(); _CwtchFolderPickerState createState() => _CwtchFolderPickerState();