import 'package:flutter/material.dart';
import 'package:flutter_lucide/flutter_lucide.dart';

import '../../../models/track.dart';
import '../../../theme/theme_extension.dart';
import 'track_actions_sheet.dart';

/// Small 3-dot trigger that opens TrackActionsSheet. Drop into any
/// track row / card to expose the canonical 7-action menu.
class TrackActionsButton extends StatelessWidget {
  const TrackActionsButton({
    super.key,
    required this.track,
    this.hideQueueActions = false,
    this.onNavigate,
  });

  final TrackRef track;

  /// Suppresses Play next / Add to queue. Set true on the Now Playing
  /// screen where the menu's track IS the currently-playing one.
  final bool hideQueueActions;

  /// Forwarded to TrackActionsSheet.onNavigate. The host receives the
  /// destination path AFTER the sheet has popped and is responsible
  /// for navigating to it (typically: pop self first, then push).
  final Future<void> Function(String path)? onNavigate;

  @override
  Widget build(BuildContext context) {
    final fs = Theme.of(context).extension<FabledSwordTheme>()!;
    return IconButton(
      icon: Icon(LucideIcons.ellipsis_vertical, color: fs.ash, size: 18),
      tooltip: 'Track actions',
      onPressed: () => TrackActionsSheet.show(
        context,
        track,
        hideQueueActions: hideQueueActions,
        onNavigate: onNavigate,
      ),
    );
  }
}
