766e98fd2b
Add IsPaused/OnPause to TrackCard, make TracksGallery controlled, and drive the active track from PlayerService.CurrentTrack as the single source of truth.
26 lines
1.0 KiB
C#
26 lines
1.0 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using DeepDrftModels.DTOs;
|
|
|
|
namespace DeepDrftShared.Client.Components;
|
|
|
|
public partial class TracksGallery : ComponentBase
|
|
{
|
|
[Parameter] public IEnumerable<TrackDto> Tracks { get; set; } = [];
|
|
|
|
// Controlled play-state inputs: the parent owns playback truth (the player service)
|
|
// and drives these. The gallery is presentational — it only matches by id to decide
|
|
// which card reflects the active state.
|
|
[Parameter] public TrackDto? ActiveTrack { get; set; }
|
|
[Parameter] public bool IsPlaying { get; set; }
|
|
[Parameter] public bool IsPaused { get; set; }
|
|
|
|
[Parameter] public EventCallback<TrackDto> OnPlay { get; set; }
|
|
[Parameter] public EventCallback<TrackDto> OnPause { get; set; }
|
|
|
|
private Task HandlePlayClick(TrackDto track) =>
|
|
OnPlay.HasDelegate ? OnPlay.InvokeAsync(track) : Task.CompletedTask;
|
|
|
|
private Task HandlePauseClick(TrackDto track) =>
|
|
OnPause.HasDelegate ? OnPause.InvokeAsync(track) : Task.CompletedTask;
|
|
}
|