feat: Search dialog styled

This commit is contained in:
Mikhail Shabanov committed 2021-05-12 14:31:28 +02:00
1 parent c60f622989
commit 4ff19d7f21
6 files changed
+96 -9

No files matched your search

@@ -0,0 +1,8 @@
using System;
namespace WotBlitzStatisticsPro.Blazor.Model
{
[Obsolete("This is temporary item. In the future there should be two new data models with 'clan, winrate and battles' for player, and 'name, tag members count' for clan")]
public record SearchItem(long ItemId, string ItemName);
}
@@ -1,4 +1,16 @@
@inherits SearchDialogTypeBase
<h3>SearchDialog</h3>
@DialogType
<RadzenButton Click=@(args => OnClick()) Text="Ok" Style="margin-bottom: 20px; width: 150px" />
@using WotBlitzStatisticsPro.Blazor.Model
@inherits SearchDialogTypeBase
<!--Realm type selection-->
<RadzenTextBox Placeholder=@($"{Localizer["Search"]}...") Change=@OnSearchTextChange Style="width: 100%;" />
<RadzenListBox
@bind-Value=@CurrentValue
Data=@FilteredList
ValueProperty="ItemId"
Style="height:335px; width: 100%; margin-top: 10px;">
<Template>
<!--ToDo: Create new component that will show nick[clan] {WinRate with color}, {battles count with translatable word "battles"}. And another component for Clans-->
@(((SearchItem) context).ItemName) | accountId: @(((SearchItem) context).ItemId)
</Template>
</RadzenListBox>
<RadzenButton Click=@(args => OnOkButtonClick()) Text="Ok" Style="margin: 10px auto 10px auto; display: block; width: 150px; " />
@@ -1,6 +1,8 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
using MediatR;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Radzen;
using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model;
@@ -15,12 +17,66 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
[Inject]
private IMediator Mediator { get; set; }
[Inject]
public IStringLocalizer<App> Localizer { get; set; }
[Parameter]
public DialogType DialogType { get; set; }
public async Task OnClick()
public List<SearchItem> FilteredList { get; set; } = new();
//public RealmType CurrentRealmType { get; set; } = RealmType.Eu;
public long CurrentValue { get; set; }
public async Task OnSearchTextChange(string value)
{
await Mediator.Publish(new OpenPlayerInfoMessage(123456789, false));
if (DialogType == DialogType.FindPlayer && value.Length < 3)
{
return;
}
FilteredList.Clear();
await InvokeAsync(StateHasChanged);
// ToDo: Call GraphQL Backend CurrentRealmType + value
await Task.Delay(1000);
for (int i = 0; i < 15; i++)
{
FilteredList.Add(new SearchItem(i, $"Item number {i}"));
}
await InvokeAsync(StateHasChanged);
}
public async Task OnLoadSearchData(LoadDataArgs args)
{
if (DialogType == DialogType.FindPlayer && args.Filter.Length < 3)
{
return;
}
FilteredList.Clear();
await InvokeAsync(StateHasChanged);
// ToDo: Call GraphQL Backend CurrentRealmType + args.Filter
await Task.Delay(1000);
for (int i = 0; i < 15; i++)
{
FilteredList.Add(new SearchItem(i, $"Item number {i}"));
}
await InvokeAsync(StateHasChanged);
}
public async Task OnOkButtonClick()
{
if (CurrentValue > 0)
{
await Mediator.Publish(new OpenPlayerInfoMessage(CurrentValue, false));
}
DialogService.Close(true);
}
}
@@ -123,6 +123,9 @@
<data name="Login with WG.net ID" xml:space="preserve">
<value>Anmelden mit WG.net-ID</value>
</data>
<data name="Search" xml:space="preserve">
<value>Suchen</value>
</data>
<data name="Search clan" xml:space="preserve">
<value>Clan suchen</value>
</data>
@@ -123,6 +123,9 @@
<data name="Login with WG.net ID" xml:space="preserve">
<value>Войти с WG.net ID</value>
</data>
<data name="Search" xml:space="preserve">
<value>Поиск</value>
</data>
<data name="Search clan" xml:space="preserve">
<value>Поиск клана</value>
</data>
@@ -2,6 +2,7 @@
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.Extensions.Localization;
using Radzen;
using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model;
@@ -13,16 +14,20 @@ namespace WotBlitzStatisticsPro.Blazor.Services
{
private readonly DialogService _dialogService;
private readonly IStringLocalizer<App> _localizer;
public SearchDialogService(DialogService dialogService)
public SearchDialogService(
DialogService dialogService,
IStringLocalizer<App> localizer)
{
_dialogService = dialogService;
_localizer = localizer;
}
public async Task OpenSearchDialog(DialogType type)
{
await _dialogService.OpenAsync<SearchDialog>($"Search",
await _dialogService.OpenAsync<SearchDialog>(type == DialogType.FindPlayer ? _localizer.GetString("Search player") : _localizer.GetString("Search clan"),
new Dictionary<string, object>() { { "DialogType", type } },
new DialogOptions() { Width = "300px", Height = "530px" });
}