983a9d92be
Track row (album detail): - Vertical padding 10→6 and only render the artist line when non-empty, so tracks without a populated artist row don't reserve a blank line. - Number column 28→22 — visually tighter without making 3-digit numbers cramp. Mini player missing artist: - Symptom was an empty `artist` field on MediaItem after tapping a track in album detail; layout change wasn't the cause. Real cause: albumProvider's cold-cache only wrote cachedAlbums + cachedTracks, never cachedArtists. The drift JOINs that build the AlbumRef + each TrackRef returned null for the artist row, so artistName fell back to '' and the audio handler stamped MediaItem.artist=''. - Cold-cache now collects every distinct (artistId, artistName) pair off the album header + each track, inserts them into cachedArtists alongside the album/tracks. Subsequent JOINs populate artistName, the audio handler stamps it on MediaItem, and the mini player picks it up via the existing artistName.isNotEmpty render. - Existing cached albums won't get artist names until they're re-fetched (cache invalidation TBD). Future cold-cache hits will. Artist detail album grid: - AlbumCard gains showArtist (default true). Pass false in the artist detail grid since the page header already names the artist. cellH trimmed by the 16dp artist line.
80 lines
2.6 KiB
Dart
80 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../models/track.dart';
|
|
import '../../shared/widgets/track_actions/track_actions_button.dart';
|
|
import '../../theme/theme_extension.dart';
|
|
import 'cached_indicator.dart';
|
|
|
|
class TrackRow extends StatelessWidget {
|
|
const TrackRow({
|
|
required this.track,
|
|
required this.onTap,
|
|
this.trailing,
|
|
this.actions = true,
|
|
super.key,
|
|
});
|
|
final TrackRef track;
|
|
final VoidCallback onTap;
|
|
final Widget? trailing;
|
|
|
|
/// Render the 3-dot TrackActionsButton at the end of the row. Default
|
|
/// true; pass false in surfaces that don't want the menu (e.g. when
|
|
/// showing a static read-only list).
|
|
final bool actions;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final fs = Theme.of(context).extension<FabledSwordTheme>()!;
|
|
final mins = (track.durationSec ~/ 60).toString().padLeft(2, '0');
|
|
final secs = (track.durationSec % 60).toString().padLeft(2, '0');
|
|
return InkWell(
|
|
onTap: onTap,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
|
child: Row(children: [
|
|
if (track.trackNumber != null)
|
|
SizedBox(
|
|
width: 22,
|
|
child: Text(
|
|
track.trackNumber.toString(),
|
|
style: TextStyle(color: fs.ash, fontSize: 13),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
track.title,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(color: fs.parchment, fontSize: 14),
|
|
),
|
|
// Skip the artist line entirely when empty so the row
|
|
// height collapses to a single line of title — keeps
|
|
// dense album views from looking padded.
|
|
if (track.artistName.isNotEmpty)
|
|
Text(
|
|
track.artistName,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(color: fs.ash, fontSize: 12),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
CachedIndicator(trackId: track.id),
|
|
Text('$mins:$secs', style: TextStyle(color: fs.ash, fontSize: 12)),
|
|
if (trailing != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8),
|
|
child: trailing!,
|
|
),
|
|
if (actions) TrackActionsButton(track: track),
|
|
]),
|
|
),
|
|
);
|
|
}
|
|
}
|