Skip to content

Commit 3bada37

Browse files
committed
Update MudBlazor to v8
1 parent 6ef077e commit 3bada37

8 files changed

Lines changed: 129 additions & 121 deletions

File tree

PocketDDD.BlazorClient/PocketDDD.BlazorClient/Features/EventFeedback/Components/EventFeedback.razor

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
@using PocketDDD.BlazorClient.Features.EventFeedback.Store
2-
@using Microsoft.AspNetCore.Components
3-
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
2+
@inherits FluxorComponent
43

5-
@inject IState<EventFeedbackState> State
64
@inject IDispatcher Dispatcher
75

86
<MudDialog>
9-
<TitleContent><MudText Typo="Typo.h6" Align="Align.Center">Event Feedback</MudText></TitleContent>
7+
<TitleContent>
8+
<MudText Typo="Typo.h6" Align="Align.Center">Event Feedback</MudText>
9+
</TitleContent>
1010
<DialogContent>
1111

1212
<MudCard>
@@ -22,20 +22,24 @@
2222
<MudCard Class="mt-3">
2323
<MudCardContent>
2424
<MudText Typo="Typo.h6">Refreshments:</MudText>
25-
<MudRating SelectedValue="@_refreshments" SelectedValueChanged="newValue => { _refreshments = newValue; HandleDataChanged();}" />
26-
25+
<MudRating SelectedValue="@_refreshments"
26+
SelectedValueChanged="newValue => { _refreshments = newValue; HandleDataChanged();}"/>
27+
2728
<MudText Typo="Typo.h6">Venue:</MudText>
28-
<MudRating SelectedValue="@_venue" SelectedValueChanged="newValue => { _venue = newValue; HandleDataChanged();}" />
29-
29+
<MudRating SelectedValue="@_venue"
30+
SelectedValueChanged="newValue => { _venue = newValue; HandleDataChanged();}"/>
31+
3032
<MudText Typo="Typo.h6">Overall:</MudText>
31-
<MudRating SelectedValue="@_overall" SelectedValueChanged="newValue => { _overall = newValue; HandleDataChanged();}" />
33+
<MudRating SelectedValue="@_overall"
34+
SelectedValueChanged="newValue => { _overall = newValue; HandleDataChanged();}"/>
3235

3336
<MudText Typo="Typo.h6">Comments:</MudText>
3437
<MudText Typo="Typo.body2">
35-
<MudTextField Value="_comments" ValueChanged="(string newText) => { _comments = newText; HandleDataChanged();}"
36-
Immediate="true"
37-
Variant="Variant.Text"
38-
Lines="3">
38+
<MudTextField Value="_comments"
39+
ValueChanged="(string newText) => { _comments = newText; HandleDataChanged();}"
40+
Immediate="true"
41+
Variant="Variant.Text"
42+
Lines="3">
3943
</MudTextField>
4044
</MudText>
4145
</MudCardContent>
@@ -44,7 +48,7 @@
4448
</MudDialog>
4549

4650
<MudAppBar Bottom="true" Fixed="true" Color="Color.Transparent" Elevation="1">
47-
<MudButton
51+
<MudButton
4852
Variant="Variant.Filled"
4953
Color="Color.Secondary"
5054
FullWidth="true"
@@ -57,20 +61,20 @@
5761
Color="Color.Primary"
5862
FullWidth="true"
5963
OnClick="HandleSubmit"
60-
Disabled="!isDirty">
64+
Disabled="!_isDirty">
6165
Submit
6266
</MudButton>
6367
</MudAppBar>
6468

