Skip to content

Commit

Permalink
don't highlight some track list tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaphasilor committed Nov 11, 2024
1 parent 03797a1 commit fa232f6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
39 changes: 22 additions & 17 deletions lib/components/AlbumScreen/track_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class TrackListTile extends StatelessWidget {
this.isOnArtistScreen = false,
this.isShownInSearch = false,
this.allowDismiss = true,
this.highlightCurrentTrack = true,
});

final jellyfin_models.BaseItemDto item;
Expand All @@ -91,6 +92,7 @@ class TrackListTile extends StatelessWidget {
final bool isOnArtistScreen;
final bool isShownInSearch;
final bool allowDismiss;
final bool highlightCurrentTrack;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -283,6 +285,7 @@ class TrackListTile extends StatelessWidget {
isInPlaylist: isInPlaylist,
allowReorder: false,
allowDismiss: allowDismiss,
highlightCurrentTrack: highlightCurrentTrack,
onRemoveFromList: onRemoveFromList,
onTap: trackListTileOnTap,
confirmDismiss: trackListTileConfirmDismiss,
Expand All @@ -298,10 +301,10 @@ class QueueListTile extends StatelessWidget {
final int actualIndex;
final int indexOffset;
final bool isCurrentTrack;
final bool isPreviousTrack;
final bool isInPlaylist;
final bool allowReorder;
final bool allowDismiss;
final bool highlightCurrentTrack;

final void Function(bool playable) onTap;
final VoidCallback? onRemoveFromList;
Expand All @@ -318,7 +321,7 @@ class QueueListTile extends StatelessWidget {
required this.isInPlaylist,
required this.allowReorder,
this.allowDismiss = true,
this.isPreviousTrack = false,
this.highlightCurrentTrack = false,
this.parentItem,
this.onRemoveFromList,
this.themeCallback,
Expand All @@ -338,10 +341,10 @@ class QueueListTile extends StatelessWidget {
parentItem: parentItem,
listIndex: listIndex,
actualIndex: item.indexNumber,
isPreviousTrack: isPreviousTrack,
isInPlaylist: isInPlaylist,
allowReorder: allowReorder,
allowDismiss: allowDismiss,
highlightCurrentTrack: highlightCurrentTrack,
onRemoveFromList: onRemoveFromList,
// This must be in ListTile instead of parent GestureDetecter to
// enable hover color changes
Expand All @@ -360,10 +363,10 @@ class TrackListItem extends ConsumerStatefulWidget {
final bool showCover;
final bool showArtists;
final bool showPlayCount;
final bool isPreviousTrack;
final bool isInPlaylist;
final bool allowReorder;
final bool allowDismiss;
final bool highlightCurrentTrack;
final Widget dismissBackground;

final void Function(bool playable) onTap;
Expand All @@ -378,14 +381,14 @@ class TrackListItem extends ConsumerStatefulWidget {
required this.onTap,
required this.confirmDismiss,
this.parentItem,
this.isPreviousTrack = false,
this.isInPlaylist = false,
this.allowReorder = false,
this.allowDismiss = true,
this.showIndex = false,
this.showCover = true,
this.showArtists = true,
this.showPlayCount = false,
this.highlightCurrentTrack = true,
this.onRemoveFromList,
this.dismissBackground = const SizedBox.shrink()});

Expand Down Expand Up @@ -455,7 +458,7 @@ class TrackListItemState extends ConsumerState<TrackListItem>
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
child: isCurrentlyPlaying
child: isCurrentlyPlaying && widget.highlightCurrentTrack
? ProviderScope(
overrides: [
themeDataProvider.overrideWith((ref) {
Expand Down Expand Up @@ -488,8 +491,7 @@ class TrackListItemState extends ConsumerState<TrackListItem>
.textTheme
.bodyLarge
?.copyWith(
color: isCurrentlyPlaying
? Color.alphaBlend(
color: Color.alphaBlend(
(ref
.watch(
colorThemeProvider)
Expand All @@ -500,8 +502,7 @@ class TrackListItemState extends ConsumerState<TrackListItem>
Brightness
.light
? 0.5
: 0.1)) ??
Colors.transparent,
: 0.1)),
Theme.of(context)
.textTheme
.bodyLarge
Expand All @@ -510,11 +511,7 @@ class TrackListItemState extends ConsumerState<TrackListItem>
.brightness ==
Brightness.light
? Colors.black
: Colors.white))
: Theme.of(context)
.textTheme
.bodyLarge
?.color,
: Colors.white))
),
),
iconTheme: Theme.of(context).iconTheme.copyWith(
Expand All @@ -532,6 +529,8 @@ class TrackListItemState extends ConsumerState<TrackListItem>
showPlayCount: widget.showPlayCount,
themeCallback: (x) => _menuTheme = x,
isCurrentTrack: isCurrentlyPlaying,
highlightCurrentTrack:
widget.highlightCurrentTrack,
allowReorder: widget.allowReorder,
onTap: () => widget.onTap(playable)),
);
Expand All @@ -549,6 +548,7 @@ class TrackListItemState extends ConsumerState<TrackListItem>
showPlayCount: widget.showPlayCount,
themeCallback: (x) => _menuTheme = x,
isCurrentTrack: isCurrentlyPlaying,
highlightCurrentTrack: widget.highlightCurrentTrack,
allowReorder: widget.allowReorder,
onTap: () => widget.onTap(playable)),
),
Expand Down Expand Up @@ -597,6 +597,7 @@ class TrackListItemTile extends StatelessWidget {
this.showArtists = true,
this.showAlbum = true,
this.showPlayCount = false,
this.highlightCurrentTrack = true,
});

