import 'package:flutter/material.dart'; import '../../models/track.dart'; import '../../shared/widgets/track_actions/track_actions_button.dart'; import '../../theme/theme_extension.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()!; 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), ), ]), ), 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), ]), ), ); } }