Skip to content

Commit

Permalink
feat: flag to disable dim in light mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Jul 22, 2024
1 parent d1cdc2e commit c8ce851
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/controller/settings.youtube.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ class _YoutubeSettings with SettingsFileWriter {
bool markVideoWatched = true;
InnertubeClients? innertubeClient;
bool whiteVideoBGInLightMode = false;
bool enableDimInLightMode = true;

void save({
int? addToPlaylistsTabIndex,
bool? markVideoWatched,
InnertubeClients? innertubeClient,
bool? whiteVideoBGInLightMode,
bool? enableDimInLightMode,
}) {
if (addToPlaylistsTabIndex != null) this.addToPlaylistsTabIndex = addToPlaylistsTabIndex;
if (markVideoWatched != null) this.markVideoWatched = markVideoWatched;
if (innertubeClient != null) this.innertubeClient = innertubeClient;
if (whiteVideoBGInLightMode != null) this.whiteVideoBGInLightMode = whiteVideoBGInLightMode;
if (enableDimInLightMode != null) this.enableDimInLightMode = enableDimInLightMode;
_writeToStorage();
}

Expand All @@ -45,6 +48,7 @@ class _YoutubeSettings with SettingsFileWriter {
markVideoWatched = json['markVideoWatched'] ?? markVideoWatched;
innertubeClient = InnertubeClients.values.getEnum(json['innertubeClient']);
whiteVideoBGInLightMode = json['whiteVideoBGInLightMode'] ?? whiteVideoBGInLightMode;
enableDimInLightMode = json['enableDimInLightMode'] ?? enableDimInLightMode;
} catch (e) {
printy(e, isError: true);
}
Expand All @@ -58,6 +62,7 @@ class _YoutubeSettings with SettingsFileWriter {
'markVideoWatched': markVideoWatched,
'innertubeClient': innertubeClient?.convertToString,
'whiteVideoBGInLightMode': whiteVideoBGInLightMode,
'enableDimInLightMode': enableDimInLightMode,
};

Future<void> _writeToStorage() => writeToStorage();
Expand Down
5 changes: 5 additions & 0 deletions lib/ui/widgets/settings/youtube_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@ class __YTFlagsOptionsState extends State<_YTFlagsOptions> {
onChanged: (isTrue) => setState(() => settings.youtube.save(whiteVideoBGInLightMode: !isTrue)),
title: 'white_video_bg_in_light_mode'.toUpperCase(),
),
CustomSwitchListTile(
value: settings.youtube.enableDimInLightMode,
onChanged: (isTrue) => setState(() => settings.youtube.save(enableDimInLightMode: !isTrue)),
title: 'enable_dim_in_light_mode'.toUpperCase(),
),
],
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/youtube/youtube_miniplayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class YoutubeMiniPlayerState extends State<YoutubeMiniPlayer> {

void startDimTimer() {
cancelDimTimer();
if (settings.youtube.enableDimInLightMode == false && namida.context?.isDarkMode == false) return;
final int defaultMiniplayerDimSeconds = settings.ytMiniplayerDimAfterSeconds.value;
if (defaultMiniplayerDimSeconds <= 0) return;
final double defaultMiniplayerOpacity = settings.ytMiniplayerDimOpacity.value;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 3.5.8-beta+240722230
version: 3.5.9-beta+240722230

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down

0 comments on commit c8ce851

Please sign in to comment.