|
| 1 | +@namespace MudExtensions |
| 2 | +@inherits MudComponentBase |
| 3 | +@using MudExtensions.Enums |
| 4 | + |
| 5 | +<CascadingValue Value="this" IsFixed="true"> |
| 6 | + <MudStack Class="@Class" Style="@Style"> @*Row="Vertical"*@ |
| 7 | + <MudStack Row="true" AlignItems="@(HeaderTextView == HeaderTextView.NewLine ? AlignItems.Start : AlignItems.Center)"> @*Row="!Vertical"*@ |
| 8 | + @foreach (MudStep step in _steps) |
| 9 | + { |
| 10 | + if (step.IsResultStep) |
| 11 | + { |
| 12 | + continue; |
| 13 | + } |
| 14 | + bool active = IsStepActive(step); |
| 15 | + <div @onclick="@(Linear ? null : () => SetActiveIndex(step))" Class="@HeaderClassname"> |
| 16 | + <MudAvatar Class="@((active || step.Status != StepStatus.Continued) ? $"mud-theme-{Color.ToDescriptionString()}" : null)" Variant="@Variant" Size="Size.Small"> |
| 17 | + @if (step.Status == Enums.StepStatus.Completed) |
| 18 | + { |
| 19 | + <MudIcon Icon="@Icons.Filled.Done" Size="Size.Small" /> |
| 20 | + } |
| 21 | + else if (step.Status == StepStatus.Skipped) |
| 22 | + { |
| 23 | + <MudIcon Icon="@Icons.Filled.Remove" Size="Size.Small" /> |
| 24 | + } |
| 25 | + else |
| 26 | + { |
| 27 | + @(Steps.IndexOf(step) + 1) |
| 28 | + } |
| 29 | + </MudAvatar> |
| 30 | + @if (HeaderTextView == HeaderTextView.All || HeaderTextView == HeaderTextView.NewLine || (HeaderTextView == HeaderTextView.OnlyActiveText && active)) |
| 31 | + { |
| 32 | + <div> |
| 33 | + <MudText Align="Align.Center" Color="@(active ? Color : Color.Default)" Style="@(active ? "font-weight: 900" : null)">@step.Title</MudText> |
| 34 | + @if (step.Optional == true) |
| 35 | + { |
| 36 | + <MudText Align="@(HeaderTextView == HeaderTextView.NewLine ? Align.Center : Align.Start)" Typo="Typo.subtitle2" Color="@(active ? Color : Color.Default)" Style="@(active ? "font-weight: 500" : null)">@LocalizedStrings.Optional</MudText> |
| 37 | + } |
| 38 | + </div> |
| 39 | + } |
| 40 | + </div> |
| 41 | + |
| 42 | + if (_steps.Count - 1 != _steps.IndexOf(step)) |
| 43 | + { |
| 44 | + <span class="@GetDashClassname(step)"></span> |
| 45 | + } |
| 46 | + } |
| 47 | + </MudStack> |
| 48 | + <MudStack Class="mud-width-full" Justify="Justify.SpaceBetween"> |
| 49 | + <div class="@ContentClassname" style="@ContentStyle"> |
| 50 | + @ChildContent |
| 51 | + </div> |
| 52 | + |
| 53 | + <div class="d-flex gap-4"> |
| 54 | + @if (ActionContent != null) |
| 55 | + { |
| 56 | + @ActionContent |
| 57 | + } |
| 58 | + else |
| 59 | + { |
| 60 | + bool showResultStep = ShowResultStep(); |
| 61 | + if (ActiveIndex != 0) |
| 62 | + { |
| 63 | + if (ActiveIndex < Steps.Count && Steps[ActiveIndex].Status != StepStatus.Continued || showResultStep) |
| 64 | + { |
| 65 | + <MudIconButton Color="@Color" Variant="@Variant" Icon="@Icons.Filled.ChevronLeft" OnClick="@(() => SetActiveIndex(-1))" /> |
| 66 | + } |
| 67 | + else |
| 68 | + { |
| 69 | + <MudButton Color="@Color" Variant="@Variant" OnClick="@(() => SetActiveIndex(-1))">@LocalizedStrings.Previous</MudButton> |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + <MudSpacer /> |
| 74 | + |
| 75 | + if (showResultStep == false) |
| 76 | + { |
| 77 | + if ((ActiveIndex < Steps.Count && Steps[ActiveIndex].Status != StepStatus.Continued) || (ActiveIndex == Steps.Count - 1 && HasResultStep() == false && IsAllStepsCompleted())) |
| 78 | + { |
| 79 | + <MudButton Color="@Color" Variant="@Variant" Disabled="true">@(Steps[ActiveIndex].Status == StepStatus.Completed ? LocalizedStrings.Completed : LocalizedStrings.Skipped)</MudButton> |
| 80 | + } |
| 81 | + else if (ActiveIndex < Steps.Count && Steps[ActiveIndex].Optional == true) |
| 82 | + { |
| 83 | + <MudButton Color="@Color" Variant="@Variant" OnClick="@(() => SkipStep(ActiveIndex))">@LocalizedStrings.Skip</MudButton> |
| 84 | + } |
| 85 | + } |
| 86 | + if (showResultStep == false && !(ActiveIndex == Steps.Count - 1 && HasResultStep() == false && IsAllStepsCompleted())) |
| 87 | + { |
| 88 | + if (ActiveIndex < Steps.Count && Steps[ActiveIndex].Status != StepStatus.Continued) |
| 89 | + { |
| 90 | + <MudIconButton Color="@Color" Variant="@Variant" Icon="@Icons.Filled.ChevronRight" OnClick="@(() => SetActiveIndex(1))" /> |
| 91 | + } |
| 92 | + else |
| 93 | + { |
| 94 | + <MudButton Color="@Color" Variant="@Variant" OnClick="@(() => CompleteStep(ActiveIndex))">@GetNextButtonString()</MudButton> |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + </div> |
| 99 | + </MudStack> |
| 100 | + </MudStack> |
| 101 | +</CascadingValue> |
| 102 | + |
| 103 | +@if (DisableAnimation == false) |
| 104 | +{ |
| 105 | + <MudAnimate @ref="_animate" Selector="@($".mud-stepper-ani-{_animateGuid.ToString()}")" AnimationType="Enums.AnimationType.Fade" Value="1" Duration="0.5" /> |
| 106 | +} |
| 107 | + |
0 commit comments