wabbajack/Wabbajack.App.Blazor/Components/TopBar.razor
Unnoen 47ffa30222
Restructure installing stage into three pages. Changed some design.
Added getBlobUrlFromStream JavaScript function so we can reuse the URL.
2022-01-27 18:55:07 +11:00

53 lines
1.6 KiB
Plaintext

@using Wabbajack.App.Blazor.Pages
@using Wabbajack.App.Blazor.Shared
@using Wabbajack.App.Blazor.State
@inject NavigationManager _navigationManager
@inject IStateContainer _stateContainer
@namespace Wabbajack.App.Blazor.Components
<header id="top-bar">
<nav class="@(_stateContainer.NavigationAllowed ? "" : "disallow")">
<ul>
@foreach (var (name, route) in Pages)
{
<li>
<div class="item @CurrentPage(route)" @onclick="@(() => Navigate(route))">@name</div>
</li>
}
</ul>
</nav>
<div class="settings">
<InteractionIcon Icon="images/icons/adjust.svg" Label="Settings" Size="100%" OnClick="@(() => Navigate(Settings.Route))"/>
</div>
</header>
@code {
private static readonly Dictionary<string, string> Pages = new()
{
{"Play", Play.Route},
{"Gallery", Gallery.Route},
{"Install", Select.Route},
{"Create", Create.Route}
};
private void Navigate(string page)
{
_navigationManager.NavigateTo(page);
}
protected override void OnInitialized()
{
// TODO(erri120): update this
// _navigationManager.LocationChanged += (_, _) => StateHasChanged();
// _globalState.OnNavigationStateChange += StateHasChanged;
}
private string CurrentPage(string page)
{
var relativePath = _navigationManager.ToBaseRelativePath(_navigationManager.Uri);
return page.Equals(relativePath, StringComparison.OrdinalIgnoreCase) ? "active" : string.Empty;
}
}