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 @using WotBlitzStatisticsPro.Blazor.Model
<h3>SearchDialog</h3> @inherits SearchDialogTypeBase
@DialogType <!--Realm type selection-->
<RadzenButton Click=@(args => OnClick()) Text="Ok" Style="margin-bottom: 20px; width: 150px" /> <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 MediatR;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Radzen; using Radzen;
using WotBlitzStatisticsPro.Blazor.Messages; using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model; using WotBlitzStatisticsPro.Blazor.Model;
@@ -15,12 +17,66 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
[Inject] [Inject]
private IMediator Mediator { get; set; } private IMediator Mediator { get; set; }
[Inject]
public IStringLocalizer<App> Localizer { get; set; }
[Parameter] [Parameter]
public DialogType DialogType { get; set; } 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); DialogService.Close(true);
} }
} }
@@ -123,6 +123,9 @@
<data name="Login with WG.net ID" xml:space="preserve"> <data name="Login with WG.net ID" xml:space="preserve">
<value>Anmelden mit WG.net-ID</value> <value>Anmelden mit WG.net-ID</value>
</data> </data>
<data name="Search" xml:space="preserve">
<value>Suchen</value>
</data>
<data name="Search clan" xml:space="preserve"> <data name="Search clan" xml:space="preserve">
<value>Clan suchen</value> <value>Clan suchen</value>
</data> </data>
@@ -123,6 +123,9 @@
<data name="Login with WG.net ID" xml:space="preserve"> <data name="Login with WG.net ID" xml:space="preserve">
<value>Войти с WG.net ID</value> <value>Войти с WG.net ID</value>
</data> </data>
<data name="Search" xml:space="preserve">
<value>Поиск</value>
</data>
<data name="Search clan" xml:space="preserve"> <data name="Search clan" xml:space="preserve">
<value>Поиск клана</value> <value>Поиск клана</value>
</data> </data>
@@ -2,6 +2,7 @@
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediatR; using MediatR;
using Microsoft.Extensions.Localization;
using Radzen; using Radzen;
using WotBlitzStatisticsPro.Blazor.Messages; using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model; using WotBlitzStatisticsPro.Blazor.Model;
@@ -13,16 +14,20 @@ namespace WotBlitzStatisticsPro.Blazor.Services
{ {
private readonly DialogService _dialogService; private readonly DialogService _dialogService;
private readonly IStringLocalizer<App> _localizer;
public SearchDialogService(DialogService dialogService) public SearchDialogService(
DialogService dialogService,
IStringLocalizer<App> localizer)
{ {
_dialogService = dialogService; _dialogService = dialogService;
_localizer = localizer;
} }
public async Task OpenSearchDialog(DialogType type) 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 Dictionary<string, object>() { { "DialogType", type } },
new DialogOptions() { Width = "300px", Height = "530px" }); new DialogOptions() { Width = "300px", Height = "530px" });
} }