mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 10:27:18 +02:00
feat: implemented Mediator and added dialog service
This commit is contained in:
1 parent
ec977c490a
commit
38c631bc44
13 files changed
+188
-54
No files matched your search
@@ -1,12 +1,12 @@
|
||||
@inherits LayoutComponentBase
|
||||
@inherits MainLayoutBase
|
||||
|
||||
<RadzenDialog />
|
||||
<RadzenDialog />
|
||||
|
||||
<RadzenHeader>
|
||||
<ChildContent>
|
||||
<div class="row justify-content-start align-items-center">
|
||||
<div class="col-6 d-flex align-items-center">
|
||||
<RadzenSidebarToggle Click="@(args => { sidebarExpanded = !sidebarExpanded; bodyExpanded = !bodyExpanded; })">
|
||||
<RadzenSidebarToggle Click="@(args => InvertSideBar())">
|
||||
</RadzenSidebarToggle>
|
||||
<RadzenLabel Text="WOT Blitz statistics">
|
||||
</RadzenLabel>
|
||||
@@ -15,7 +15,7 @@
|
||||
</ChildContent>
|
||||
</RadzenHeader>
|
||||
<div style="width:100%">
|
||||
<RadzenBody @ref="@body0" @bind-Expanded="@bodyExpanded">
|
||||
<RadzenBody @ref="@Body0" @bind-Expanded="@BodyExpanded">
|
||||
<ChildContent>
|
||||
<RadzenContentContainer Name="main">
|
||||
@Body
|
||||
@@ -23,41 +23,15 @@
|
||||
</ChildContent>
|
||||
</RadzenBody>
|
||||
</div>
|
||||
<RadzenSidebar @ref="@sidebar0" @bind-Expanded="@sidebarExpanded">
|
||||
<RadzenSidebar @ref="@Sidebar0" @bind-Expanded="@SidebarExpanded">
|
||||
<ChildContent>
|
||||
<NavMenu />
|
||||
<NavMenu CloseSideBar=@InvertSideBar/>
|
||||
</ChildContent>
|
||||
</RadzenSidebar>
|
||||
<RadzenFooter>
|
||||
<ChildContent>
|
||||
<RadzenLabel Text="WOT Blitz statistics, Copyright © 2021">
|
||||
</RadzenLabel>
|
||||
<RadzenLink Text="[source]" Path="https://github.com/DrMboga/WotBlitzStatisticsBlazor" Target="_blank" Style="margin-left:5px;vertical-align:bottom;" />
|
||||
<RadzenLink Text="DrMboga" Path="https://github.com/DrMboga/WotBlitzStatisticsBlazor" Target="_blank" Style="margin-left:5px;vertical-align:bottom;" />
|
||||
</ChildContent>
|
||||
</RadzenFooter>
|
||||
|
||||
@code {
|
||||
RadzenSidebar sidebar0;
|
||||
RadzenBody body0;
|
||||
bool sidebarExpanded = false;
|
||||
bool bodyExpanded = true;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
@*if (httpContextAccessor != null && httpContextAccessor.HttpContext != null &&
|
||||
httpContextAccessor.HttpContext.Request != null && httpContextAccessor.HttpContext.Request.Headers.ContainsKey("User-Agent"))
|
||||
{
|
||||
var userAgent = httpContextAccessor.HttpContext.Request.Headers["User-Agent"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(userAgent))
|
||||
{
|
||||
if (userAgent.Contains("iPhone") || userAgent.Contains("Android") || userAgent.Contains("Googlebot"))
|
||||
{
|
||||
sidebarExpanded = false;
|
||||
bodyExpanded = true;
|
||||
}
|
||||
}
|
||||
}*@
|
||||
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Radzen;
|
||||
using Radzen.Blazor;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Blazor.Shared
|
||||
{
|
||||
public class MainLayoutBase: LayoutComponentBase
|
||||
{
|
||||
[Inject]
|
||||
private DialogService DialogService { get; set; }
|
||||
|
||||
public RadzenSidebar Sidebar0;
|
||||
public RadzenBody Body0;
|
||||
public bool SidebarExpanded { get; set; } = false;
|
||||
public bool BodyExpanded { get; set; } = true;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
//if (httpContextAccessor != null && httpContextAccessor.HttpContext != null &&
|
||||
// httpContextAccessor.HttpContext.Request != null && httpContextAccessor.HttpContext.Request.Headers.ContainsKey("User-Agent"))
|
||||
//{
|
||||
// var userAgent = httpContextAccessor.HttpContext.Request.Headers["User-Agent"].FirstOrDefault();
|
||||
// if (!string.IsNullOrEmpty(userAgent))
|
||||
// {
|
||||
// if (userAgent.Contains("iPhone") || userAgent.Contains("Android") || userAgent.Contains("Googlebot"))
|
||||
// {
|
||||
// SidebarExpanded = false;
|
||||
// BodyExpanded = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
|
||||
}
|
||||
|
||||
public void InvertSideBar()
|
||||
{
|
||||
SidebarExpanded = !SidebarExpanded;
|
||||
BodyExpanded = !BodyExpanded;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
<div>
|
||||
<RadzenPanelMenu >
|
||||
<RadzenPanelMenuItem Text="Home" Icon="home" Path="/"></RadzenPanelMenuItem>
|
||||
<RadzenPanelMenuItem Text="Counter" Icon="add_circle" Path="counter"></RadzenPanelMenuItem>
|
||||
@inherits NavMenuBase
|
||||
<div>
|
||||
<RadzenPanelMenu Click="@(MenuClicked)">
|
||||
<RadzenPanelMenuItem Text="Home" Icon="home"></RadzenPanelMenuItem>
|
||||
<RadzenPanelMenuItem Text="Search player" Icon="person_search"></RadzenPanelMenuItem>
|
||||
<RadzenPanelMenuItem Text="Search clan" Icon="screen_search_desktop"></RadzenPanelMenuItem>
|
||||
</RadzenPanelMenu>
|
||||
</div>
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Radzen;
|
||||
using WotBlitzStatisticsPro.Blazor.Messages;
|
||||
using WotBlitzStatisticsPro.Blazor.Model;
|
||||
using WotBlitzStatisticsPro.Blazor.Services;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Blazor.Shared
|
||||
{
|
||||
public class NavMenuBase: ComponentBase
|
||||
{
|
||||
[Inject]
|
||||
public NavigationManager NavManager { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IMediator Mediator { get; set; }
|
||||
|
||||
[Inject]
|
||||
public ISearchDialogService SearchDialogService { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback CloseSideBar { get; set; }
|
||||
|
||||
public async Task MenuClicked(MenuItemEventArgs menuItem)
|
||||
{
|
||||
await CloseSideBar.InvokeAsync();
|
||||
switch (menuItem.Text)
|
||||
{
|
||||
case "Home":
|
||||
NavManager.NavigateTo("/");
|
||||
break;
|
||||
case "Search player":
|
||||
await Mediator.Publish(new OpenSearchDialogMessage(DialogType.FindPlayer));
|
||||
//await SearchDialogService.OpenSearchDialog(DialogType.FindPlayer);
|
||||
break;
|
||||
case "Search clan":
|
||||
await Mediator.Publish(new OpenSearchDialogMessage(DialogType.FindClan));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user