5114a8118c
CachedIndicator (lib/library/widgets/cached_indicator.dart) — small
download glyph rendered next to a track row when AudioCacheManager
reports the track as cached. FutureBuilder one-shot.
Wiring:
- track_row.dart: render CachedIndicator before the duration label
- playlist_detail: 'Download' OutlinedButton next to Play; pins all
playable tracks with source: autoPlaylist + SnackBar feedback
- album_detail: 'Download' IconButton in the header; same pin pattern
- app.dart: now ConsumerStatefulWidget — initState fires the initial
sync + activates the prefetcher provider
Together these complete the operator-facing surfaces of the offline
slice: visible cache state, explicit download trigger, automatic
sync + queue-ahead prefetch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
72 lines
2.2 KiB
Dart
72 lines
2.2 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: 10),
|
|
child: Row(children: [
|
|
if (track.trackNumber != null)
|
|
SizedBox(
|
|
width: 28,
|
|
child: Text(
|
|
track.trackNumber.toString(),
|
|
style: TextStyle(color: fs.ash, fontSize: 13),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Text(
|
|
track.title,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(color: fs.parchment, fontSize: 14),
|
|
),
|
|
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),
|
|
]),
|
|
),
|
|
);
|
|
}
|
|
}
|