Skip to content

Commit 50f0d22

Browse files
committed
2 parents d4b25e7 + 6185e8e commit 50f0d22

File tree

4 files changed

+1534
-45
lines changed

4 files changed

+1534
-45
lines changed

CodeBeam.MudBlazor.Extensions/Components/Stepper/MudStepper.razor.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Text;
1212
using System.Threading.Tasks;
1313
using static MudBlazor.Colors;
14+
using MudExtensions.Extensions;
1415

1516
namespace MudExtensions
1617
{
@@ -254,6 +255,38 @@ public async Task SetActiveIndex(int count, bool firstCompleted = false, bool sk
254255
}
255256
}
256257

258+
public async Task SetActiveStepByIndex(int index, bool firstCompleted = false, bool skipPreventProcess = false)
259+
{
260+
var stepChangeDirection = (
261+
index == ActiveIndex ? StepChangeDirection.None :
262+
index > ActiveIndex ? StepChangeDirection.Forward :
263+
StepChangeDirection.Backward
264+
);
265+
266+
if (!skipPreventProcess && PreventStepChange != null && PreventStepChange.Invoke(stepChangeDirection))
267+
{
268+
return;
269+
}
270+
271+
if (ActiveIndex == index || index < 0 || Steps.Count < index)
272+
{
273+
return;
274+
}
275+
276+
if (Steps.Count == index && IsAllStepsCompleted() == false)
277+
{
278+
return;
279+
}
280+
281+
if (_animate != null)
282+
{
283+
await _animate.Refresh();
284+
}
285+
286+
ActiveIndex = index;
287+
await ActiveStepChanged.InvokeAsync(ActiveIndex);
288+
}
289+
257290
public async Task CompleteStep(int index, bool moveToNextStep = true)
258291
{
259292
var isActiveStep = (index == ActiveIndex);

0 commit comments

Comments
 (0)