6569
@code {
66-
[CascadingParameter] MudDialogInstance MudDialog { get; set; } = default!;
70+
[CascadingParameter] IMudDialogInstance MudDialog { get; set; } = default!;
6771

68-
int _refreshments = 0;
69-
int _venue = 0;
70-
int _overall = 0;
72+
int _refreshments;
73+
int _venue;
74+
int _overall;
7175
string _comments = string.Empty;
7276

73-
bool isDirty = false;
77+
bool _isDirty;
7478

7579
protected override void OnInitialized()
7680
{
@@ -93,7 +97,10 @@
9397
_comments = action.Feedback.Comments;
9498
}
9599

96-
void HandleDataChanged() => isDirty = true;
100+
void HandleDataChanged()
101+
{
102+
_isDirty = true;
103+
}
97104

98105
void HandleSubmit()
99106
{
@@ -114,4 +121,5 @@
114121
{
115122
MudDialog.Cancel();
116123
}
124+
117125
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
@using PocketDDD.BlazorClient.Features.EventScore.Store;
1+
@using PocketDDD.BlazorClient.Features.EventScore.Store
22
@using PocketDDD.BlazorClient.Features.Sync.Components
3-
4-
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
3+
@inherits FluxorComponent
54

65
@inject IState<EventScoreState> State
76
@inject IDispatcher Dispatcher
@@ -11,17 +10,19 @@
1110
Size="Size.Large"
1211
Label="@State.Value.Score.ToString()"
1312
Style="position:fixed; right:10px; bottom:10px"
14-
OnClick="HandleViewSyncStatus" />
13+
OnClick="HandleViewSyncStatusAsync"/>
1514

1615
@code {
16+
1717
protected override void OnInitialized()
1818
{
1919
Dispatcher.Dispatch(new FetchExistingEventScoreAction());
2020
base.OnInitialized();
2121
}
2222

23-
void HandleViewSyncStatus()
23+
async Task HandleViewSyncStatusAsync()
2424
{
25-
Dialog.Show<SyncStatus>("", new DialogOptions { FullScreen = true });
25+
await Dialog.ShowAsync<SyncStatus>("", new DialogOptions { FullScreen = true });
2626
}
27+
2728
}
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
@page "/"
2-
2+
@using PocketDDD.BlazorClient.Features.EventFeedback.Components
33
@using PocketDDD.BlazorClient.Features.EventScore.Components
4-
@using PocketDDD.BlazorClient.Features.HeaderBar.Store;
5-
@using PocketDDD.BlazorClient.Features.Sync.Store
6-
@using PocketDDD.BlazorClient.Services
4+
@using PocketDDD.BlazorClient.Features.HeaderBar.Store
75
@using PocketDDD.BlazorClient.Features.Home.Store
8-
@using PocketDDD.BlazorClient.Features.EventFeedback.Components
9-
10-
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
6+
@using PocketDDD.BlazorClient.Features.Sync.Store
7+
@inherits FluxorComponent
118

129
@inject IState<HomeState> State
1310
@inject IDispatcher Dispatcher
1411
@inject IDialogService Dialog
15-
@inject LocalStorageContext LocalStorage
1612

1713
@WhenLoadingAndNotFailedShowAlert()
1814
@WhenLoadingFailedShowCard()
@@ -21,39 +17,45 @@
2117
<EventScore></EventScore>
2218

2319
@code {
20+
2421
RenderFragment? WhenLoadingAndNotFailedShowAlert() => State.Value.Loading && !State.Value.FailedToLoad
2522
? @<MudAlert Severity="Severity.Info">loading...</MudAlert>
2623
: null;
2724

2825
RenderFragment? WhenLoadingFailedShowCard() => State.Value.Loading && State.Value.FailedToLoad
2926
? @<MudCard>
30-
<MudCardContent>
31-
<MudText><h5>Failed to load data</h5></MudText>
32-
</MudCardContent>
33-
<MudCardActions>
34-
<MudButton Variant="Variant.Text" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Refresh">Retry</MudButton>
35-
</MudCardActions>
27+
<MudCardContent>
28+
<MudText><h5>Failed to load data</h5></MudText>
29+
</MudCardContent>
30+
<MudCardActions>
31+
<MudButton Variant="Variant.Text" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Refresh">
32+
Retry
33+
</MudButton>
34+
</MudCardActions>
3635
</MudCard>
3736
: null;
37+
3838
}
3939

4040
@code {
41+
4142
protected override void OnInitialized()
4243
{
4344
Dispatcher.Dispatch(new SetHeaderBarTitleAction("DDDSW 2024"));
4445

45-
if(State.Value.Loading)
46+
if (State.Value.Loading)
4647
Dispatcher.Dispatch(new LoadDataAction());
4748

4849
Dispatcher.Dispatch(new SyncAction());
4950

50-
SubscribeToAction<ViewFeedbackAction>(_ => HandleShowEventFeedback());
51+
SubscribeToAction<ViewFeedbackAction>(async _ => await HandleShowEventFeedbackAsync());
5152

5253
base.OnInitialized();
5354
}
5455

55-
void HandleShowEventFeedback()
56+
async Task HandleShowEventFeedbackAsync()
5657
{
57-
Dialog.Show<EventFeedback>("", new DialogOptions { FullScreen = true });
58+
await Dialog.ShowAsync<EventFeedback>("", new DialogOptions { FullScreen = true });
5859
}
60+
5961
}
Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,43 @@
1-
using System.Net.Http.Json;
2-
using Blazored.LocalStorage;
3-
using Fluxor;
1+
using Fluxor;
42
using Microsoft.AspNetCore.Components;
53
using MudBlazor;
6-
using PocketDDD.BlazorClient.Features.EventScore.Store;
7-
using PocketDDD.BlazorClient.Features.Home.Store;
4+
using PocketDDD.BlazorClient.Features.Security.Components;
85
using PocketDDD.BlazorClient.Services;
9-
using static MudBlazor.CategoryTypes;
106

117
namespace PocketDDD.BlazorClient.Features.Security.Store;
128

13-
public class SecurityEffects
9+
public class SecurityEffects(
10+
LocalStorageContext localStorage,
11+
IPocketDDDApiService pocketDddapi,
12+
IDialogService dialog,
13+
NavigationManager navigationManager)
1414
{
15-
private readonly IState<SecurityState> _state;
16-
private readonly LocalStorageContext _localStorage;
17-
private readonly IPocketDDDApiService _pocketDDDAPI;
18-
private readonly IDialogService _dialog;
19-
private readonly NavigationManager _navigationManager;
20-
private IDialogReference? currentDialogReference = null;
21-
22-
public SecurityEffects(IState<SecurityState> state, LocalStorageContext localStorage,
23-
IPocketDDDApiService pocketDDDAPI, IDialogService dialog, NavigationManager navigationManager)
24-
{
25-
_state = state;
26-
_localStorage = localStorage;
27-
_pocketDDDAPI = pocketDDDAPI;
28-
_dialog = dialog;
29-
_navigationManager = navigationManager;
30-
}
15+
private IDialogReference? _currentDialogReference;
3116

3217
[EffectMethod]
3318
public async Task OnCheckUser(CheckUserAction action, IDispatcher dispatcher)
3419
{
35-
var user = await _localStorage.CurrentUser.GetAsync();
20+
var user = await localStorage.CurrentUser.GetAsync();
3621

3722
if (user is not null)
3823
{
3924
dispatcher.Dispatch(new SetCurrentUserAction(user));
4025
return;
4126
}
4227

43-
if (currentDialogReference is null)
44-
currentDialogReference = _dialog.Show<Features.Security.Components.Login>("", new DialogOptions { FullScreen = true });
28+
_currentDialogReference ??= await dialog.ShowAsync<Login>("", new DialogOptions { FullScreen = true });
4529
}
4630

4731
[EffectMethod]
4832
public async Task OnLogin(LoginAction action, IDispatcher dispatcher)
4933
{
5034
try
5135
{
52-
var result = await _pocketDDDAPI.Login(action.LoginName);
36+
var result = await pocketDddapi.Login(action.LoginName);
5337
ArgumentNullException.ThrowIfNull(result, nameof(result));
5438

55-
await _localStorage.CurrentUser.SetAsync(result);
56-
await _localStorage.EventScore.SetAsync(1);
39+
await localStorage.CurrentUser.SetAsync(result);
40+
await localStorage.EventScore.SetAsync(1);
5741

5842
dispatcher.Dispatch(new SetLoginSuccessAction(result));
5943
}
@@ -68,22 +52,22 @@ public Task OnLoginSuccess(SetLoginSuccessAction action, IDispatcher dispatcher)
6852
{
6953
dispatcher.Dispatch(new SetCurrentUserAction(action.User));
7054

71-
currentDialogReference?.Close();
72-
currentDialogReference = null;
55+
_currentDialogReference?.Close();
56+
_currentDialogReference = null;
7357
return Task.CompletedTask;
7458
}
7559

7660
[EffectMethod]
7761
public Task OnLoginSuccess(SetCurrentUserAction action, IDispatcher dispatcher)
7862
{
79-
_pocketDDDAPI.SetUserAuthToken(action.User.Token);
63+
pocketDddapi.SetUserAuthToken(action.User.Token);
8064
return Task.CompletedTask;
8165
}
8266

8367
[EffectMethod]
8468
public async Task DeleteAllDataAndLogOut(DeleteAllDataAndLogOutAction action, IDispatcher dispatcher)
8569
{
86-
await _localStorage.DeleteAllDataAsync();
87-
_navigationManager.NavigateTo("/", true);
70+
await localStorage.DeleteAllDataAsync();
71+
navigationManager.NavigateTo("/", true);
8872
}
8973
}

PocketDDD.BlazorClient/PocketDDD.BlazorClient/Features/Session/Components/Session.razor

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
@page "/session/{id:int}"
22

3-
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
4-
5-
@using PocketDDD.BlazorClient.Features.HeaderBar.Store;
3+
@using PocketDDD.BlazorClient.Features.HeaderBar.Store
64
@using PocketDDD.BlazorClient.Features.Session.Store
7-
@using PocketDDD.BlazorClient.Features.SessionFeedback.Store;
5+
@using PocketDDD.BlazorClient.Features.SessionFeedback.Components
6+
@inherits FluxorComponent
87

98
@inject IState<SessionState> State
109
@inject IDispatcher Dispatcher
@@ -33,22 +32,21 @@
3332
</MudCardContent>
3433
</MudCard>
3534

36-
<MudFab
35+
<MudFab
3736
Color="@State.Value.Session.BookmarkColor"
3837
Size="Size.Large"
3938
StartIcon="@State.Value.Session.BookmarkIcon"
4039
Style="position:fixed; right:10px; bottom:10px"
41-
OnClick="HandleToggleSessionBookmarked" />
40+
OnClick="HandleToggleSessionBookmarked"/>
4241
}
4342

4443
@code {
45-
[Parameter]
46-
public int Id { get; set; }
44+
[Parameter] public int Id { get; set; }
4745

4846
protected override void OnInitialized()
4947
{
5048
SubscribeToAction<NavigateBackAction>(_ => HandleNavigateHome());
51-
SubscribeToAction<ViewFeedbackAction>(_ => HandleShowSessionFeedback());
49+
SubscribeToAction<ViewFeedbackAction>(async _ => await HandleShowSessionFeedbackAsync());
5250

5351
base.OnInitialized();
5452
}
@@ -60,7 +58,10 @@
6058
base.OnParametersSet();
6159
}
6260

63-
void HandleNavigateHome() => Navigation.NavigateTo("/", false, true);
61+
void HandleNavigateHome()
62+
{
63+
Navigation.NavigateTo("/", false, true);
64+
}
6465

6566
void HandleToggleSessionBookmarked()
6667
{
@@ -71,11 +72,12 @@
7172
Dispatcher.Dispatch(new ToggleBookmarkedAction(session.Id, !session.IsBookmarked));
7273
}
7374

74-
void HandleShowSessionFeedback()
75+
async Task HandleShowSessionFeedbackAsync()
7576
{
76-
Dialog.Show<Features.SessionFeedback.Components.SessionFeedback>(
77-
"",
77+
await Dialog.ShowAsync<SessionFeedback>(
78+
"",
7879
new DialogParameters { ["Id"] = Id },
7980
new DialogOptions { FullScreen = true });
8081
}
82+
8183
}

0 commit comments

Comments
 (0)