diff --git a/lib/settings.dart b/lib/settings.dart index ee75f6b5..786171ac 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -404,9 +404,12 @@ class Settings extends ChangeNotifier { // checks experiment settings and file extension for image previews // (ignores file size; if the user manually accepts the file, assume it's okay to preview) bool shouldPreview(String path) { + return isExperimentEnabled(ImagePreviewsExperiment) && isImage(path); + } + + bool isImage(String path) { var lpath = path.toLowerCase(); - return isExperimentEnabled(ImagePreviewsExperiment) && - (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")); + return (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")); } String get downloadPath => _downloadPath; diff --git a/lib/views/globalsettingsexperimentsview.dart b/lib/views/globalsettingsexperimentsview.dart index 2cd1bf34..9aa69275 100644 --- a/lib/views/globalsettingsexperimentsview.dart +++ b/lib/views/globalsettingsexperimentsview.dart @@ -163,28 +163,28 @@ class _GlobalSettingsExperimentsViewState extends State(context, listen: false).cwtch.IsBlodeuweddSupported(), - child: SwitchListTile( - title: Text(AppLocalizations.of(context)!.blodeuweddExperimentEnable), - subtitle: Provider.of(context, listen: false).cwtch.IsBlodeuweddSupported() - ? Text(AppLocalizations.of(context)!.blodeuweddDescription) - : Text(AppLocalizations.of(context)!.blodeuweddNotSupported), - value: Provider.of(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment), - onChanged: Provider.of(context, listen: false).cwtch.IsBlodeuweddSupported() - ? (bool value) { - if (value) { - settings.enableExperiment(BlodeuweddExperiment); - } else { - settings.disableExperiment(BlodeuweddExperiment); + visible: Provider.of(context, listen: false).cwtch.IsBlodeuweddSupported(), + child: SwitchListTile( + title: Text(AppLocalizations.of(context)!.blodeuweddExperimentEnable), + subtitle: Provider.of(context, listen: false).cwtch.IsBlodeuweddSupported() + ? Text(AppLocalizations.of(context)!.blodeuweddDescription) + : Text(AppLocalizations.of(context)!.blodeuweddNotSupported), + value: Provider.of(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment), + onChanged: Provider.of(context, listen: false).cwtch.IsBlodeuweddSupported() + ? (bool value) { + if (value) { + settings.enableExperiment(BlodeuweddExperiment); + } else { + settings.disableExperiment(BlodeuweddExperiment); + } + saveSettings(context); } - saveSettings(context); - } - : null, - activeTrackColor: settings.theme.defaultButtonColor, - inactiveTrackColor: settings.theme.defaultButtonDisabledColor, - inactiveThumbColor: settings.theme.defaultButtonDisabledColor, - secondary: Icon(Icons.assistant, color: settings.current().mainTextColor), - )), + : null, + activeTrackColor: settings.theme.defaultButtonColor, + inactiveTrackColor: settings.theme.defaultButtonDisabledColor, + inactiveThumbColor: settings.theme.defaultButtonDisabledColor, + secondary: Icon(Icons.assistant, color: settings.current().mainTextColor), + )), Visibility( visible: Provider.of(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment), child: CwtchFolderPicker( diff --git a/lib/widgets/filebubble.dart b/lib/widgets/filebubble.dart index 2879d721..df27041d 100644 --- a/lib/widgets/filebubble.dart +++ b/lib/widgets/filebubble.dart @@ -94,10 +94,7 @@ class FileBubbleState extends State { var isImagePreview = false; if (path != null) { - var lpath = path.toLowerCase(); - if (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")) { - isImagePreview = true; - } + isImagePreview = Provider.of(context).isImage(path); } if (downloadComplete && path != null) {