@page "/mixes/{Id:long}"
@using DeepDrftPublic.Client.Controls
@inherits ReleaseDetailBase

<PageTitle>@(ViewModel.Release?.Title ?? "Mix") - DeepDrft</PageTitle>

@if (ViewModel.IsLoading)
{
    <div class="deepdrft-track-detail-container">
        <div class="deepdrft-track-detail-masthead">
            <MudSkeleton SkeletonType="SkeletonType.Text" Width="70%" Height="56px" />
            <MudSkeleton SkeletonType="SkeletonType.Text" Width="40%" Height="32px" />
        </div>
    </div>
}
else if (ViewModel.NotFound || ViewModel.Release is null)
{
    <div class="deepdrft-track-detail-container">
        <div class="deepdrft-track-detail-masthead">
            <MudText Typo="Typo.h4" Align="Align.Center">Mix not found.</MudText>
            <div class="d-flex justify-center mt-4">
                <MudButton Href="/mixes"
                           Variant="Variant.Text"
                           StartIcon="@Icons.Material.Filled.ArrowBack">
                    All mixes
                </MudButton>
            </div>
        </div>
    </div>
}
else
{
    var release = ViewModel.Release;
    var hasGenre = release.Genre is not null;
    var hasDate = release.ReleaseDate is not null;

    @* Full-page waveform sits behind the scaffold content. The scaffold's container is positioned
       above it via the mix-detail-foreground stacking context. *@
    <MixWaveformVisualizer ReleaseId="@release.Id" />

    <div class="mix-detail-foreground">
        <ReleaseDetailScaffold Title="@release.Title"
                               Artist="@release.Artist"
                               Track="@ViewModel.Track"
                               BackHref="/mixes"
                               BackLabel="All mixes"
                               ShowMeta="@(hasGenre || hasDate)">
            <MetaContent>
                @if (hasGenre)
                {
                    <div>
                        <MudChip T="string" Variant="Variant.Outlined" Color="Color.Tertiary" Class="deepdrft-genre-chip">
                            @release.Genre
                        </MudChip>
                    </div>
                }
                @if (hasDate)
                {
                    <div>
                        <MudText Typo="Typo.overline">Released</MudText>
                        <MudText Typo="Typo.body1">@release.ReleaseDate!.Value.ToString("MMMM yyyy")</MudText>
                    </div>
                }
            </MetaContent>
        </ReleaseDetailScaffold>
    </div>
}

@code {
    protected override string PersistKey => "mix-detail";
}
