Files
2025-12-16 23:22:01 -05:00

104 lines
3.4 KiB
C#

namespace MarketAlly.SpotlightTour.Maui;
/// <summary>
/// Represents a single step in an onboarding tour.
/// </summary>
public class OnboardingStep
{
/// <summary>
/// The target visual element for this step.
/// </summary>
public required VisualElement Target { get; init; }
/// <summary>
/// Unique key identifying this step.
/// </summary>
public string? StepKey { get; init; }
/// <summary>
/// Title text displayed in the callout.
/// </summary>
public string? Title { get; init; }
/// <summary>
/// Description text displayed in the callout.
/// </summary>
public string? Description { get; init; }
/// <summary>
/// Order/sequence number within the group.
/// </summary>
public int Order { get; init; }
/// <summary>
/// Group name for organizing multiple tours.
/// </summary>
public string? Group { get; init; }
/// <summary>
/// Whether spotlight cutout is enabled for this step.
/// </summary>
public bool SpotlightEnabled { get; init; } = true;
/// <summary>
/// Callout placement relative to the spotlight.
/// </summary>
public CalloutPlacement Placement { get; init; } = CalloutPlacement.Auto;
/// <summary>
/// Shape of the spotlight cutout.
/// </summary>
public SpotlightShape SpotlightShape { get; init; } = SpotlightShape.RoundedRectangle;
/// <summary>
/// Padding around the target in the spotlight cutout.
/// </summary>
public Thickness SpotlightPadding { get; init; } = new(8);
/// <summary>
/// Corner radius for RoundedRectangle shape.
/// </summary>
public double SpotlightCornerRadius { get; init; } = 8.0;
/// <summary>
/// Behavior when user taps the spotlight.
/// </summary>
public SpotlightTapBehavior TapBehavior { get; init; } = SpotlightTapBehavior.None;
/// <summary>
/// Action to execute when entering this step.
/// Runs before the spotlight animates to allow UI preparation.
/// </summary>
public Func<OnboardingStep, CancellationToken, Task>? OnEntering { get; init; }
/// <summary>
/// Action to execute when leaving this step.
/// Runs before navigating to the next/previous step.
/// </summary>
public Func<OnboardingStep, CancellationToken, Task>? OnLeaving { get; init; }
/// <summary>
/// Creates an OnboardingStep from a tagged VisualElement.
/// </summary>
public static OnboardingStep FromElement(VisualElement element)
{
return new OnboardingStep
{
Target = element,
StepKey = Onboarding.GetEffectiveStepKey(element),
Title = Onboarding.GetTitle(element),
Description = Onboarding.GetDescription(element),
Order = Onboarding.GetOrder(element),
Group = Onboarding.GetGroup(element),
SpotlightEnabled = Onboarding.GetSpotlightEnabled(element),
Placement = Onboarding.GetPlacement(element),
SpotlightShape = Onboarding.GetSpotlightShape(element),
SpotlightPadding = Onboarding.GetSpotlightPadding(element),
SpotlightCornerRadius = Onboarding.GetSpotlightCornerRadius(element),
TapBehavior = Onboarding.GetTapBehavior(element),
OnEntering = Onboarding.GetOnEntering(element),
OnLeaving = Onboarding.GetOnLeaving(element)
};
}
}