upd bell button
This commit is contained in:
parent
b93a7048fd
commit
acb9201725
|
|
@ -1,52 +1,51 @@
|
|||
@if (!Value)
|
||||
{
|
||||
<MudButton OnClick="ToggleClick" Disabled="Disabled">
|
||||
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.AddAlert" Color="Color.Dark" Style="font-size: 3rem;" />
|
||||
</MudButton>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudButton OnClick="ToggleClick" Disabled="Disabled">
|
||||
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.AddAlert" Color="Color.Tertiary"
|
||||
Style="font-size: 3rem;"/>
|
||||
</MudButton>
|
||||
}
|
||||
@using KoogleApp.Model
|
||||
@using KoogleApp.Store.Game.ThrowPanel
|
||||
|
||||
<MudSwitch T="bool" Label="" Size="Size.Medium" Disabled="Disabled"
|
||||
ThumbIcon="@(Value ? Icons.Material.Filled.Done : @Icons.Material.Filled.AddAlert)" ThumbIconColor="@(Value ? Color.Success : Color.Primary)"
|
||||
@bind-Value="Value"/>
|
||||
@inherits FluxorComponent
|
||||
|
||||
@inject IDispatcher Dispatcher
|
||||
@inject IState<ThrowPanelState> State
|
||||
|
||||
|
||||
<MudButton OnClick="ToggleClick" Disabled="false">
|
||||
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.AddAlert"
|
||||
Color="@(State.Value.BellValue ? Color.Primary : Color.Warning)"
|
||||
Style="font-size: 3rem;"/>
|
||||
</MudButton>
|
||||
|
||||
@* <MudSwitch T="bool" Label="" Size="Size.Medium" Disabled="false"
|
||||
@bind-Value="MudSwitchValue"
|
||||
ThumbIcon="@(State.Value.BellValue ? Icons.Material.Filled.Done : @Icons.Material.Filled.AddAlert)"
|
||||
ThumbIconColor="@(State.Value.BellValue ? Color.Success : Color.Primary)" /> *@
|
||||
|
||||
|
||||
@code {
|
||||
private bool _value;
|
||||
// private bool _mudSwitchValue;
|
||||
|
||||
[Parameter]
|
||||
public bool Value
|
||||
// private bool MudSwitchValue
|
||||
// {
|
||||
// get => _mudSwitchValue;
|
||||
// set
|
||||
// {
|
||||
// if (_mudSwitchValue == value)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// _mudSwitchValue = value;
|
||||
// Dispatcher.Dispatch(new ToggleBellAction());
|
||||
// }
|
||||
// }
|
||||
|
||||
// protected override void OnAfterRender(bool firstRender)
|
||||
// {
|
||||
// base.OnAfterRender(firstRender);
|
||||
// _mudSwitchValue = State.Value.BellValue;
|
||||
// }
|
||||
|
||||
private void ToggleClick(MouseEventArgs obj)
|
||||
{
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
if (_value == value) return;
|
||||
_value = value;
|
||||
InvokeAsync(async () => await ValueChanged.InvokeAsync(value));
|
||||
|
||||
InvokeAsync(async () => await OnStateChanged.InvokeAsync(Value));
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> ValueChanged { get; set; }
|
||||
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> OnStateChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; } = false;
|
||||
|
||||
private async Task ToggleClick(MouseEventArgs obj)
|
||||
{
|
||||
Value = !Value;
|
||||
Dispatcher.Dispatch(new ToggleBellAction());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
@inherits FluxorComponent
|
||||
|
||||
@inject IMyEventAggregator EventAggregator
|
||||
@inject IState<ThrowPanelState> ThrowPanelState
|
||||
@inject IDispatcher Dispatcher
|
||||
|
||||
|
|
@ -33,8 +32,7 @@
|
|||
</MudItem>
|
||||
<MudItem xs="4">
|
||||
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
|
||||
<BellButton
|
||||
OnStateChanged="OnBellStateChanged" />
|
||||
<BellButton />
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
|
||||
|
|
@ -138,12 +136,7 @@
|
|||
|
||||
|
||||
@code {
|
||||
// [Parameter]
|
||||
// public ThrowPanelState? ThrowPanelState { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<ThrowPanelState> OnStateChanged { get; set; }
|
||||
|
||||
|
||||
[Parameter]
|
||||
public bool ShowNumbers
|
||||
{
|
||||
|
|
@ -161,19 +154,10 @@
|
|||
private void ToggleClick(MouseEventArgs obj)
|
||||
{
|
||||
Dispatcher.Dispatch(new ToggleAllPinsAction());
|
||||
// await EventAggregator.PublishAsync(new PinToggleMessage());
|
||||
}
|
||||
|
||||
private async Task OneClick(int number)
|
||||
{
|
||||
Dispatcher.Dispatch(new UpdatePinStateByNumber(number));
|
||||
// await EventAggregator.PublishAsync(new NumberPanelMessage(number));
|
||||
Dispatcher.Dispatch(new UpdatePinStateByNumberAction(number));
|
||||
}
|
||||
|
||||
private async Task OnBellStateChanged(bool obj)
|
||||
{
|
||||
Dispatcher.Dispatch(new ToggleBellAction());
|
||||
// await OnStateChanged.InvokeAsync(ThrowPanelState);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
<MudItem xs="12" md="6">
|
||||
<NumberPanel ShowNumbers="ShowNumbers"
|
||||
CanSelectPlayer="CanSelectPlayers"
|
||||
OnStateChanged="OnThrowPanelStateChanged"
|
||||
/>
|
||||
</MudItem>
|
||||
|
||||
|
|
@ -21,8 +20,7 @@
|
|||
// [Parameter]
|
||||
// public ThrowPanelState? ThrowPanelState { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<ThrowPanelState> OnStateChanged { get; set; }
|
||||
|
||||
|
||||
PinPanel _pinPanel;
|
||||
NumberPanel _numberPanel;
|
||||
|
|
@ -47,9 +45,5 @@
|
|||
|
||||
// }
|
||||
|
||||
private async Task OnThrowPanelStateChanged(ThrowPanelState arg)
|
||||
{
|
||||
await OnStateChanged.InvokeAsync(arg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@
|
|||
{
|
||||
<MudGrid>
|
||||
|
||||
<NumberPinPanel @ref="_numberPinPanel"
|
||||
ShowNumbers="true"
|
||||
OnStateChanged="OnNumberPinStateChanged"
|
||||
<NumberPinPanel ShowNumbers="true"
|
||||
CanSelectPlayers="true"
|
||||
/>
|
||||
|
||||
|
|
@ -49,7 +47,6 @@
|
|||
|
||||
|
||||
@code {
|
||||
private NumberPinPanel _numberPinPanel;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<ThrowEventArgs> OnClick { get; set; }
|
||||
|
|
@ -106,11 +103,5 @@
|
|||
|
||||
}
|
||||
|
||||
// public void UpdatePanelState(ThrowPanelState state)
|
||||
// {
|
||||
// _numberPinPanel.UpdatePanelState(state);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace KoogleApp.Hub
|
|||
|
||||
_hubConnection.On<ThrowPanelState>("ReceiveThrowPanelState", state =>
|
||||
{
|
||||
dispatcher.Dispatch(new ReceiveStateFromServer(state));
|
||||
dispatcher.Dispatch(new ReceiveStateFromServerAction(state));
|
||||
});
|
||||
|
||||
// _hubConnection.On<string>("ReceiveTextUpdate", (newText) =>
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
|
||||
public record ToggleBellAction();
|
||||
|
||||
public record UpdatePinStateByNumber(int Number);
|
||||
public record UpdatePinStateByNumberAction(int Number);
|
||||
|
||||
public record ReceiveStateFromServer(ThrowPanelState State);
|
||||
public record ReceiveStateFromServerAction(ThrowPanelState State);
|
||||
|
||||
public record LoadStateFromSessionAction();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,31 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
dispatcher.Dispatch(new BroadcastThrowPanelStateAction(_state.Value));
|
||||
}
|
||||
|
||||
[EffectMethod]
|
||||
public async Task HandleToggleAllPinsAction(ToggleAllPinsAction stopAction, IDispatcher dispatcher)
|
||||
{
|
||||
dispatcher.Dispatch(new BroadcastThrowPanelStateAction(_state.Value));
|
||||
}
|
||||
|
||||
[EffectMethod]
|
||||
public async Task HandleTogglePinValueAction(TogglePinValueAction stopAction, IDispatcher dispatcher)
|
||||
{
|
||||
dispatcher.Dispatch(new BroadcastThrowPanelStateAction(_state.Value));
|
||||
}
|
||||
|
||||
[EffectMethod]
|
||||
public async Task HandleUpdatePinStateByNumberAction(UpdatePinStateByNumberAction stopAction, IDispatcher dispatcher)
|
||||
{
|
||||
dispatcher.Dispatch(new BroadcastThrowPanelStateAction(_state.Value));
|
||||
}
|
||||
|
||||
[EffectMethod]
|
||||
public async Task HandleToggleBellAction(ToggleBellAction stopAction, IDispatcher dispatcher)
|
||||
{
|
||||
dispatcher.Dispatch(new BroadcastThrowPanelStateAction(_state.Value));
|
||||
}
|
||||
|
||||
|
||||
[EffectMethod]
|
||||
public async Task HandleConnectToHubAction(ConnectToHubAction action, IDispatcher dispatcher)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
public static class ThrowPanelStateReducer
|
||||
{
|
||||
[ReducerMethod]
|
||||
public static ThrowPanelState ReceiveStateFromServer(ThrowPanelState state, ReceiveStateFromServer action)
|
||||
public static ThrowPanelState OnReceiveStateFromServer(ThrowPanelState state, ReceiveStateFromServerAction action)
|
||||
{
|
||||
return action.State;
|
||||
}
|
||||
|
||||
[ReducerMethod]
|
||||
public static ThrowPanelState OnToggleDevice(ThrowPanelState state, TogglePinValueAction action)
|
||||
public static ThrowPanelState OnTogglePinValue(ThrowPanelState state, TogglePinValueAction action)
|
||||
{
|
||||
switch (action.PinNumber)
|
||||
{
|
||||
|
|
@ -41,7 +41,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
}
|
||||
|
||||
[ReducerMethod]
|
||||
public static ThrowPanelState OnStart(ThrowPanelState state, StartStopAction stopAction)
|
||||
public static ThrowPanelState OnStartStop(ThrowPanelState state, StartStopAction stopAction)
|
||||
{
|
||||
return state with { IsStated = !state.IsStated };
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
}
|
||||
|
||||
[ReducerMethod]
|
||||
public static ThrowPanelState OnUpdatePinStateByNumber(ThrowPanelState state, UpdatePinStateByNumber action)
|
||||
public static ThrowPanelState OnUpdatePinStateByNumber(ThrowPanelState state, UpdatePinStateByNumberAction action)
|
||||
{
|
||||
var chgCnt = 0;
|
||||
|
||||
|
|
@ -112,13 +112,13 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
}
|
||||
|
||||
[ReducerMethod]
|
||||
public static ThrowPanelState OnUpdatePinStateByNumber(ThrowPanelState state, ToggleBellAction action)
|
||||
public static ThrowPanelState OnToggleBell(ThrowPanelState state, ToggleBellAction action)
|
||||
{
|
||||
return state with { BellValue = !state.BellValue };
|
||||
}
|
||||
|
||||
[ReducerMethod]
|
||||
public static ThrowPanelState OnLoadState(ThrowPanelState state, StateLoadedAction action)
|
||||
public static ThrowPanelState OnStateLoaded(ThrowPanelState state, StateLoadedAction action)
|
||||
{
|
||||
return action.State;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
{
|
||||
"IsStated": false,
|
||||
"BellValue": false,
|
||||
"Pin1Value": false,
|
||||
"Pin2Value": false,
|
||||
"Pin3Value": false,
|
||||
"Pin4Value": false,
|
||||
"Pin5Value": false,
|
||||
"Pin6Value": false,
|
||||
"IsStated": true,
|
||||
"BellValue": true,
|
||||
"Pin1Value": true,
|
||||
"Pin2Value": true,
|
||||
"Pin3Value": true,
|
||||
"Pin4Value": true,
|
||||
"Pin5Value": true,
|
||||
"Pin6Value": true,
|
||||
"Pin7Value": false,
|
||||
"Pin8Value": false,
|
||||
"Pin9Value": false,
|
||||
"Pin8Value": true,
|
||||
"Pin9Value": true,
|
||||
"Pin1Disabled": false,
|
||||
"Pin2Disabled": false,
|
||||
"Pin3Disabled": false,
|
||||
|
|
|
|||
Loading…
Reference in New Issue