Skip to content

Commit

Permalink
feat: flag to enable white bg for videos
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Jul 22, 2024
1 parent eb651ef commit d1cdc2e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
5 changes: 5 additions & 0 deletions lib/controller/settings.youtube.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ class _YoutubeSettings with SettingsFileWriter {
int addToPlaylistsTabIndex = 0;
bool markVideoWatched = true;
InnertubeClients? innertubeClient;
bool whiteVideoBGInLightMode = false;

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

Expand All @@ -41,6 +44,7 @@ class _YoutubeSettings with SettingsFileWriter {
addToPlaylistsTabIndex = json['addToPlaylistsTabIndex'] ?? addToPlaylistsTabIndex;
markVideoWatched = json['markVideoWatched'] ?? markVideoWatched;
innertubeClient = InnertubeClients.values.getEnum(json['innertubeClient']);
whiteVideoBGInLightMode = json['whiteVideoBGInLightMode'] ?? whiteVideoBGInLightMode;
} catch (e) {
printy(e, isError: true);
}
Expand All @@ -53,6 +57,7 @@ class _YoutubeSettings with SettingsFileWriter {
'addToPlaylistsTabIndex': addToPlaylistsTabIndex,
'markVideoWatched': markVideoWatched,
'innertubeClient': innertubeClient?.convertToString,
'whiteVideoBGInLightMode': whiteVideoBGInLightMode,
};

Future<void> _writeToStorage() => writeToStorage();
Expand Down
21 changes: 14 additions & 7 deletions lib/controller/video_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,21 @@ class VideoController {
bool? setOrientations,
}) async {
final aspect = Player.inst.videoPlayerInfo.value?.aspectRatio;
Widget videoControls = NamidaVideoControls(
key: VideoController.inst.videoControlsKeyFullScreen,
isLocal: isLocal,
onMinimizeTap: NamidaNavigator.inst.exitFullScreen,
showControls: true,
isFullScreen: true,
);
if (settings.youtube.whiteVideoBGInLightMode && namida.context?.isDarkMode == false) {
videoControls = ColoredBox(
color: Colors.white,
child: videoControls,
);
}
await NamidaNavigator.inst.toggleFullScreen(
NamidaVideoControls(
key: VideoController.inst.videoControlsKeyFullScreen,
isLocal: isLocal,
onMinimizeTap: NamidaNavigator.inst.exitFullScreen,
showControls: true,
isFullScreen: true,
),
videoControls,
setOrientations: setOrientations ?? (aspect == null ? true : aspect > 1),
);
}
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 @@ -569,6 +569,11 @@ class __YTFlagsOptionsState extends State<_YTFlagsOptions> {
child: Text(settings.youtube.innertubeClient?.name ?? lang.DEFAULT)),
onTap: () {},
),
CustomSwitchListTile(
value: settings.youtube.whiteVideoBGInLightMode,
onChanged: (isTrue) => setState(() => settings.youtube.save(whiteVideoBGInLightMode: !isTrue)),
title: 'white_video_bg_in_light_mode'.toUpperCase(),
),
],
),
),
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.7-beta+240722227
version: 3.5.8-beta+240722230

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

0 comments on commit d1cdc2e

Please sign in to comment.