Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Text;
using System.Threading.Tasks;
using static MudBlazor.Colors;
using MudExtensions.Extensions;

namespace MudExtensions
{
Expand Down Expand Up @@ -254,6 +255,38 @@ public async Task SetActiveIndex(int count, bool firstCompleted = false, bool sk
}
}

public async Task SetActiveStepByIndex(int index, bool firstCompleted = false, bool skipPreventProcess = false)
{
var stepChangeDirection = (
index == ActiveIndex ? StepChangeDirection.None :
index > ActiveIndex ? StepChangeDirection.Forward :
StepChangeDirection.Backward
);

if (!skipPreventProcess && PreventStepChange != null && PreventStepChange.Invoke(stepChangeDirection))
{
return;
}

if (ActiveIndex == index || index < 0 || Steps.Count < index)
{
return;
}

if (Steps.Count == index && IsAllStepsCompleted() == false)
{
return;
}

if (_animate != null)
{
await _animate.Refresh();
}

ActiveIndex = index;
await ActiveStepChanged.InvokeAsync(ActiveIndex);
}

public async Task CompleteStep(int index, bool moveToNextStep = true)
{
var isActiveStep = (index == ActiveIndex);
Expand Down
2 changes: 2 additions & 0 deletions ComponentViewer.Docs/Pages/Examples/StepperExample1.razor
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

<MudItem xs="12" sm="4" Style="box-shadow: rgba(240, 46, 170, 0.4) -3px 3px;">
<MudStack Spacing="4">
<MudNumericField @bind-Value="_activeIndex" Label="Change ActiveIndex" @bind-Value:after="(() => _stepper.SetActiveStepByIndex(_activeIndex))" Margin="Margin.Dense" />
<MudCheckBox @bind-Checked="_linear" Color="Color.Primary" Label="Linear" Dense="true" />
<MudCheckBox @bind-Checked="_disableAnimation" Color="Color.Primary" Label="Disable Animation" Dense="true" />
<MudCheckBox @bind-Checked="_disablePreviousButton" Color="Color.Primary" Label="Disable Previous Step Action Button" Dense="true" />
Expand Down Expand Up @@ -111,6 +112,7 @@
bool _addResultStep = true;
bool _customLocalization = false;
Color _color = Color.Primary;
int _activeIndex = 0;

private bool CheckChange(StepChangeDirection direction)
{
Expand Down