Skip to content

Commit

Permalink
chore: refactor views & subscribers to extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Aug 19, 2024
1 parent 5aa8308 commit 591581d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
3 changes: 3 additions & 0 deletions lib/core/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ extension DisplayKeywords on int {
String get displayFolderKeyword => displayKeyword(lang.FOLDER, lang.FOLDERS);
String get displayPlaylistKeyword => displayKeyword(lang.PLAYLIST, lang.PLAYLISTS);
String get displayVideoKeyword => displayKeyword(lang.VIDEO, lang.VIDEOS);
String get displayViewsKeyword => displayKeyword(lang.VIEW, lang.VIEWS);
String get displayViewsKeywordShort => displayKeywordShort(lang.VIEW, lang.VIEWS);
String get displaySubscribersKeywordShort => displayKeywordShort(lang.SUBSCRIBER, lang.SUBSCRIBERS);
}

extension YearDateFormatted on int {
Expand Down
2 changes: 1 addition & 1 deletion lib/youtube/pages/yt_playlist_subpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ class _YTHostedPlaylistSubpageState extends State<YTHostedPlaylistSubpage> with
description = playlist.info.description;
final uploaderTitle = playlist.info.uploader?.title;
final viewsCount = playlist.info.viewsCount;
final viewsCountText = viewsCount == null ? playlist.info.viewsCountText : "${viewsCount.formatDecimalShort()} ${viewsCount == 0 ? lang.VIEW : lang.VIEWS}";
final viewsCountText = viewsCount == null ? playlist.info.viewsCountText : viewsCount.displayViewsKeywordShort;
uploaderTitleAndViews = [
if (uploaderTitle != null) uploaderTitle,
if (viewsCountText != null) viewsCountText,
Expand Down
3 changes: 1 addition & 2 deletions lib/youtube/widgets/yt_video_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:youtipie/youtipie.dart';
import 'package:namida/controller/player_controller.dart';
import 'package:namida/core/enums.dart';
import 'package:namida/core/extensions.dart';
import 'package:namida/core/translations/language.dart';
import 'package:namida/core/utils.dart';
import 'package:namida/ui/widgets/custom_widgets.dart';
import 'package:namida/youtube/class/youtube_id.dart';
Expand Down Expand Up @@ -67,7 +66,7 @@ class YoutubeVideoCard extends StatelessWidget {
final viewsCount = video.viewsCount;
String? viewsCountText = video.viewsText;
if (viewsCount != null) {
viewsCountText = "${viewsCount.formatDecimalShort()} ${viewsCount == 0 ? lang.VIEW : lang.VIEWS}";
viewsCountText = viewsCount.displayViewsKeywordShort;
}

DateTime? publishedDate = video.publishedAt.date;
Expand Down
9 changes: 2 additions & 7 deletions lib/youtube/youtube_miniplayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class YoutubeMiniPlayerState extends State<YoutubeMiniPlayer> {
child: Text(
[
if (videoViewCount != null)
"${videoViewCount.formatDecimalShort(isTitleExpanded)} ${videoViewCount == 0 ? lang.VIEW : lang.VIEWS}",
isTitleExpanded ? videoViewCount.displayViewsKeyword : videoViewCount.displayViewsKeywordShort,
if (dateToShow != null) dateToShow,
].join(' • '),
style: mainTextTheme.displaySmall?.copyWith(fontWeight: FontWeight.w500),
Expand Down Expand Up @@ -772,12 +772,7 @@ class YoutubeMiniPlayerState extends State<YoutubeMiniPlayer> {
child: ObxO(
rx: _isTitleExpanded,
builder: (isTitleExpanded) => Text(
channelSubs == null
? '? ${lang.SUBSCRIBERS}'
: [
channelSubs.formatDecimalShort(isTitleExpanded),
channelSubs < 2 ? lang.SUBSCRIBER : lang.SUBSCRIBERS,
].join(' '),
channelSubs == null ? '? ${lang.SUBSCRIBERS}' : channelSubs.displaySubscribersKeywordShort,
style: mainTextTheme.displaySmall?.copyWith(
fontSize: 12.0,
),
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.9.55-beta+240819220
version: 3.9.56-beta+240819222

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

0 comments on commit 591581d

Please sign in to comment.