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