|
1 | 1 | @inject Data Datas |
2 | 2 | @inject NavigationManager Nav |
3 | 3 | @inject IJSRuntime JsRuntime |
4 | | -<MudAppBar |
5 | | - Color="Color.Secondary" |
6 | | - Fixed="true" |
7 | | - Dense="true" |
8 | | - Elevation="0" |
| 4 | +<MudAppBar |
| 5 | + Color="Color.Secondary" |
| 6 | + Fixed="true" |
| 7 | + Dense="true" |
| 8 | + Elevation="0" |
9 | 9 | Class=""> |
10 | | - <MudIconButton |
11 | | - Icon="@Icons.Material.Filled.Home" |
12 | | - Color="Color.Inherit" |
| 10 | + <MudIconButton |
| 11 | + Icon="@Icons.Material.Filled.Home" |
| 12 | + Color="Color.Inherit" |
13 | 13 | Edge="Edge.Start" |
14 | | - OnClick="GoToHomePage"/> |
15 | | - <MudSpacer/> |
| 14 | + OnClick="GoToHomePage" /> |
| 15 | + <MudSpacer /> |
16 | 16 | <MudPaper Elevation="0" Class="mx-6"> |
17 | 17 | <div class="InputContainer"> |
18 | 18 | <input type="text" |
19 | 19 | name="text" |
20 | | - @bind-value="@_findData" |
| 20 | + @bind-value="@FindData" |
21 | 21 | class="input" id="input" |
22 | | - placeholder="Search"> |
| 22 | + placeholder="Search" > |
23 | 23 |
|
24 | 24 | <label for="input" class="labelforsearch"> |
25 | 25 |
|
26 | 26 | </label> |
27 | 27 |
|
28 | 28 | <button class="micButton" @onclick="GoToPage"> |
29 | | - <svg viewBox="0 0 512 512" class="searchIcon"> |
30 | | - <path |
31 | | - d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"></path> |
32 | | - </svg> |
| 29 | + <svg viewBox="0 0 512 512" class="searchIcon"><path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"></path></svg> |
33 | 30 | </button> |
34 | 31 | </div> |
35 | 32 | </MudPaper> |
36 | 33 | </MudAppBar> |
37 | | - |
38 | | -@code { |
39 | | - private string _findData = string.Empty; |
40 | | - |
| 34 | + |
| 35 | +@code { |
| 36 | + public string FindData = string.Empty; |
| 37 | + |
41 | 38 | void GoToHomePage() |
42 | | - { |
43 | | - Nav.NavigateTo(""); |
| 39 | + { |
| 40 | + Nav.NavigateTo(""); |
44 | 41 | } |
45 | 42 |
|
46 | | - private void GoToPage() |
| 43 | + public void GoToPage() |
47 | 44 | { |
48 | 45 | Filter(); |
49 | | - if (!string.IsNullOrEmpty(_findData)) |
| 46 | + if (!string.IsNullOrEmpty(FindData)) |
50 | 47 | { |
51 | | - Nav.NavigateTo($"Search/{_findData}"); |
| 48 | + Nav.NavigateTo($"Search/{FindData}"); |
52 | 49 | } |
53 | | - } |
54 | | - |
| 50 | + } |
55 | 51 | protected override async Task OnAfterRenderAsync(bool firstRender) |
56 | 52 | { |
57 | 53 | if (firstRender) |
58 | 54 | { |
59 | 55 | await JsRuntime.InvokeVoidAsync("blazorKeyPressed", DotNetObjectReference.Create(this)); |
60 | 56 | } |
61 | 57 | } |
62 | | - |
63 | 58 | [JSInvokable] |
64 | 59 | public void OnArrowKeyPressed(string key) |
65 | 60 | { |
66 | 61 | Filter(); |
67 | | - if (key == "Enter" && !string.IsNullOrEmpty(_findData)) |
| 62 | + if (key == "Enter" && !string.IsNullOrEmpty(FindData)) |
68 | 63 | { |
69 | | - Nav.NavigateTo($"Search/{_findData}"); |
| 64 | + Nav.NavigateTo($"Search/{FindData}"); |
70 | 65 | } |
71 | 66 |
|
72 | 67 | StateHasChanged(); |
73 | | - } |
74 | | - |
| 68 | + } |
75 | 69 | void Filter() |
76 | 70 | { |
77 | | - Datas.FilteredData = Datas.VideosData.Where(x => x.Description != null && x.Description.Contains(_findData, StringComparison.OrdinalIgnoreCase)) |
78 | | - .ToList(); |
| 71 | + Datas.FilteredData = Datas.VideosData.Where(x => x.Description != null && x.Description.Contains(FindData, StringComparison.OrdinalIgnoreCase)) |
| 72 | + .ToList(); |
79 | 73 | } |
80 | | - |
81 | 74 | } |
82 | | - |
83 | | - |
| 75 | + |
84 | 76 | @code{ |
85 | | - |
86 | 77 | protected override async Task OnInitializedAsync() |
87 | 78 | { |
88 | 79 | Datas.OnChange += StateHasChanged; |
|
93 | 84 | { |
94 | 85 | Datas.OnChange -= StateHasChanged; |
95 | 86 | } |
96 | | - |
97 | 87 | } |
98 | | - |
99 | 88 | <style> |
100 | 89 | .InputContainer { |
101 | 90 | height: 40px; |
|
0 commit comments