64 lines
1.5 KiB
Plaintext
64 lines
1.5 KiB
Plaintext
@using KoogleApp.Store.Game.ThrowPanel
|
|
|
|
@typeparam TState
|
|
@inject IState<TState> State
|
|
|
|
|
|
<MudSelect T="ThrowModeClass" Label="Modus" HelperText="Wähle zwischen Abräumen und in die Vollen"
|
|
|
|
@bind-Value="ThrowModeClass"
|
|
OpenIcon="@Icons.Material.Filled.Mode" AdornmentColor="Color.Primary">
|
|
@foreach (var item in _items)
|
|
{
|
|
<MudSelectItem T="ThrowModeClass" Value="item">@item.Name</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
|
|
@code {
|
|
private ThrowModeClass _throwModeClass;
|
|
|
|
private ThrowModeClass ThrowModeClass
|
|
{
|
|
get => _throwModeClass;
|
|
set
|
|
{
|
|
if (_throwModeClass == value)
|
|
{
|
|
return;
|
|
}
|
|
_throwModeClass = value;
|
|
OnValueChanged?.Invoke(value.ThrowMode);
|
|
}
|
|
}
|
|
|
|
[Parameter, EditorRequired]
|
|
public Func<TState, ThrowMode> ValueSelector
|
|
{
|
|
get;
|
|
set;
|
|
} = null!;
|
|
|
|
|
|
[Parameter, EditorRequired]
|
|
public Action<ThrowMode> OnValueChanged
|
|
{
|
|
get;
|
|
set;
|
|
} = null!;
|
|
|
|
|
|
private readonly List<ThrowModeClass> _items = [];
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
_items.Add(new ThrowModeClass(ThrowMode.Reposition, "in die Vollen"));
|
|
_items.Add(new ThrowModeClass(ThrowMode.Decrease, "Abräumen"));
|
|
|
|
_throwModeClass = _items.FirstOrDefault(_ => _.ThrowMode == ValueSelector.Invoke(State.Value));
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
}
|