final jellyfin_models.BaseItemDto baseItem;
Expand All @@ -610,13 +611,17 @@ class TrackListItemTile extends StatelessWidget {
final bool showArtists;
final bool showAlbum;
final bool showPlayCount;
final bool highlightCurrentTrack;
final void Function() onTap;

static const double defaultTileHeight = 60.0;
static const double defaultTitleGap = 10.0;

@override
Widget build(BuildContext context) {

final highlightTrack = isCurrentTrack && highlightCurrentTrack;

final bool secondRowNeeded = showArtists || showAlbum || showPlayCount;

final durationLabelFullHours =
Expand All @@ -633,7 +638,7 @@ class TrackListItemTile extends StatelessWidget {
: baseItem.albumArtist ?? AppLocalizations.of(context)!.unknownArtist;

return ListTileTheme(
tileColor: isCurrentTrack
tileColor: highlightTrack
? Theme.of(context).colorScheme.surfaceContainer
: Colors.transparent,
child: ListTile(
Expand Down Expand Up @@ -670,7 +675,7 @@ class TrackListItemTile extends StatelessWidget {
if (showCover)
AlbumImage(
item: baseItem,
borderRadius: isCurrentTrack
borderRadius: highlightTrack
? BorderRadius.zero
: BorderRadius.circular(8.0),
themeCallback: themeCallback,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:finamp/components/AddToPlaylistScreen/add_to_playlist_list.dart';
import 'package:finamp/components/AlbumScreen/track_list_tile.dart';
import 'package:finamp/components/global_snackbar.dart';
import 'package:finamp/models/finamp_models.dart';
Expand Down Expand Up @@ -33,7 +34,9 @@ class PlaybackHistoryList extends StatelessWidget {

return CustomScrollView(
// use nested SliverList.builder()s to show history items grouped by date
slivers: groupedHistory.map((group) {
slivers: groupedHistory.indexed.map((indexedGroup) {
final groupIndex = indexedGroup.$1;
final group = indexedGroup.$2;
return SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
Expand All @@ -42,6 +45,8 @@ class PlaybackHistoryList extends StatelessWidget {
final historyItem = TrackListTile(
index: Future.value(actualIndex),
item: group.value[actualIndex].item.baseItem!,
highlightCurrentTrack: groupIndex == 0 &&
index == 0, // only highlight first track
);

final now = DateTime.now();
Expand Down
1 change: 0 additions & 1 deletion lib/components/PlayerScreen/queue_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ class _PreviousTracksListState extends State<PreviousTracksList>
duration: const Duration(milliseconds: 500));
},
isCurrentTrack: false,
isPreviousTrack: true,
);
},
);
Expand Down

0 comments on commit fa232f6

Please sign in to comment.