@using Toolbelt.Blazor.PWA.Updater
@using Toolbelt.Blazor.PWA.Updater.Service
@inherits LayoutComponentBase
@inject IPWAUpdaterService PwaUpdaterService
<style>
    body .pwa-updater[b-pwa-updater] {
        --pwa-updater-bar-height: 40px;
        --pwa-updater-font-size: 16px;
        --pwa-updater-bar-color: rgba(253, 216, 53, 1);
        --pwa-updater-bar-backcolor: #444;
        padding-top: 35px;
        padding-right: 10px;
        padding-bottom: 35px;
        padding-left: 10px;
    }

    body .pwa-updater-updatenow-button {
        border: dashed 2px rgba(253, 216, 53, 1) !important;
        font-family: iranyekan !important;
        font-weight:800 !important;
    }

    body .pwa-updater-close-button {
        color:#fff !important;
    }
</style>
<MudRTLProvider RightToLeft="true">
    <MudThemeProvider Theme="MyCustomTheme" />
    <MudDialogProvider />
    <MudSnackbarProvider />

    <MudLayout>
        <div>
            @Body
            <div dir="ltr">
                <PWAUpdater Text="@_updateText" ButtonCaption="اپدیت کنید" />
            </div>
        </div>
    </MudLayout>
</MudRTLProvider>
@code
{
    MudTheme MyCustomTheme = new MudTheme()
        {
            Palette = new PaletteLight()
            {
                Primary = "#356859",
                Secondary = "#FD5523",
            },
            PaletteDark = new PaletteDark()
            {
                Primary = "#356859",
                Secondary = "#FD5523",
            }
        };

    private string _updateText = "! نسخه جدید داکیومد رسید";
    protected override void OnInitialized()
    {
        string? version = typeof(Program)?.Assembly.GetName()?.Version?.ToString();
        if (version != null)
            _updateText = $"نسخه جدید داکیومد رسید - {version}";


        base.OnInitialized();
    }
}
