Skip to content

Commit

Permalink
Merge cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Komodo5197 committed Feb 11, 2024
1 parent 6931024 commit caea382
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 47 deletions.
29 changes: 16 additions & 13 deletions lib/components/AlbumScreen/item_info.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:finamp/components/PlayerScreen/artist_chip.dart';
import 'package:finamp/components/artists_text_spans.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:get_it/get_it.dart';

Expand Down Expand Up @@ -39,23 +38,27 @@ class ItemInfo extends StatelessWidget {
// ),
// ),
// ),
if (item.type != "Playlist") ArtistChips(
baseItem: item,
useAlbumArtist: true,
),
if (item.type != "Playlist")
ArtistChips(
baseItem: item,
useAlbumArtist: true,
),
IconAndText(
iconData: Icons.music_note,
textSpan: TextSpan(text: (itemSongs == (item.childCount ?? itemSongs))
? AppLocalizations.of(context)!.songCount(itemSongs)
: AppLocalizations.of(context)!
.offlineSongCount(item.childCount!, itemSongs),
)),
iconData: Icons.music_note,
textSpan: TextSpan(
text: (itemSongs == (item.childCount ?? itemSongs))
? AppLocalizations.of(context)!.songCount(itemSongs)
: AppLocalizations.of(context)!
.offlineSongCount(item.childCount!, itemSongs),
)),
IconAndText(
iconData: Icons.timer,
textSpan: TextSpan(text: printDuration(item.runTimeTicksDuration())),
),
if (item.type != "Playlist")
IconAndText(iconData: Icons.event, textSpan: TextSpan(text: item.productionYearString))
IconAndText(
iconData: Icons.event,
textSpan: TextSpan(text: item.productionYearString))
],
);
}
Expand Down
11 changes: 8 additions & 3 deletions lib/components/ArtistScreen/artist_item_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@ class ArtistItemInfo extends StatelessWidget {
// TODO: see if there's a way to expand this column to the row that it's in
@override
Widget build(BuildContext context) {
bool isOffline=FinampSettingsHelper.finampSettings.isOffline;
bool isOffline = FinampSettingsHelper.finampSettings.isOffline;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconAndText(
iconData: Icons.music_note,
textSpan: TextSpan(text: isOffline?AppLocalizations.of(context)!.offlineSongCountArtist(itemSongs):AppLocalizations.of(context)!.songCount(itemSongs))),
textSpan: TextSpan(
text: isOffline
? AppLocalizations.of(context)!
.offlineSongCountArtist(itemSongs)
: AppLocalizations.of(context)!.songCount(itemSongs))),
IconAndText(
iconData: Icons.book,
textSpan: TextSpan(text: AppLocalizations.of(context)!.albumCount(itemAlbums))),
textSpan: TextSpan(
text: AppLocalizations.of(context)!.albumCount(itemAlbums))),
if (item.type != "MusicGenre" &&
item.genreItems != null &&
item.genreItems!.isNotEmpty)
Expand Down
7 changes: 5 additions & 2 deletions lib/components/DownloadsScreen/downloaded_items_list.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:finamp/services/finamp_settings_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:get_it/get_it.dart';
Expand Down Expand Up @@ -42,8 +43,10 @@ class _DownloadedItemsListState extends State<DownloadedItemsList> {
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (!(album.baseItemType == BaseItemDtoType.album ||
album.baseItemType == BaseItemDtoType.song))
if ((!(album.baseItemType == BaseItemDtoType.album ||
album.baseItemType ==
BaseItemDtoType.song)) &&
!FinampSettingsHelper.finampSettings.isOffline)
IconButton(
icon: const Icon(Icons.sync),
onPressed: () {
Expand Down
6 changes: 3 additions & 3 deletions lib/components/PlayerScreen/artist_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class ArtistChips extends StatelessWidget {

@override
Widget build(BuildContext context) {

final artists = useAlbumArtist ? baseItem?.albumArtists : baseItem?.artistItems;
final artists =
useAlbumArtist ? baseItem?.albumArtists : baseItem?.artistItems;

return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
Expand Down Expand Up @@ -147,7 +147,7 @@ class _ArtistChipContent extends StatelessWidget {
onTap: !item.isArtist
? null
: () => Navigator.of(context)
.popAndPushNamed(ArtistScreen.routeName, arguments: item),
.pushNamed(ArtistScreen.routeName, arguments: item),
borderRadius: _borderRadius,
child: Row(
mainAxisSize: MainAxisSize.min,
Expand Down
49 changes: 23 additions & 26 deletions lib/components/artists_text_spans.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ import 'package:get_it/get_it.dart';
import '../../models/jellyfin_models.dart';
import '../../services/jellyfin_api_helper.dart';
import '../screens/artist_screen.dart';
import '../services/isar_downloads.dart';

List<TextSpan> buildArtistsTextSpans(
BaseItemDto item,
Color? textColour,
BuildContext context,
bool popRoutes
) {
BaseItemDto item, Color? textColour, BuildContext context, bool popRoutes) {
final jellyfinApiHelper = GetIt.instance<JellyfinApiHelper>();
final isarDownloader = GetIt.instance<IsarDownloads>();
List<TextSpan> separatedArtistTextSpans = [];

List<NameIdPair>? artists =
item.type == "MusicAlbum"
? item.albumArtists
: item.artistItems;
item.type == "MusicAlbum" ? item.albumArtists : item.artistItems;

if (artists?.isEmpty ?? true) {
separatedArtistTextSpans = [
Expand All @@ -30,25 +26,26 @@ List<TextSpan> buildArtistsTextSpans(
];
} else {
artists
?.map((e) => TextSpan(
text: e.name,
style: TextStyle(color: textColour),
recognizer: TapGestureRecognizer()
..onTap = () {
// Offline artists aren't implemented yet so we return if offline
if (FinampSettingsHelper.finampSettings.isOffline) return;
?.map((e) => TextSpan(
text: e.name,
style: TextStyle(color: textColour),
recognizer: TapGestureRecognizer()
..onTap = () {
Future<BaseItemDto>? artistFuture =
FinampSettingsHelper.finampSettings.isOffline
? isarDownloader
.getCollectionInfo(id: e.id)
.then((value) => value!.baseItem!)
: jellyfinApiHelper.getItemById(e.id);

jellyfinApiHelper.getItemById(e.id).then((artist) =>
popRoutes
? Navigator.of(context).popAndPushNamed(
ArtistScreen.routeName,
arguments: artist)
: Navigator.of(context).pushNamed(
ArtistScreen.routeName,
arguments: artist)
);
}))
.forEach((artistTextSpan) {
artistFuture.then((artist) => popRoutes
? Navigator.of(context).popAndPushNamed(
ArtistScreen.routeName,
arguments: artist)
: Navigator.of(context)
.pushNamed(ArtistScreen.routeName, arguments: artist));
}))
.forEach((artistTextSpan) {
separatedArtistTextSpans.add(artistTextSpan);
separatedArtistTextSpans.add(TextSpan(
text: ", ",
Expand Down

0 comments on commit caea382

Please sign in to comment.