feat(metadata): rebuild track details on the collection header for both styles

Track details kept a hand-built hero for Material and a separate page for
Mornye, with Play and Delete as a bottom bar and one long card of facts.

- Both styles and desktop now use the collection header: cover, title,
  artist with the album below, and the meta row (quality, length, explicit
  badge, source). The header takes its colours from the artwork.
- Play is the one wide filled button in the header, between a round Edit
  metadata and a round Add to queue. Delete stays in the More menu only.
- The facts are split into Metadata, Release, Audio and File Info, built
  once for both styles, on tokens and text roles instead of literals.
  Identifiers copy on a tap; a long press still offers the copy sheet.
- A missing file shows the shared error card above the sections.
- The song change transition follows the app's motion settings.
- The service pill and its per-service icons are gone; the service is a
  row of File Info.

Tests follow the new layout. The sidecar export test also scrolls the
desktop menu to its row, which sat below the menu's fold.
This commit is contained in:
zarzet committed 2026-11-17 12:52:21 +07:00
1 parent 7b266ba2e4
commit 13a2d9c733
11 files changed
+783 -1018

No files matched your search

+8
View File
@@ -2400,6 +2400,14 @@
"@trackFileInfo": {
"description": "Tab title - file information"
},
"trackSectionRelease": "Release",
"@trackSectionRelease": {
"description": "Section title on the track details page: facts about the release the song belongs to (label, copyright, ISRC, barcode)"
},
"trackSectionAudio": "Audio",
"@trackSectionAudio": {
"description": "Section title on the track details page: facts about the sound (duration, quality, tempo, ReplayGain)"
},
"trackLyrics": "Lyrics",
"@trackLyrics": {
"description": "Tab title - lyrics"
-13
View File
@@ -308,17 +308,4 @@ extension _TrackMetadataFileActions on _TrackMetadataScreenState {
'${date.hour.toString().padLeft(2, '0')}:'
'${date.minute.toString().padLeft(2, '0')}';
}
IconData _getServiceIcon(String service) {
switch (service.toLowerCase()) {
case MusicServices.tidal:
return Icons.waves;
case MusicServices.qobuz:
return Icons.album;
case MusicServices.amazon:
return Icons.shopping_cart;
default:
return Icons.cloud_download;
}
}
}
File diff suppressed because it is too large. Load diff
+285
View File
@@ -0,0 +1,285 @@
part of 'track_metadata_screen.dart';
extension _TrackMetadataHeader on _TrackMetadataScreenState {
List<Widget> _headerMetadataItems(BuildContext context) => [
if (_displayAudioQuality != null && _displayAudioQuality!.isNotEmpty)
HeaderMetaItem(_displayAudioQuality!),
if (duration != null) HeaderMetaItem(formatClock(duration!)),
// The header's title is plain text, so the badge sits with the details.
if (isExplicit)
Builder(
builder: (header) =>
ExplicitBadge(colorScheme: HeaderPalette.of(header)),
),
if (_service == 'local')
HeaderMetaItem(
context.l10n.librarySourceLocal,
icon: context.isMornye ? CupertinoIcons.folder : Icons.folder,
)
else if (_service.isNotEmpty)
HeaderMetaItem(_service[0].toUpperCase() + _service.substring(1)),
];
/// The header albums and playlists have, for one song: its cover, title,
/// artist and album, the file's quality and the song's main actions. The
/// rest of the actions stay in the More menu.
///
/// The slivers go straight into the page's scroll view, so the toolbar
/// stays pinned once the cover and details have scrolled away.
List<Widget> _buildHeader(BuildContext context, ColorScheme colorScheme) {
final coverCacheWidth = coverCacheWidthForViewport(context);
final backdropCacheWidth = metadataBackdropCacheExtent(context);
// Downloaded-item entry points must await resolveOrExtract before pushing
// this route. That precondition keeps the Hero, foreground, and backdrop
// on one source from the first frame; this synchronous lookup also covers
// cached rebuilds and in-screen swipe navigation.
final sharedEmbeddedCoverPath = _hasPath(_embeddedCoverPreviewPath)
? _embeddedCoverPreviewPath
: DownloadedEmbeddedCoverResolver.resolve(_filePath);
final artworkSource = resolveMetadataArtworkSource(
embeddedCoverPath: sharedEmbeddedCoverPath,
localCoverPath: _localCoverPath,
remoteCoverUrl: _coverUrl,
);
Widget placeholder(double iconSize) => ColoredBox(
color: colorScheme.surfaceContainerHighest,
child: Center(
child: AppIcon.adaptive(
Icons.music_note,
size: iconSize,
color: colorScheme.onSurfaceVariant,
),
),
);
Widget artworkImage({
required int cacheWidth,
int? cacheHeight,
required double iconSize,
}) {
final source = artworkSource;
if (source == null) return placeholder(iconSize);
if (isHttpCoverUrl(source)) {
return CachedCoverImage(
imageUrl: source,
fit: BoxFit.cover,
memCacheWidth: cacheWidth,
memCacheHeight: cacheHeight,
placeholder: (_, _) => ColoredBox(color: colorScheme.surface),
errorWidget: (_, _, _) => placeholder(iconSize),
);
}
final filePath = coverFilePath(source);
if (filePath == null) return placeholder(iconSize);
return Image.file(
File(filePath),
fit: BoxFit.cover,
cacheWidth: cacheWidth,
cacheHeight: cacheHeight,
gaplessPlayback: true,
filterQuality: FilterQuality.low,
errorBuilder: (_, _, _) => placeholder(iconSize),
);
}
// Watched here: the header builds its actions outside this build.
final showPlayer = ref.watch(playerUiEnabledProvider);
final back = HeaderCircleButton(
icon: context.isMornye ? CupertinoIcons.back : Icons.arrow_back,
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
onPressed: _popWithMetadataResult,
);
return AlbumDetailHeader(
title: trackName,
expandedHeight: calculateExpandedHeight(context),
showTitleInAppBar: false,
showTitleListenable: showTitleNotifier,
background: RepaintBoundary(
key: ValueKey<String>('metadata_backdrop_$_itemId'),
child: artworkImage(
cacheWidth: backdropCacheWidth,
cacheHeight: backdropCacheWidth,
iconSize: 80,
),
),
paletteSource: artworkSource == null || isHttpCoverUrl(artworkSource)
? artworkSource
: coverFilePath(artworkSource),
blurAndScrimBackground: artworkSource != null,
// The square cover keeps the Hero flight from a list thumbnail square.
coverBuilder: (context, coverSize) => Hero(
tag: _coverHeroTag,
child: SizedBox.square(
dimension: coverSize,
child: artworkImage(cacheWidth: coverCacheWidth, iconSize: 48),
),
),
// Built inside the header, so it reads the header's artwork scheme.
subtitle: Builder(builder: _buildHeaderSubtitle),
meta: HeaderMetaRow(items: _headerMetadataItems(context)),
actions: Builder(
builder: (header) => _buildHeaderActions(header, showPlayer),
),
appBarActions: [
Builder(
builder: (buttonContext) => HeaderCircleButton(
icon: context.isMornye ? CupertinoIcons.ellipsis : Icons.more_vert,
tooltip: MaterialLocalizations.of(context).showMenuTooltip,
onPressed: () => _showOptionsMenu(
context,
ref,
colorScheme,
anchor: mornyeMenuAnchor(buttonContext),
),
),
),
],
// Centered so the tight leading slot of Material cannot stretch it.
leading: context.isMornye || isDesktopPlatform
? back
: Center(child: back),
).buildSlivers(context);
}
/// The artist with the album on a line below it, each cut short on its
/// own so a long artist does not push the album out.
Widget _buildHeaderSubtitle(BuildContext header) {
final scheme = HeaderPalette.of(header);
final mornye = header.isMornye;
final artistStyle = isDesktopPlatform
? desktopDetailSubtitleStyle(header)
: Theme.of(header).textTheme.titleMedium?.copyWith(
color: mornye
? Theme.of(header).colorScheme.primary
: scheme.onSurfaceVariant,
fontWeight: mornye ? FontWeight.w400 : FontWeight.w600,
);
final album = albumName.trim();
Text line(String text, {TextStyle? style}) => Text(
text,
style: style,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: isDesktopPlatform ? TextAlign.start : TextAlign.center,
);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: isDesktopPlatform
? CrossAxisAlignment.start
: CrossAxisAlignment.center,
children: [
line(artistName, style: artistStyle),
if (album.isNotEmpty)
line(
album,
style: Theme.of(
header,
).textTheme.bodyMedium?.copyWith(color: scheme.onSurfaceVariant),
),
],
);
}
/// Play as the one wide filled button, between a round Edit and a round
/// Add to queue. A round button is left out where the song cannot take
/// its action; Play stays, disabled, while the file is missing.
Widget _buildHeaderActions(BuildContext header, bool showPlayer) {
final tokens = header.tokens;
final l10n = header.l10n;
final play = HeaderFilledButton(
icon: Icons.play_arrow,
label: l10n.trackMetadataPlay,
onPressed: _fileExists ? () => _openFile(context, rawFilePath) : null,
);
final edit = _canEditMetadataFile
? HeaderCircleButton(
icon: Icons.edit_outlined,
tooltip: l10n.trackEditMetadata,
tonal: true,
onPressed: () => _showEditMetadataSheet(
context,
ref,
Theme.of(context).colorScheme,
),
)
: null;
final queue = _fileExists && showPlayer
? HeaderCircleButton(
icon: Icons.playlist_add,
tooltip: l10n.trackAddToQueue,
tonal: true,
onPressed: () => _enqueueThis(ref, playNext: false),
)
: null;
if (isDesktopPlatform) {
return Row(
mainAxisSize: MainAxisSize.min,
spacing: tokens.gapSm,
children: [play, ?edit, ?queue],
);
}
if (header.isMornye) {
return Row(
spacing: tokens.gapMd,
children: [
?edit,
Expanded(child: play),
?queue,
],
);
}
// Tablets keep the row the width it has on a phone.
return Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 460),
child: ExpressiveButtonGroup(
flexible: {edit == null ? 0 : 1},
spacing: tokens.gapMd,
slotWidth: tokens.minTouchTarget,
children: [?edit, play, ?queue],
),
),
);
}
RoundedRectangleBorder _sectionCardShape(
BuildContext context,
ColorScheme colorScheme,
) {
return RoundedRectangleBorder(
borderRadius: context.tokens.borderRadiusCard,
side: BorderSide(
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
),
);
}
/// The surface of one section of the page, shared by both styles.
Widget _metadataSectionSurface(
BuildContext context,
ColorScheme scheme, {
required Widget child,
}) {
if (context.isMornye) {
return Material(
color: MornyeTheme.controlFill(context),
// The radius of Mornye's grouped lists (see SettingsGroup).
borderRadius: BorderRadius.circular(28),
clipBehavior: Clip.antiAlias,
child: DividerTheme(
data: DividerTheme.of(
context,
).copyWith(color: MornyeTheme.metadataDividerColor(context)),
child: child,
),
);
}
return Card(
elevation: 0,
color: settingsGroupColor(context),
shape: _sectionCardShape(context, scheme),
child: child,
);
}
}
+2 -8
View File
@@ -10,20 +10,14 @@ extension _TrackMetadataLyricsAndSaving on _TrackMetadataScreenState {
context,
colorScheme,
child: Padding(
padding: const EdgeInsets.all(20),
padding: const EdgeInsets.all(_trackMetadataSectionPadding),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
context.l10n.trackLyrics,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
color: colorScheme.onSurface,
),
),
child: _buildSectionTitle(context, context.l10n.trackLyrics),
),
if (hasDisplayLyrics)
AppIconButton(
-199
View File
@@ -1,199 +0,0 @@
part of 'track_metadata_screen.dart';
extension _TrackMetadataMornye on _TrackMetadataScreenState {
Widget _buildMornyePage(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final artwork = resolveMetadataArtworkSource(
embeddedCoverPath:
_embeddedCoverPreviewPath ??
DownloadedEmbeddedCoverResolver.resolve(_filePath),
localCoverPath: _localCoverPath,
remoteCoverUrl: _coverUrl,
);
return GestureDetector(
behavior: HitTestBehavior.translucent,
onHorizontalDragEnd: _handleHorizontalDragEnd,
child: Scaffold(
body: CustomScrollView(
controller: scrollController,
slivers: [
SliverAppBar(
pinned: true,
centerTitle: true,
title: Text(context.l10n.trackMetadata),
leadingWidth: 64,
leading: Padding(
padding: const EdgeInsetsDirectional.only(start: 16),
child: HeaderCircleButton(
icon: CupertinoIcons.back,
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
onPressed: _popWithMetadataResult,
),
),
actionsPadding: const EdgeInsetsDirectional.only(end: 16),
actions: [
Builder(
builder: (buttonContext) => HeaderCircleButton(
icon: CupertinoIcons.ellipsis,
tooltip: MaterialLocalizations.of(context).showMenuTooltip,
onPressed: () => _showOptionsMenu(
context,
ref,
scheme,
anchor: mornyeMenuAnchor(buttonContext),
),
),
),
],
),
SliverToBoxAdapter(
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: adaptiveContentMaxWidth(
MediaQuery.sizeOf(context).width,
),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 24, 24, 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 320),
child: AspectRatio(
aspectRatio: 1,
child: Hero(
tag: _coverHeroTag,
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: PlayerArtwork(
artUri: artwork,
colorScheme: scheme,
iconSize: 80,
cacheWidth:
(320 *
MediaQuery.devicePixelRatioOf(
context,
))
.round()
.clamp(320, 1280),
),
),
),
),
),
),
const SizedBox(height: 20),
ExplicitTrackTitle(
title: trackName,
explicit: isExplicit,
style: theme.textTheme.titleLarge,
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 5),
Text(
artistName,
textAlign: TextAlign.center,
style: theme.textTheme.bodyLarge?.copyWith(
color: scheme.onSurfaceVariant,
),
),
if (albumName.trim().isNotEmpty)
Text(
albumName,
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.bodyMedium?.copyWith(
color: scheme.onSurfaceVariant,
),
),
const SizedBox(height: 12),
// Centered under the title; desktop detail headers
// start the row at the leading edge instead.
Center(
child: HeaderMetaRow(
items: _headerMetadataItems(context),
),
),
const SizedBox(height: 16),
// Keep header buttons within the title column.
Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 400),
child: _buildActionButtons(
context,
ref,
scheme,
_fileExists,
),
),
),
if (_fileAccessMessage(context) case final message?)
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(
message,
style: theme.textTheme.bodyMedium?.copyWith(
color: scheme.error,
),
),
),
],
),
),
),
),
),
SliverToBoxAdapter(
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: _trackMetadataContentMaxWidth(
MediaQuery.sizeOf(context).width,
),
),
child: _buildAnimatedTrackContent(context, ref, scheme),
),
),
),
SliverToBoxAdapter(
child: SizedBox(height: context.navBarBottomInset),
),
],
),
),
);
}
Widget _metadataSectionSurface(
BuildContext context,
ColorScheme scheme, {
required Widget child,
}) {
if (context.isMornye) {
return Material(
color: MornyeTheme.controlFill(context),
borderRadius: BorderRadius.circular(28),
clipBehavior: Clip.antiAlias,
child: DividerTheme(
data: DividerTheme.of(
context,
).copyWith(color: MornyeTheme.metadataDividerColor(context)),
child: child,
),
);
}
return Card(
elevation: 0,
color: settingsGroupColor(context),
shape: _sectionCardShape(scheme),
child: child,
);
}
}
+26 -168
View File
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:io';
import 'dart:math' as math;
import 'dart:ui' show ImageFilter;
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart' show defaultTargetPlatform;
import 'package:material_ui/material_ui.dart';
@@ -10,6 +9,8 @@ import 'package:mornye/widgets/app_alert_dialog.dart';
import 'package:cupertino_ui/cupertino_ui.dart'
show CupertinoButton, CupertinoIcons;
import 'package:mornye/widgets/app_bottom_sheet.dart';
import 'package:mornye/theme/app_motion.dart';
import 'package:mornye/widgets/app_icon.dart';
import 'package:mornye/widgets/app_icon_button.dart';
import 'package:mornye/widgets/app_loading_indicator.dart';
import 'package:mornye/widgets/app_snack_bar.dart';
@@ -82,8 +83,17 @@ import 'package:mornye/theme/cover_palette.dart' show HeaderPalette;
import 'package:mornye/theme/mornye_theme.dart';
import 'package:mornye/theme/mornye_icons.dart';
import 'package:mornye/widgets/album_detail_header.dart'
show HeaderMetaRow, HeaderMetaItem, HeaderCircleButton, HeaderFilledButton;
show
AlbumDetailHeader,
HeaderMetaRow,
HeaderMetaItem,
HeaderCircleButton,
HeaderFilledButton;
import 'package:mornye/widgets/desktop/context_menu.dart';
import 'package:mornye/widgets/desktop/detail_header.dart'
show desktopDetailSubtitleStyle;
import 'package:mornye/widgets/error_card.dart';
import 'package:mornye/widgets/expressive_button_group.dart';
import 'package:mornye/widgets/link/link_actions.dart';
import 'package:mornye/widgets/link/link_library_actions.dart';
import 'package:mornye/services/link/features/link_track_refs.dart';
@@ -91,10 +101,9 @@ import 'package:mornye/services/link/link_library_jobs.dart';
import 'package:mornye/services/link/link_protocol.dart';
import 'package:mornye/widgets/mornye_context_menu.dart';
import 'package:mornye/widgets/mornye_metadata_row.dart';
import 'package:mornye/widgets/player_artwork.dart';
import 'package:mornye/widgets/audio_analysis_widget.dart';
import 'package:mornye/widgets/audio_quality_badges.dart' show ExplicitBadge;
import 'package:mornye/widgets/hires_check_card.dart';
import 'package:mornye/widgets/audio_quality_badges.dart';
import 'package:mornye/widgets/batch_convert_sheet.dart';
import 'package:mornye/widgets/cached_cover_image.dart';
import 'package:mornye/widgets/open_on_platform_sheet.dart';
@@ -115,7 +124,7 @@ import 'package:mornye/screens/track_metadata_edit_sheet.dart';
part 'track_metadata_screen_cover.dart';
part 'track_metadata_screen_display.dart';
part 'track_metadata_screen_menu.dart';
part 'track_metadata_mornye.dart';
part 'track_metadata_header.dart';
part 'track_metadata_cards.dart';
part 'track_metadata_lyrics.dart';
@@ -129,8 +138,15 @@ class _MetadataItem {
final String value;
final String rawValue;
_MetadataItem(this.label, this.value, {String? rawValue})
: rawValue = rawValue ?? value;
/// Whether a tap copies the value, for identifiers people paste elsewhere.
final bool copyable;
_MetadataItem(
this.label,
this.value, {
String? rawValue,
this.copyable = false,
}) : rawValue = rawValue ?? value;
}
class _EmbeddedCoverPreviewCacheEntry {
@@ -308,13 +324,8 @@ class _TrackMetadataScreenState extends ConsumerState<TrackMetadataScreen>
@override
double calculateExpandedHeight(BuildContext context) {
final mediaSize = MediaQuery.sizeOf(context);
// Desktop windows are wide and short, so the header takes more of the
// height to leave the cover room (see _buildHeaderBackground).
if (isDesktopPlatform) {
return (mediaSize.height * 0.62).clamp(440.0, 640.0);
}
return (mediaSize.height * 0.55).clamp(360.0, 520.0);
// The header of an album, plus the line that names the song's album.
return collectionHeaderExpandedHeight(context) + 20;
}
Future<void> _checkFile() async {
@@ -793,11 +804,8 @@ class _TrackMetadataScreenState extends ConsumerState<TrackMetadataScreen>
@override
Widget build(BuildContext context) {
if (context.isMornye) return _buildMornyePage(context);
final colorScheme = Theme.of(context).colorScheme;
final expandedHeight = calculateExpandedHeight(context);
final bottomInset = context.navBarBottomInset;
final edgeInset = detailHeaderEdgeInset(context);
return GestureDetector(
behavior: HitTestBehavior.translucent,
@@ -806,81 +814,7 @@ class _TrackMetadataScreenState extends ConsumerState<TrackMetadataScreen>
body: CustomScrollView(
controller: scrollController,
slivers: [
SliverAppBar(
expandedHeight: expandedHeight,
pinned: true,
stretch: true,
backgroundColor: colorScheme.surface,
surfaceTintColor: Colors.transparent,
title: ValueListenableBuilder(
valueListenable: showTitleNotifier,
builder: (_, showTitle, title) => AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: showTitle ? 1.0 : 0.0,
child: title,
),
child: ExplicitTrackTitle(
title: trackName,
explicit: isExplicit,
style: TextStyle(
color: colorScheme.onSurface,
fontWeight: FontWeight.w600,
fontSize: 16,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
flexibleSpace: LayoutBuilder(
builder: (context, constraints) {
final collapseRatio =
(constraints.maxHeight - kToolbarHeight) /
(expandedHeight - kToolbarHeight);
final showContent = collapseRatio > 0.3;
return FlexibleSpaceBar(
collapseMode: CollapseMode.pin,
background: _buildHeaderBackground(
context,
colorScheme,
expandedHeight,
showContent,
),
stretchModes: const [StretchMode.zoomBackground],
);
},
),
leadingWidth: kToolbarHeight + edgeInset,
leading: Padding(
padding: EdgeInsetsDirectional.only(start: edgeInset),
// Centered so the tight leading slot cannot stretch it.
child: Center(
child: HeaderCircleButton(
icon: Icons.arrow_back,
tooltip: MaterialLocalizations.of(
context,
).backButtonTooltip,
onPressed: _popWithMetadataResult,
),
),
),
actionsPadding: EdgeInsetsDirectional.only(end: edgeInset),
actions: [
Builder(
builder: (buttonContext) => HeaderCircleButton(
icon: Icons.more_vert,
tooltip: MaterialLocalizations.of(context).showMenuTooltip,
onPressed: () => _showOptionsMenu(
context,
ref,
colorScheme,
anchor: mornyeMenuAnchor(buttonContext),
),
),
),
],
),
..._buildHeader(context, colorScheme),
SliverToBoxAdapter(
child: Center(
child: ConstrainedBox(
@@ -928,82 +862,6 @@ class _TrackMetadataScreenState extends ConsumerState<TrackMetadataScreen>
),
);
}
Widget _buildActionButtons(
BuildContext context,
WidgetRef ref,
ColorScheme colorScheme,
bool fileExists,
) {
if (context.isMornye) {
return Row(
children: [
Expanded(
child: HeaderFilledButton(
icon: CupertinoIcons.play_fill,
label: context.l10n.trackMetadataPlay,
onPressed: fileExists
? () => _openFile(context, rawFilePath)
: null,
),
),
if (_canDeleteFile) ...[
const SizedBox(width: 12),
Expanded(
child: HeaderFilledButton(
icon: CupertinoIcons.trash,
label: context.l10n.trackMetadataDelete,
onPressed: () => _confirmDelete(context, ref, colorScheme),
),
),
],
],
);
}
return Row(
children: [
Expanded(
flex: 2,
child: ExpressiveButton(
onPressed: fileExists
? () => _openFile(context, rawFilePath)
: null,
icon: const Icon(Icons.play_arrow),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
child: Text(context.l10n.trackMetadataPlay),
),
),
if (_canDeleteFile) ...[
const SizedBox(width: 12),
Expanded(
child: ExpressiveButton(
outlined: true,
onPressed: () => _confirmDelete(context, ref, colorScheme),
icon: Icon(Icons.delete_outline, color: colorScheme.error),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
side: BorderSide(
color: colorScheme.error.withValues(alpha: 0.5),
),
),
child: Text(
context.l10n.trackMetadataDelete,
style: TextStyle(color: colorScheme.error),
),
),
),
],
],
);
}
}
class _MetadataOption {
+26 -3
View File
@@ -9,6 +9,7 @@ import 'package:mornye/l10n/l10n.dart';
import 'package:mornye/providers/download_history_provider.dart';
import 'package:mornye/screens/track_metadata_screen.dart';
import 'package:mornye/services/library_database.dart';
import 'package:mornye/theme/cover_palette.dart' show HeaderPalette;
import 'package:mornye/widgets/album_detail_header.dart';
import 'package:mornye/widgets/audio_quality_badges.dart';
import 'package:mornye/theme/mornye_theme.dart';
@@ -115,6 +116,13 @@ void main() {
expect(find.byIcon(CupertinoIcons.back), findsOneWidget);
expect(find.byIcon(CupertinoIcons.ellipsis), findsOneWidget);
expect(find.byType(Card), findsNothing);
// The sections are built as they scroll in, below the header.
await tester.scrollUntilVisible(
find.text('Track name'),
300,
scrollable: find.byType(Scrollable).first,
);
await tester.pumpAndSettle();
final row = find.widgetWithText(MornyeMetadataRow, 'Track name');
expect(
find.ancestor(of: row, matching: find.byType(MornyeGlass)),
@@ -187,13 +195,23 @@ void main() {
final headerMeta = find.byType(HeaderMetaRow);
expect(headerMeta, findsOneWidget);
expect(find.byType(ExplicitBadge), findsNWidgets(2));
expect(
find.descendant(of: headerMeta, matching: find.byType(ExplicitBadge)),
findsOneWidget,
);
expect(find.text('Explicit'), findsNothing);
// The header takes its colors from the artwork over the theme's surface,
// so the details are dark on light here instead of white on a scrim.
final scheme = HeaderPalette.of(tester.element(headerMeta));
expect(
scheme.surface.computeLuminance() - scheme.onSurface.computeLuminance(),
greaterThan(0.5),
);
for (final label in const ['16-bit/44.1kHz', '4:10', 'Provider-a']) {
final text = tester.widget<Text>(
find.descendant(of: headerMeta, matching: find.text(label)),
);
expect(text.style?.color, Colors.white);
expect(text.style?.color, scheme.onSurface);
}
final separators = tester.widgetList<Text>(
@@ -201,10 +219,15 @@ void main() {
);
expect(separators, isNotEmpty);
expect(
separators.every((text) => text.style?.color == Colors.white70),
separators.every((text) => text.style?.color == scheme.onSurfaceVariant),
isTrue,
);
await tester.scrollUntilVisible(
find.text('Duration'),
300,
scrollable: find.byType(Scrollable).first,
);
final durationLabel = find.text('Duration');
final metadataRow = find
.ancestor(of: durationLabel, matching: find.byType(Row))
+68 -6
View File
@@ -35,6 +35,11 @@ class _Player extends MusicPlayerController {
@override
Future<void> playSingle(PlayableMedia item) async => played.add(item);
final queued = <PlayableMedia>[];
@override
Future<void> addToQueue(PlayableMedia item) async => queued.add(item);
}
void main() {
@@ -136,12 +141,7 @@ void main() {
),
);
} else {
await tester.scrollUntilVisible(
find.text('Play').hitTestable(),
300,
scrollable: find.byType(Scrollable).first,
);
await tester.pumpAndSettle();
// Play is in the header, on the first screen.
await tester.tap(find.text('Play'));
}
await tester.pumpAndSettle();
@@ -181,5 +181,67 @@ void main() {
}
}
}
for (final exists in [true, false]) {
testWidgets('metadata header holds the song actions '
'(Mornye=$mornye, file exists=$exists)', (tester) async {
await tester.binding.setSurfaceSize(const Size(393, 852));
addTearDown(() => tester.binding.setSurfaceSize(null));
if (!exists) {
messenger.setMockMethodCallHandler(channel, (call) async {
return switch (call.method) {
'safStat' => jsonEncode({'exists': false}),
_ => null,
};
});
}
final player = _Player();
await tester.pumpWidget(
ProviderScope(
overrides: [
settingsProvider.overrideWith(_Settings.new),
musicPlayerControllerProvider.overrideWithValue(player),
],
child: MaterialApp(
theme: mornye
? MornyeTheme.build(Brightness.dark)
: AppTheme.dark(),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: TrackMetadataScreen(
localItem: LocalLibraryItem(
id: 'local-song',
trackName: 'Song',
artistName: 'Artist',
albumName: 'Album',
filePath: 'content://library/document/song.flac',
scannedAt: DateTime(2026),
format: 'flac',
),
),
),
),
);
await tester.pumpAndSettle();
// Play stays where it is; the round actions need the file.
expect(find.text('Play'), findsOneWidget);
final round = exists ? findsOneWidget : findsNothing;
expect(findByTooltip('Edit Metadata'), round);
expect(findByTooltip('Add to queue'), round);
// Delete is kept to the More menu.
expect(find.text('Delete'), findsNothing);
await tester.tap(find.text('Play'));
await tester.pumpAndSettle();
expect(player.played, hasLength(exists ? 1 : 0));
if (exists) {
await tester.tap(findByTooltip('Add to queue'));
await tester.pumpAndSettle();
expect(player.queued.single.title, 'Song');
}
expect(tester.takeException(), isNull);
});
}
}
}
@@ -225,6 +225,9 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text(label), findsOneWidget);
// A long menu scrolls, and these rows start below its fold.
await tester.ensureVisible(find.text(label));
await tester.pumpAndSettle();
await tester.tap(find.text(label));
await _settleIo(tester);
expect(
+2 -3
View File
@@ -39,9 +39,8 @@ void main() {
await tester.pump();
await tester.pump(const Duration(milliseconds: 300));
// Mornye also names the page "Metadata" in its navigation bar.
final metadata = tester.getTopLeft(find.text('Metadata').last);
final lyrics = tester.getTopLeft(find.text('Lyrics').last);
final metadata = tester.getTopLeft(find.text('Metadata'));
final lyrics = tester.getTopLeft(find.text('Lyrics'));
if (twoColumns) {
expect(lyrics.dx, greaterThan(metadata.dx + 400));
expect(lyrics.dy, moreOrLessEquals(metadata.dy, epsilon: 1));