feat(library): mark the current song on Mornye rows and open CUE tracks on a tap

Mornye rows marked the current song only through the play button's pause
glyph, which the info button replaces when a tap plays. Show the current
song's title in the accent on Mornye track rows instead, in the Library,
search, playlists and catalog lists.

A CUE virtual track cannot play before it is split, so its tap opens the
details whatever the "Tapping a song" setting, and its button stays the
play button.
This commit is contained in:
zarzet committed 2026-11-16 18:00:12 +07:00
1 parent b5e1117f2c
commit 015accd0ab
12 files changed
+148 -49

No files matched your search

@@ -18,7 +18,6 @@ import 'package:mornye/widgets/song_row_tap.dart';
import 'package:mornye/widgets/track_card.dart';
import 'package:mornye/widgets/queue_swipe.dart';
import 'package:mornye/widgets/app_snack_bar.dart';
import 'package:mornye/theme/mornye_theme.dart';
import 'package:share_plus/share_plus.dart' show ShareParams, SharePlus, XFile;
import 'package:mornye/widgets/album_detail_header.dart';
import 'package:mornye/widgets/cached_cover_image.dart';
@@ -1356,13 +1355,11 @@ class _CollectionTrackTile extends ConsumerWidget {
final heroTag = inMemoryHistoryItem != null
? 'cover_${inMemoryHistoryItem.id}'
: null;
// Material rows mark the current track; Mornye rows show no
// current-track state.
final playback = context.isMornye
? null
: ref.watch(catalogTrackPlaybackUiProvider(catalogTrackKey(track)));
final isCurrent = playback?.isCurrent ?? false;
final isPlaying = playback?.isPlaying ?? false;
final playback = ref.watch(
catalogTrackPlaybackUiProvider(catalogTrackKey(track)),
);
final isCurrent = playback.isCurrent;
final isPlaying = playback.isPlaying;
final hasFile = isInHistory || isInLocalLibrary;
// Songs with a file queue as the selection bar queues them.
final queueSwipe = hasFile
+1
View File
@@ -859,6 +859,7 @@ class _LocalAlbumScreenState extends ConsumerState<LocalAlbumScreen>
);
final isPlaying = isCurrent && ref.watch(playbackPlayingProvider);
return AlbumTrackTile(
filePath: track.filePath,
isCurrent: isCurrent,
isPlaying: isPlaying,
trackNumber: track.trackNumber,
+14 -15
View File
@@ -983,6 +983,7 @@ extension _QueueTabItemWidgets on _QueueTabState {
if (item == null) return;
songRowTap(
ref,
path: item.filePath,
openDetails: openAction(item),
play: () => _LibraryPlaybackButton.run(
ref,
@@ -1087,6 +1088,7 @@ extension _QueueTabItemWidgets on _QueueTabState {
(_songTableByMode[filterMode]?.openAction ?? openAction)(
item,
)(),
path: item.filePath,
),
),
playback: mediaItemPlaybackUiProvider(_libraryPlaybackKey(item)),
@@ -1227,6 +1229,7 @@ extension _QueueTabItemWidgets on _QueueTabState {
// A song whose file is missing has no play action and keeps opening.
final tap = songRowTap(
ref,
path: item.filePath,
openDetails: open,
play: () => fileExistsListenable.value
? _LibraryPlaybackButton.run(ref, playbackKey, play)
@@ -1246,6 +1249,7 @@ extension _QueueTabItemWidgets on _QueueTabState {
onPlay: play,
),
onOpenDetails: open,
path: item.filePath,
);
}
return Tooltip(
@@ -1292,21 +1296,14 @@ extension _QueueTabItemWidgets on _QueueTabState {
return Semantics(
label: context.l10n.a11yTrackByArtist(item.trackName, item.artistName),
selected: isSelected,
// Material rows follow their own file, so a track change rebuilds only
// the rows involved. Mornye rows show no current-track state.
child: context.isMornye
? card()
: Consumer(
builder: (context, ref, _) {
final playback = ref.watch(
mediaItemPlaybackUiProvider(playbackKey),
);
return card(
current: playback.isCurrent,
playing: playback.isPlaying,
);
},
),
// Rows follow their own file, so a track change rebuilds only the rows
// involved.
child: Consumer(
builder: (context, ref, _) {
final playback = ref.watch(mediaItemPlaybackUiProvider(playbackKey));
return card(current: playback.isCurrent, playing: playback.isPlaying);
},
),
);
}
@@ -1338,6 +1335,7 @@ extension _QueueTabItemWidgets on _QueueTabState {
// A song whose file is missing has no play action and keeps opening.
final tap = songRowTap(
ref,
path: item.filePath,
openDetails: open,
play: () => fileExistsListenable.value
? _LibraryPlaybackButton.run(ref, playbackKey, play)
@@ -1421,6 +1419,7 @@ extension _QueueTabItemWidgets on _QueueTabState {
),
onOpenDetails: open,
size: SongRowButtonSize.grid,
path: item.filePath,
);
}
return Tooltip(
+6 -1
View File
@@ -30,6 +30,7 @@ class AlbumTrackTile extends ConsumerWidget {
this.isCurrent = false,
this.isPlaying = false,
this.queueSwipe,
this.filePath,
});
final int? trackNumber;
@@ -51,6 +52,9 @@ class AlbumTrackTile extends ConsumerWidget {
/// See [TrackCard.queueSwipe].
final QueueSwipeActions? queueSwipe;
/// The track's file. A CUE virtual track's tap opens it ([songRowTap]).
final String? filePath;
@override
Widget build(BuildContext context, WidgetRef ref) {
return TrackCard(
@@ -62,7 +66,7 @@ class AlbumTrackTile extends ConsumerWidget {
isPlaying: isPlaying,
onTap: isSelectionMode
? onToggleSelection
: songRowTap(ref, openDetails: onOpen, play: onPlay),
: songRowTap(ref, path: filePath, openDetails: onOpen, play: onPlay),
onLongPress: isSelectionMode ? null : onEnterSelectionMode,
leading: SizedBox(
width: 24,
@@ -78,6 +82,7 @@ class AlbumTrackTile extends ConsumerWidget {
trailing: SongRowButton(
playButton: AlbumTrackPlayButton(isPlaying: isPlaying, onPlay: onPlay),
onOpenDetails: onOpen,
path: filePath,
),
);
}
+7 -1
View File
@@ -873,12 +873,18 @@ class _LibraryDirectoryViewState extends ConsumerState<LibraryDirectoryView>
onPressed: play,
),
onOpenDetails: openDetails,
path: item.filePath,
),
isSelectionMode: isSelectionMode,
isSelected: selectedIds.contains(item.id),
onTap: isSelectionMode
? () => toggleSelection(item.id)
: songRowTap(ref, openDetails: openDetails, play: play),
: songRowTap(
ref,
path: item.filePath,
openDetails: openDetails,
play: play,
),
onLongPress: isSelectionMode
? () => toggleSelection(item.id)
: () => enterSelectionMode(item.id),
+5 -4
View File
@@ -502,6 +502,7 @@ class _LibrarySearchResultsState extends ConsumerState<LibrarySearchResults> {
onPressed: play(playback),
),
onOpenDetails: () => _open(hit),
path: hit.samplePath,
)
: const Icon(Icons.chevron_right),
// Long-press selects songs for the Library batch actions; while
@@ -512,6 +513,7 @@ class _LibrarySearchResultsState extends ConsumerState<LibrarySearchResults> {
? song
? songRowTap(
ref,
path: hit.samplePath,
openDetails: () => _open(hit),
play: play(playback),
)
@@ -523,10 +525,9 @@ class _LibrarySearchResultsState extends ConsumerState<LibrarySearchResults> {
onContextMenu: (position) => _showHitMenu(hit, position),
queueSwipe: swipe,
);
if (!song || context.isMornye) return card();
// Material song rows follow the file they play, so a track change
// rebuilds only the rows involved. Mornye rows show no current-track
// state.
if (!song) return card();
// Song rows follow the file they play, so a track change rebuilds only
// the rows involved.
return Consumer(
key: key,
builder: (context, ref, _) => card(
+14 -4
View File
@@ -6,6 +6,7 @@ import 'package:mornye/providers/settings_provider.dart';
import 'package:mornye/theme/app_tokens.dart';
import 'package:mornye/theme/mornye_icons.dart';
import 'package:mornye/theme/mornye_theme.dart';
import 'package:mornye/utils/file_access.dart';
import 'package:mornye/widgets/app_icon.dart';
import 'package:mornye/widgets/app_icon_button.dart';
import 'package:mornye/widgets/track_card.dart';
@@ -27,13 +28,17 @@ final librarySongTapPlaysProvider = Provider<bool>(
/// read at the tap, so rows built before a change follow it.
///
/// Rows without a play action keep their own tap, and selection mode stays
/// with the caller.
/// with the caller. A CUE virtual track at [path] cannot play before it is
/// split, so its tap always opens the details.
VoidCallback songRowTap(
WidgetRef ref, {
required VoidCallback openDetails,
required VoidCallback play,
String? path,
}) =>
() => ref.read(librarySongTapPlaysProvider) ? play() : openDetails();
() => ref.read(librarySongTapPlaysProvider) && !isCueVirtualPath(path)
? play()
: openDetails();
/// How a [SongRowButton] lays out its details button.
enum SongRowButtonSize {
@@ -49,22 +54,27 @@ enum SongRowButtonSize {
/// The trailing button of a song row that has both a details page and a play
/// button: [playButton], or a details button running [onOpenDetails] while a
/// tap on the row plays (see [songRowTap]).
/// tap on the row plays (see [songRowTap]). A CUE virtual track at [path]
/// keeps [playButton], because its tap opens the details.
class SongRowButton extends ConsumerWidget {
const SongRowButton({
super.key,
required this.playButton,
required this.onOpenDetails,
this.size = SongRowButtonSize.list,
this.path,
});
final Widget playButton;
final VoidCallback onOpenDetails;
final SongRowButtonSize size;
final String? path;
@override
Widget build(BuildContext context, WidgetRef ref) {
if (!ref.watch(librarySongTapPlaysProvider)) return playButton;
if (!ref.watch(librarySongTapPlaysProvider) || isCueVirtualPath(path)) {
return playButton;
}
final tooltip = context.l10n.desktopMenuShowDetails;
if (size == SongRowButtonSize.grid) {
return TrackGridPlayButton(
+7 -2
View File
@@ -152,7 +152,8 @@ class TrackCard extends StatelessWidget {
/// The row is the player's current track. The Material style fills it with
/// `primaryContainer` of the track's artwork scheme ([PlayerArtworkTheme]),
/// rounds its ends into a pill and shows a [NowPlayingIndicator] before
/// [trailing]. Mornye ignores it.
/// [trailing]. Mornye keeps the row plain and shows the title in its
/// accent.
final bool isCurrent;
/// The current track is playing, so the indicator moves.
@@ -352,7 +353,11 @@ class TrackCard extends StatelessWidget {
fontWeight: current
? FontWeight.w700
: FontWeight.w500,
color: contentColor,
// The accent as status: Mornye's only sign of
// the current track.
color: isCurrent && !material
? colorScheme.primary
: contentColor,
),
),
if (subtitle != null) ...[
+5 -8
View File
@@ -5,7 +5,6 @@ import 'package:mornye/providers/download_queue_provider.dart';
import 'package:mornye/providers/local_library_provider.dart';
import 'package:mornye/providers/music_player_provider.dart';
import 'package:mornye/providers/settings_provider.dart';
import 'package:mornye/theme/mornye_theme.dart';
import 'package:mornye/controllers/clickable_metadata.dart';
import 'package:mornye/controllers/local_playback.dart';
import 'package:mornye/widgets/audio_quality_badges.dart';
@@ -52,11 +51,9 @@ class TrackListTile extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final colorScheme = Theme.of(context).colorScheme;
// Material rows mark the current track; Mornye rows show no
// current-track state.
final playback = context.isMornye
? null
: ref.watch(catalogTrackPlaybackUiProvider(catalogTrackKey(track)));
final playback = ref.watch(
catalogTrackPlaybackUiProvider(catalogTrackKey(track)),
);
final isQueued = ref.watch(
downloadQueueLookupProvider.select(
@@ -85,8 +82,8 @@ class TrackListTile extends ConsumerWidget {
style: TrackCardStyle.flat,
isSelectionMode: isSelectionMode,
isSelected: isSelected,
isCurrent: playback?.isCurrent ?? false,
isPlaying: playback?.isPlaying ?? false,
isCurrent: playback.isCurrent,
isPlaying: playback.isPlaying,
leadingArtwork: leadingArtwork,
leading: leading,
title: track.name,
+54
View File
@@ -190,4 +190,58 @@ void main() {
], contains(_title));
});
}
testWidgets('a CUE virtual track opens its details on a tap and keeps its '
'play button', (tester) async {
SharedPreferences.setMockInitialValues({});
final log = <String>[];
Widget row(String name, String path) => Consumer(
builder: (context, ref, _) => Row(
children: [
TextButton(
onPressed: songRowTap(
ref,
path: path,
openDetails: () => log.add('details $name'),
play: () => log.add('play $name'),
),
child: Text('row $name'),
),
SongRowButton(
path: path,
playButton: Text('play button $name'),
onOpenDetails: () {},
),
],
),
);
await tester.pumpWidget(
ProviderScope(
overrides: [
initialSettingsProvider.overrideWithValue(const AppSettings()),
],
child: MaterialApp(
theme: AppTheme.light(),
localizationsDelegates: appLocalizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: Column(
children: [
row('song', '/music/song.flac'),
row('cue', '/music/album.cue#track02'),
],
),
),
),
),
);
await tester.pump();
await tester.tap(find.text('row song'));
await tester.tap(find.text('row cue'));
expect(log, ['play song', 'details cue']);
// The song's button opens the details; the CUE track's still plays.
expect(find.text('play button song'), findsNothing);
expect(find.text('play button cue'), findsOneWidget);
});
}
+21 -5
View File
@@ -164,6 +164,19 @@ TrackCard _card(WidgetTester tester, String title) => tester.widget<TrackCard>(
find.ancestor(of: find.text(title), matching: find.byType(TrackCard)),
);
/// Mornye marks the current row with its title's colour alone.
void _expectOnlyCurrentAccented(WidgetTester tester) {
Color? titleColor(String title) =>
tester.widget<Text>(find.text(title)).style?.color;
final accent = Theme.of(
tester.element(find.text('Current song')),
).colorScheme.primary;
expect(titleColor('Current song'), accent);
expect(titleColor('Other song'), isNot(accent));
expect(titleColor('Same id song'), isNot(accent));
expect(find.byType(NowPlayingIndicator), findsNothing);
}
void _expectOnlyCurrentMarked(WidgetTester tester) {
expect(_card(tester, 'Current song').isCurrent, isTrue);
expect(_card(tester, 'Other song').isCurrent, isFalse);
@@ -205,11 +218,12 @@ void main() {
expect(find.byType(NowPlayingIndicator), findsNothing);
});
testWidgets('Mornye rows show no current-track state', (tester) async {
testWidgets('Mornye rows show only the current title in the accent', (
tester,
) async {
await tester.pumpWidget(_app(list(), mornye: true));
await _pumpFor(tester);
expect(_card(tester, 'Current song').isCurrent, isFalse);
expect(find.byType(NowPlayingIndicator), findsNothing);
_expectOnlyCurrentAccented(tester);
});
});
@@ -370,7 +384,9 @@ void main() {
});
}
testWidgets('Mornye rows show no current-track state', (tester) async {
testWidgets('Mornye rows show only the current title in the accent', (
tester,
) async {
await tester.pumpWidget(
_app(
results(),
@@ -380,7 +396,7 @@ void main() {
),
);
await _pumpFor(tester);
expect(find.byType(NowPlayingIndicator), findsNothing);
_expectOnlyCurrentAccented(tester);
});
});
}
+9 -1
View File
@@ -578,7 +578,9 @@ void main() {
expect(find.byType(NowPlayingIndicator), findsOneWidget);
});
testWidgets('Mornye ignores the current track', (tester) async {
testWidgets('Mornye shows the current track in its title colour alone', (
tester,
) async {
await tester.pumpWidget(_app(card(current: true), mornye: true));
await tester.pump();
@@ -588,6 +590,12 @@ void main() {
);
expect(surface.color, Colors.transparent);
expect(_textStyle(tester, 'Song')?.fontWeight, FontWeight.w500);
final accent = _scheme(tester, find.text('Song')).primary;
expect(_textStyle(tester, 'Song')?.color, accent);
await tester.pumpWidget(_app(card(), mornye: true));
await tester.pump();
expect(_textStyle(tester, 'Song')?.color, isNot(accent));
});
testWidgets('Mornye keeps its selection tint', (tester) async {