Skip to content

Commit

Permalink
feat(yt): show channel watermark in fullscreen (optional)
Browse files Browse the repository at this point in the history
ref: #227
  • Loading branch information
MSOB7YY committed Jul 25, 2024
1 parent 2afb697 commit f017377
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 9 deletions.
17 changes: 9 additions & 8 deletions bump_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,19 @@ Future<bool> _buildAPK({required bool verbose}) async {

Future<bool> _runGitAdd({required String oldLine, required String newLine, required List<String> args}) async {
bool added = false;
bool executedFirstCommand = false;
final success = await _runProcess(
program: 'git',
command: 'add pubspec.yaml -p',
onOutput: (data, stdinStream) {
final requiredChangeDetect = "-$oldLine\n+$newLine";
if (data.contains(requiredChangeDetect)) {
stdinStream.writeln('y');
added = true;
print('git: added version change');
} else {
stdinStream.writeln('n');
}
if (executedFirstCommand) return;
executedFirstCommand = true;
stdinStream.writeln('s');
stdinStream.writeln('/');
stdinStream.writeln('^version: ');
stdinStream.writeln('y');
stdinStream.writeln('q');
added = true;
},
);
return success && added;
Expand Down
5 changes: 5 additions & 0 deletions lib/controller/settings.youtube.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class _YoutubeSettings with SettingsFileWriter {

final ytVisibleShorts = <YTVisibleShortPlaces, bool>{}.obs;
final ytVisibleMixes = <YTVisibleMixesPlaces, bool>{}.obs;
final showChannelWatermarkFullscreen = true.obs;

int addToPlaylistsTabIndex = 0;
bool markVideoWatched = true;
Expand All @@ -13,13 +14,15 @@ class _YoutubeSettings with SettingsFileWriter {
bool enableDimInLightMode = true;

void save({
bool? showChannelWatermarkFullscreen,
int? addToPlaylistsTabIndex,
bool? markVideoWatched,
InnertubeClients? innertubeClient,
bool setDefaultInnertubeClient = false,
bool? whiteVideoBGInLightMode,
bool? enableDimInLightMode,
}) {
if (showChannelWatermarkFullscreen != null) this.showChannelWatermarkFullscreen.value = showChannelWatermarkFullscreen;
if (addToPlaylistsTabIndex != null) this.addToPlaylistsTabIndex = addToPlaylistsTabIndex;
if (markVideoWatched != null) this.markVideoWatched = markVideoWatched;
if (innertubeClient != null || setDefaultInnertubeClient) this.innertubeClient = innertubeClient;
Expand All @@ -43,6 +46,7 @@ class _YoutubeSettings with SettingsFileWriter {
if (json == null) return;
try {
json as Map;
showChannelWatermarkFullscreen.value = json['showChannelWatermarkFullscreen'] ?? showChannelWatermarkFullscreen.value;
ytVisibleShorts.value = (json['ytVisibleShorts'] as Map?)?.map((key, value) => MapEntry(YTVisibleShortPlaces.values.getEnum(key)!, value)) ?? ytVisibleShorts.value;
ytVisibleMixes.value = (json['ytVisibleMixes'] as Map?)?.map((key, value) => MapEntry(YTVisibleMixesPlaces.values.getEnum(key)!, value)) ?? ytVisibleMixes.value;
addToPlaylistsTabIndex = json['addToPlaylistsTabIndex'] ?? addToPlaylistsTabIndex;
Expand All @@ -57,6 +61,7 @@ class _YoutubeSettings with SettingsFileWriter {

@override
Object get jsonToWrite => <String, dynamic>{
'showChannelWatermarkFullscreen': showChannelWatermarkFullscreen,
'ytVisibleShorts': ytVisibleShorts.map((key, value) => MapEntry(key.convertToString, value)),
'ytVisibleMixes': ytVisibleMixes.map((key, value) => MapEntry(key.convertToString, value)),
'addToPlaylistsTabIndex': addToPlaylistsTabIndex,
Expand Down
1 change: 1 addition & 0 deletions lib/core/translations/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ abstract class LanguageKeys {
String get SHOULD_DUCK_NOTE => _getKey('SHOULD_DUCK_NOTE');
String get SHOULD_PAUSE => _getKey('SHOULD_PAUSE');
String get SHOULD_PAUSE_NOTE => _getKey('SHOULD_PAUSE_NOTE');
String get SHOW_CHANNEL_WATERMARK_IN_FULLSCREEN => _getKey('SHOW_CHANNEL_WATERMARK_IN_FULLSCREEN');
String get SHOW_HIDE_UNKNOWN_FIELDS => _getKey('SHOW_HIDE_UNKNOWN_FIELDS');
String get SHOW_MIX_PLAYLISTS_IN => _getKey('SHOW_MIX_PLAYLISTS_IN');
String get SHOW_MORE => _getKey('SHOW_MORE');
Expand Down
19 changes: 19 additions & 0 deletions lib/ui/widgets/settings/youtube_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum _YoutubeSettingKeys {
showMixesIn,
topComments,
preferNewComments,
showChannelWatermarkFullscreen,
dimMiniplayerAfter,
dimIntensity,
downloadsMetadataTags,
Expand All @@ -49,6 +50,7 @@ class YoutubeSettings extends SettingSubpageProvider {
_YoutubeSettingKeys.showMixesIn: [lang.SHOW_MIX_PLAYLISTS_IN],
_YoutubeSettingKeys.topComments: [lang.TOP_COMMENTS, lang.TOP_COMMENTS_SUBTITLE],
_YoutubeSettingKeys.preferNewComments: [lang.YT_PREFER_NEW_COMMENTS, lang.YT_PREFER_NEW_COMMENTS_SUBTITLE],
_YoutubeSettingKeys.showChannelWatermarkFullscreen: [lang.SHOW_CHANNEL_WATERMARK_IN_FULLSCREEN],
_YoutubeSettingKeys.dimMiniplayerAfter: [lang.DIM_MINIPLAYER_AFTER_SECONDS],
_YoutubeSettingKeys.dimIntensity: [lang.DIM_INTENSITY],
_YoutubeSettingKeys.seekbar: [lang.SEEKBAR, lang.TAP_TO_SEEK, lang.DRAG_TO_SEEK],
Expand Down Expand Up @@ -174,6 +176,23 @@ class YoutubeSettings extends SettingSubpageProvider {
),
),
),
getItemWrapper(
key: _YoutubeSettingKeys.showChannelWatermarkFullscreen,
child: ObxO(
rx: settings.youtube.showChannelWatermarkFullscreen,
builder: (showChannelWatermarkFullscreen) => CustomSwitchListTile(
bgColor: getBgColor(_YoutubeSettingKeys.showChannelWatermarkFullscreen),
leading: const StackedIcon(
baseIcon: Broken.profile_circle,
secondaryIcon: Broken.drop,
secondaryIconSize: 12.0,
),
title: lang.SHOW_CHANNEL_WATERMARK_IN_FULLSCREEN,
value: showChannelWatermarkFullscreen,
onChanged: (isTrue) => settings.youtube.save(showChannelWatermarkFullscreen: !isTrue),
),
),
),
getItemWrapper(
key: _YoutubeSettingKeys.showShortsIn,
child: _ShowItemInListTile(
Expand Down
57 changes: 57 additions & 0 deletions lib/ui/widgets/video_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,13 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
final shouldShowSeekBar = widget.isFullScreen;
final view = View.of(context);

String? channelOverlayUrl;

if (widget.isFullScreen && settings.youtube.showChannelWatermarkFullscreen.value) {
final channelOverlay = YoutubeInfoController.current.currentYTStreams.value?.overlay;
channelOverlayUrl = channelOverlay?.overlays.pick()?.url;
}

return Listener(
onPointerDown: (event) {
_pointerDownedOnRight = event.position.dx > context.width / 2;
Expand Down Expand Up @@ -1653,6 +1660,15 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
),
],
],

if (channelOverlayUrl != null)
Positioned(
right: 12.0,
bottom: 12.0,
child: _YTChannelOverlayThumbnail(
channelOverlayUrl: channelOverlayUrl,
),
),
],
),
),
Expand Down Expand Up @@ -1772,3 +1788,44 @@ class __SpeedsEditorDialogState extends State<_SpeedsEditorDialog> {
);
}
}

class _YTChannelOverlayThumbnail extends StatefulWidget {
final String channelOverlayUrl;
const _YTChannelOverlayThumbnail({required this.channelOverlayUrl});

@override
State<_YTChannelOverlayThumbnail> createState() => __YTChannelOverlayThumbnailState();
}

class __YTChannelOverlayThumbnailState extends State<_YTChannelOverlayThumbnail> {
bool _isHighlighted = false;

@override
Widget build(BuildContext context) {
final channelOverlayUrl = widget.channelOverlayUrl;
return TapDetector(
onTap: null,
initializer: (instance) {
instance
..onTapDown = (d) {
if (mounted) setState(() => _isHighlighted = true);
}
..onTapUp = (d) {
if (mounted) setState(() => _isHighlighted = false);
};
},
child: AnimatedOpacity(
duration: const Duration(milliseconds: 300),
opacity: _isHighlighted ? 1 : 0.35,
child: YoutubeThumbnail(
key: ValueKey(channelOverlayUrl),
width: 38.0,
isImportantInCache: true,
borderRadius: 0,
type: ThumbnailType.channel,
customUrl: channelOverlayUrl,
),
),
);
}
}
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.6.65-beta+240725235
version: 3.6.7-beta+240725238

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

0 comments on commit f017377

Please sign in to comment.