# MASpotlightTour API Reference Complete API documentation for the MASpotlightTour library. ## Table of Contents - [Namespace](#namespace) - [OnboardingHost](#onboardinghost) - [Onboarding (Attached Properties)](#onboarding-attached-properties) - [OnboardingStep](#onboardingstep) - [OnboardingScanner](#onboardingscanner) - [Enumerations](#enumerations) - [Events](#events) --- ## Namespace ```csharp using MarketAlly.SpotlightTour.Maui; ``` XAML namespace: ```xml xmlns:tour="clr-namespace:MarketAlly.SpotlightTour.Maui;assembly=MarketAlly.SpotlightTour.Maui" ``` --- ## OnboardingHost The main host control that orchestrates the onboarding tour experience. Add this as an overlay on your page to enable spotlight tours. **Inheritance:** `Grid` → `OnboardingHost` ### Properties #### Display & Mode Properties | Property | Type | Default | Description | |----------|------|---------|-------------| | `DisplayMode` | `TourDisplayMode` | `SpotlightWithCallout` | The display mode for the tour. | | `Theme` | `TourTheme` | `Light` | Visual theme (Light, Dark, or System). | | `TourFlowDirection` | `FlowDirection` | `MatchParent` | RTL support: `MatchParent`, `LeftToRight`, or `RightToLeft`. | | `AnimationsEnabled` | `bool` | `true` | Whether animations are enabled. | | `AnimationDuration` | `uint` | `250` | Animation duration in milliseconds. | #### Overlay Properties | Property | Type | Default | Description | |----------|------|---------|-------------| | `DimOpacity` | `double` | `0.6` | Opacity of the dimmed overlay (0.0 - 1.0). | | `DimColor` | `Color` | `Colors.Black` | Color of the dimmed overlay. | #### Callout Properties | Property | Type | Default | Description | |----------|------|---------|-------------| | `CalloutPositionMode` | `CalloutPositionMode` | `Following` | Positioning strategy for the callout card. | | `CalloutCorner` | `CalloutCorner` | `BottomLeft` | Corner to use when `CalloutPositionMode` is `FixedCorner`. | | `CalloutCornerMargin` | `double` | `16.0` | Margin from screen edge when using corner positioning. | #### Navigator Properties | Property | Type | Default | Description | |----------|------|---------|-------------| | `ShowCornerNavigator` | `bool` | `true` | Whether to show the corner navigator control. | | `CornerNavigatorPlacement` | `CornerNavigatorPlacement` | `BottomRight` | Position of the corner navigator. | | `ShowSkipButton` | `bool` | `true` | Whether to show the skip/done button in navigator. | | `ShowArrow` | `bool` | `true` | Whether to show the arrow indicator pointing to spotlight. | #### Auto Features | Property | Type | Default | Description | |----------|------|---------|-------------| | `AutoStartDelay` | `int` | `0` | Delay in ms before auto-starting. 0 = disabled. | | `AutoStartGroup` | `string?` | `null` | Group to use for auto-start. | | `AutoAdvanceDelay` | `int` | `0` | Delay in ms before auto-advancing. 0 = disabled. | | `AutoLoop` | `int` | `0` | Number of times to repeat the tour. 0 = disabled. | #### Intro View | Property | Type | Default | Description | |----------|------|---------|-------------| | `IntroView` | `View?` | `null` | Custom intro/welcome view displayed before tour starts. | | `ShowIntro` | `bool` | `true` | Controls whether intro view is displayed. Set to `false` to skip intro (useful for returning users). | | `AllowTapAnywhereToDismissIntro` | `bool` | `false` | When `true`, tapping anywhere on the dimmed overlay while intro is shown will skip the tour. | ### Read-Only Properties | Property | Type | Description | |----------|------|-------------| | `IsRunning` | `bool` | Whether a tour is currently running. | | `CurrentStepIndex` | `int` | Current step index (0-based). -1 if not running. | | `TotalSteps` | `int` | Total number of steps in the tour. | | `CurrentStep` | `OnboardingStep?` | Current step, or null if no tour is running. | | `IsShowingIntro` | `bool` | Whether the intro view is currently displayed. | ### Methods #### Starting Tours ```csharp Task StartTourAsync(VisualElement root, string? group = null) ``` Starts the onboarding tour by scanning for tagged elements. Returns when the tour ends. **Parameters:** - `root`: The root element to scan (typically `this.Content` or a layout). - `group`: Optional group filter. If null, includes all steps. **Returns:** `TourResult` indicating how the tour ended. --- ```csharp Task StartTourFromStepAsync(VisualElement root, string stepKey, string? group = null) ``` Starts the tour from a specific step identified by its key. **Parameters:** - `root`: The root element to scan. - `stepKey`: The step key to start from. - `group`: Optional group filter. **Returns:** `TourResult` indicating how the tour ended. --- ```csharp Task StartTourWithIntroAsync(VisualElement root, string? group = null, bool showIntro = true) ``` Starts the tour, optionally showing the intro view first. **Parameters:** - `root`: The root element to scan. - `group`: Optional group filter. - `showIntro`: Whether to show the intro view (if configured). **Returns:** `TourResult` indicating how the tour ended. #### Navigation ```csharp Task GoToStepAsync(int index) ``` Navigates to a specific step by index. --- ```csharp void GoToNextStep() ``` Advances to the next step. Completes the tour if on the last step. --- ```csharp void GoToPreviousStep() ``` Returns to the previous step. Does nothing if on the first step. #### Ending Tours ```csharp void CompleteTour() ``` Completes the tour (user finished all steps). Triggers `TourCompleted` event. --- ```csharp void SkipTour() ``` Skips/cancels the tour. Triggers `TourSkipped` event. --- ```csharp void StopTour() ``` Stops any currently running tour. Sets result to `Cancelled`. #### Intro View ```csharp void DisplayIntroView() ``` Displays the intro view. Called automatically by `StartTourWithIntroAsync` when `ShowIntro` property is `true`. --- ```csharp void DismissIntro() ``` Dismisses the intro view and continues with the tour. ### Events | Event | Args | Description | |-------|------|-------------| | `TourStarted` | `EventArgs` | Raised when the tour starts. | | `TourCompleted` | `EventArgs` | Raised when the user completes all steps. | | `TourSkipped` | `EventArgs` | Raised when the user skips the tour. | | `TourEnded` | `EventArgs` | Raised when the tour ends (any reason). | | `StepEntering` | `StepActionEventArgs` | Raised before entering a step. Async. Can set `Skip = true`. | | `StepEntered` | `StepActionEventArgs` | Raised after step is fully visible (after animations). | | `StepLeaving` | `StepActionEventArgs` | Raised before leaving the current step. Async. | | `StepChanged` | `OnboardingStepEventArgs` | Raised when moving to a new step. | | `IntroShown` | `EventArgs` | Raised when the intro view is shown. | | `IntroDismissed` | `EventArgs` | Raised when the intro view is dismissed. | ### Step Action Registration ```csharp void RegisterStepEnteringAction(string stepKey, Func action) ``` Registers an action to execute when entering a specific step (by StepKey). The action runs before the spotlight animates to the step. --- ```csharp void RegisterStepLeavingAction(string stepKey, Func action) ``` Registers an action to execute when leaving a specific step (by StepKey). The action runs before navigating away. --- ```csharp bool UnregisterStepEnteringAction(string stepKey) ``` Removes a registered entering action for a step. Returns true if the action was removed. --- ```csharp bool UnregisterStepLeavingAction(string stepKey) ``` Removes a registered leaving action for a step. Returns true if the action was removed. --- ```csharp void ClearStepActions() ``` Clears all registered step actions (both entering and leaving). ### Usage Example ```xml ``` ```csharp var result = await TourHost.StartTourAsync(this.Content); if (result == TourResult.Completed) { // Tour completed successfully } ``` --- ## Onboarding (Attached Properties) Static class providing attached properties for tagging UI elements as onboarding/tour steps. ### Attached Properties #### Identification | Property | Type | Default | Description | |----------|------|---------|-------------| | `StepKey` | `string?` | `null` | Unique key identifying the step. Falls back to `AutomationId` if not set. | | `Group` | `string?` | `null` | Group name for organizing multiple tours. | | `Order` | `int` | `0` | Sequence number within the group. Lower numbers appear first. | #### Content | Property | Type | Default | Description | |----------|------|---------|-------------| | `Title` | `string?` | `null` | Title text displayed in the callout. | | `Description` | `string?` | `null` | Description text displayed in the callout. | #### Spotlight Appearance | Property | Type | Default | Description | |----------|------|---------|-------------| | `SpotlightEnabled` | `bool` | `true` | Whether this element participates in spotlight cutouts. | | `SpotlightShape` | `SpotlightShape` | `RoundedRectangle` | Shape of the spotlight cutout. | | `SpotlightPadding` | `Thickness` | `8` | Padding around the target element. | | `SpotlightCornerRadius` | `double` | `8.0` | Corner radius for `RoundedRectangle` shape. | #### Behavior | Property | Type | Default | Description | |----------|------|---------|-------------| | `Placement` | `CalloutPlacement` | `Auto` | Where to place the callout relative to this element. | | `TapBehavior` | `SpotlightTapBehavior` | `None` | Behavior when user taps the spotlight. | #### Step Actions | Property | Type | Default | Description | |----------|------|---------|-------------| | `OnEntering` | `Func?` | `null` | Action to execute when entering this step. Runs before spotlight animation. | | `OnLeaving` | `Func?` | `null` | Action to execute when leaving this step. Runs before navigating away. | ### Static Methods ```csharp string? GetEffectiveStepKey(BindableObject view) ``` Gets the step key, falling back to `AutomationId` if `StepKey` is not set. --- ```csharp bool IsOnboardingStep(BindableObject view) ``` Returns `true` if the element is tagged as an onboarding step (has StepKey, Title, or Description). ### XAML Usage ```xml