Table of Contents

Class SkiaShell

Namespace
DrawnUi.Controls
Assembly
DrawnUi.Maui.dll

A Canvas with Navigation capabilities

public class SkiaShell : BasePageReloadable, INotifyPropertyChanged, IVisualTreeElement, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, ILayout, IPageController, IVisualElementController, IElementController, IElementConfiguration<Page>, ISafeAreaView, ITitledElement, IToolbarElement, IContentView, IPadding, ICrossPlatformLayout, IHotReloadableView, IView, IElement, ITransform, IReplaceableView, IDisposable
Inheritance
SkiaShell
Implements
Inherited Members
Extension Methods

Constructors

SkiaShell()

public SkiaShell()

Fields

LockLayers

protected SemaphoreSlim LockLayers

Field Value

SemaphoreSlim

LockNavigation

protected SemaphoreSlim LockNavigation

Field Value

SemaphoreSlim

LogEnabled

public static bool LogEnabled

Field Value

bool

PopupBackgroundColor

Default background tint for freezing popups/modals etc

public static Color PopupBackgroundColor

Field Value

Color

PopupsAnimationSpeed

public static float PopupsAnimationSpeed

Field Value

float

PopupsBackgroundBlur

Default background blur amount for freezing popups/modals etc

public static float PopupsBackgroundBlur

Field Value

float

PopupsCancelAnimationsAfterMs

public static int PopupsCancelAnimationsAfterMs

Field Value

int

RouteProperty

public static readonly BindableProperty RouteProperty

Field Value

BindableProperty

Services

protected readonly IServiceProvider Services

Field Value

IServiceProvider

ToastBackgroundColor

public static Color ToastBackgroundColor

Field Value

Color

ToastTextColor

public static Color ToastTextColor

Field Value

Color

ToastTextFont

public static string ToastTextFont

Field Value

string

ToastTextFontWeight

public static int ToastTextFontWeight

Field Value

int

ToastTextMargins

public static double ToastTextMargins

Field Value

double

ToastTextSize

public static double ToastTextSize

Field Value

double

ZIndexModals

public static int ZIndexModals

Field Value

int

ZIndexPopups

public static int ZIndexPopups

Field Value

int

ZIndexToasts

public static int ZIndexToasts

Field Value

int

_lockLayers

protected object _lockLayers

Field Value

object

_rootRoute

protected string _rootRoute

Field Value

string

_topmost

protected SkiaControl _topmost

Field Value

SkiaControl

Properties

BottomInsets

public double BottomInsets { get; set; }

Property Value

double

Buffer

Can use to pass items as models between viewmodels

public static Dictionary<string, object> Buffer { get; }

Property Value

Dictionary<string, object>

Canvas

public Canvas Canvas { get; }

Property Value

Canvas

CurrentRoute

public SkiaShell.ShellCurrentRoute CurrentRoute { get; protected set; }

Property Value

SkiaShell.ShellCurrentRoute

CurrentRouteAuto

public string CurrentRouteAuto { get; }

Property Value

string

FreezingModals

public List<SkiaControl> FreezingModals { get; protected set; }

Property Value

List<SkiaControl>

FrozenLayers

public Dictionary<SkiaControl, SkiaControl> FrozenLayers { get; }

Property Value

Dictionary<SkiaControl, SkiaControl>

Initialized

public bool Initialized { get; protected set; }

Property Value

bool

MenuItems

public ObservableCollection<MenuPageItem> MenuItems { get; }

Property Value

ObservableCollection<MenuPageItem>

ModalStack

public IReadOnlyList<Page> ModalStack { get; }

Property Value

IReadOnlyList<Page>

NavigationLayout

The main control that pushes pages, switches tabs etc

public SkiaViewSwitcher NavigationLayout { get; set; }

Property Value

SkiaViewSwitcher

NavigationStack

public IReadOnlyList<Page> NavigationStack { get; }

Property Value

IReadOnlyList<Page>

NavigationStackModals

public LinkedList<SkiaShell.PageInStack> NavigationStackModals { get; }

Property Value

LinkedList<SkiaShell.PageInStack>

NavigationStackScreens

public LinkedList<SkiaShell.PageInStack> NavigationStackScreens { get; }

Property Value

LinkedList<SkiaShell.PageInStack>

OnShellGoBack

public static SkiaShell.IHandleGoBack OnShellGoBack { get; set; }

Property Value

SkiaShell.IHandleGoBack

OrderedRoute

public string OrderedRoute { get; protected set; }

Property Value

string

Popups

public SkiaShell.NavigationLayer<SkiaControl> Popups { get; }

Property Value

SkiaShell.NavigationLayer<SkiaControl>

RootLayout

Use this for covering everything in a modal way, precisely tabs

public SkiaControl RootLayout { get; set; }

Property Value

SkiaControl

ShellLayout

public SkiaControl ShellLayout { get; set; }

Property Value

SkiaControl

StatusBarHeight

public double StatusBarHeight { get; set; }

Property Value

double

Toasts

public SkiaShell.NavigationLayer<SkiaControl> Toasts { get; }

Property Value

SkiaShell.NavigationLayer<SkiaControl>

TopInsets

public double TopInsets { get; set; }

Property Value

double

Methods

AddToCurrentRouteNodes(string, SkiaControl)

protected void AddToCurrentRouteNodes(string registered, SkiaControl created)

Parameters

registered string
created SkiaControl

ApplyShellPropertiesToCanvas()

public virtual void ApplyShellPropertiesToCanvas()

AwaitLayersLock(string)

protected virtual Task AwaitLayersLock(string caller = null)

Parameters

caller string

Returns

Task

AwaitNavigationLock(string)

protected virtual Task AwaitNavigationLock(string caller = null)

Parameters

caller string

Returns

Task

BuildRoute(string, IDictionary<string, object>)

public static string BuildRoute(string host, IDictionary<string, object> arguments = null)

Parameters

host string
arguments IDictionary<string, object>

Returns

string

CanFreezeLayout()

Override this if you have custom navigation layers and custom logic to decide if we can unfreeze background.

public virtual bool CanFreezeLayout()

Returns

bool

CanUnfreezeLayout()

Override this if you have custom navigation layers and custom logic to decide if we can unfreeze background.

public virtual bool CanUnfreezeLayout()

Returns

bool

CloseAllPopups()

public Task CloseAllPopups()

Returns

Task

CloseAllToasts()

public Task CloseAllToasts()

Returns

Task

ClosePopupAsync(SkiaControl, bool)

public Task ClosePopupAsync(SkiaControl popup, bool animated)

Parameters

popup SkiaControl
animated bool

Returns

Task

ClosePopupAsync(bool)

Close topmost popup

public Task ClosePopupAsync(bool animated)

Parameters

animated bool

Returns

Task

CreateModalDrawer(bool, bool, bool, Color)

protected virtual SkiaShell.ModalWrapper CreateModalDrawer(bool useGestures, bool animated, bool willFreeze, Color backgroundColor)

Parameters

useGestures bool
animated bool
willFreeze bool
backgroundColor Color

Returns

SkiaShell.ModalWrapper

Dispose(bool)

protected override void Dispose(bool isDisposing)

Parameters

isDisposing bool

ExecuteActionRoute(string)

public static bool ExecuteActionRoute(string route)

Parameters

route string

Returns

bool

FormatRoute(List<string>)

public static string FormatRoute(List<string> segments)

Parameters

segments List<string>

Returns

string

FormatRoute(string)

public static string FormatRoute(string route)

Parameters

route string

Returns

string

FreezeRootLayout(SkiaControl, SKImage, bool, Color, float)

public virtual Task FreezeRootLayout(SkiaControl control, SKImage screenshot, bool animated, Color tintScreenshot, float blurScreenshot)

Parameters

control SkiaControl
screenshot SKImage
animated bool
tintScreenshot Color
blurScreenshot float

Returns

Task

FreezeRootLayout(SkiaControl, bool, Color, float)

Freezes layout below the overlay: takes screenshot of RootLayout, places it over, then hides RootLayout to avoid rendering it. Can override

public virtual Task FreezeRootLayout(SkiaControl control, bool animated, Color tintScreenshot, float blurScreenshot)

Parameters

control SkiaControl
animated bool
tintScreenshot Color
blurScreenshot float

Returns

Task

FreezeRootLayoutInternal(SkiaControl, SkiaControl, bool)

public virtual Task FreezeRootLayoutInternal(SkiaControl control, SkiaControl screenshot, bool animated)

Parameters

control SkiaControl
screenshot SkiaControl
animated bool

Returns

Task

GetOrCreateContent(string)

public BindableObject GetOrCreateContent(string route)

Parameters

route string

Returns

BindableObject

GetOrCreateContentSetArguments<T>(string, IDictionary<string, object>)

public virtual T GetOrCreateContentSetArguments<T>(string part, IDictionary<string, object> arguments) where T : BindableObject

Parameters

part string
arguments IDictionary<string, object>

Returns

T

Type Parameters

T

GetTopModal()

public SkiaControl GetTopModal()

Returns

SkiaControl

GetTopPopup()

public SkiaControl GetTopPopup()

Returns

SkiaControl

GetTopmostView()

Gets the topmost visible view: if no popups and modals are open then return NavigationLayout otherwise return the topmost popup or modal depending which ZIndexModals or ZIndexPopups is higher. If view is inside a shell wrapper will return just the view.

public SkiaControl GetTopmostView()

Returns

SkiaControl

GetTopmostViewInternal()

Gets the topmost visible view: if no popups and modals are open then return NavigationLayout otherwise return the topmost popup or modal depending which ZIndexModals or ZIndexPopups is higher. If pushed view is inside a shell wrapper will return the wrapper.

public SkiaControl GetTopmostViewInternal()

Returns

SkiaControl

GoBack(bool)

public virtual bool GoBack(bool animate)

Parameters

animate bool

Returns

bool

GoBackDefault(bool)

public bool GoBackDefault(bool animate)

Parameters

animate bool

Returns

bool

GoBackInRoute(bool)

This will not affect popups

protected Task<SkiaControl> GoBackInRoute(bool animate)

Parameters

animate bool

Returns

Task<SkiaControl>

GoToAsync(ShellNavigationState)

public virtual Task GoToAsync(ShellNavigationState state)

Parameters

state ShellNavigationState

Returns

Task

GoToAsync(ShellNavigationState, bool?, IDictionary<string, object>)

Navigate to a registered route. Arguments will be taken from query string of can be passed as parameter. You can receive them by implementing IQueryAttributable or using attribute [QueryProperty] in the page itsself or in the ViewModel that must be the screen's BindingContext upon registered screen instatiation. Animate can be specified otherwise will use it from Shell.PresentationMode attached property. This property will be also used for pushing as page, modal etc.

public virtual Task GoToAsync(ShellNavigationState state, bool? animate = null, IDictionary<string, object> arguments = null)

Parameters

state ShellNavigationState
animate bool?
arguments IDictionary<string, object>

Returns

Task

HasTopmostModalBindingContext<T>()

public bool HasTopmostModalBindingContext<T>()

Returns

bool

Type Parameters

T

ImportNavigationLayout(bool)

protected virtual void ImportNavigationLayout(bool replace = false)

Parameters

replace bool

ImportRootLayout(bool)

protected virtual void ImportRootLayout(bool replace = false)

Parameters

replace bool

Initialize(string)

public virtual void Initialize(string route)

Parameters

route string

NotifyAndCheckCanNavigate(SkiaControl, string, NavigationSource)

protected virtual bool NotifyAndCheckCanNavigate(SkiaControl view, string route, NavigationSource source)

Parameters

view SkiaControl
route string
source NavigationSource

Returns

bool

OnCurrentRouteChanged()

protected virtual void OnCurrentRouteChanged()

OnDisposing()

protected virtual void OnDisposing()

OnHandlerChanged()

When overridden in a derived class, should raise the HandlerChanged event.

protected override void OnHandlerChanged()

Remarks

It is the implementor's responsibility to raise the HandlerChanged event.

OnLayersChanged(SkiaControl)

Setup _topmost and send OnAppeared / OnDisappeared to views. Occurs when layers configuration changes, some layer go visible, some not, some are added, some are removed.

protected virtual void OnLayersChanged(SkiaControl dissapeared = null)

Parameters

dissapeared SkiaControl

OnLayoutInvalidated()

public virtual void OnLayoutInvalidated()

OnModalStackChanged(int)

public virtual void OnModalStackChanged(int count)

Parameters

count int

OnNavigated(SkiaShellNavigatedArgs)

protected virtual void OnNavigated(SkiaShellNavigatedArgs e)

Parameters

e SkiaShellNavigatedArgs

OnNavigating(SkiaShellNavigatingArgs)

protected virtual void OnNavigating(SkiaShellNavigatingArgs e)

Parameters

e SkiaShellNavigatingArgs

OnPagesStackChanged(int)

public virtual void OnPagesStackChanged(int count)

Parameters

count int

OnPopupsStackChanged(int)

public virtual void OnPopupsStackChanged(int count)

Parameters

count int

OnStarted()

protected virtual void OnStarted()

OnToastsStackChanged(int)

public virtual void OnToastsStackChanged(int count)

Parameters

count int

OpenPopupAsync(SkiaControl, bool, bool, bool, Color, SKPoint?)

Pass pixelsScaleInFrom you you want popup to animate appearing from a specific point instead of screen center.

public Task<SkiaControl> OpenPopupAsync(SkiaControl content, bool animated = true, bool closeWhenBackgroundTapped = true, bool showOverlay = true, Color backgroundColor = null, SKPoint? pixelsScaleInFrom = null)

Parameters

content SkiaControl
animated bool
closeWhenBackgroundTapped bool
showOverlay bool
backgroundColor Color
pixelsScaleInFrom SKPoint?

Returns

Task<SkiaControl>

ParseRoute(string)

public static SkiaShell.ParsedRoute ParseRoute(string route)

Parameters

route string

Returns

SkiaShell.ParsedRoute

ParseState(ShellNavigationState)

public static SkiaShell.ParsedRoute ParseState(ShellNavigationState state)

Parameters

state ShellNavigationState

Returns

SkiaShell.ParsedRoute

PopAsync(bool)

Returns the page so you could dispose it if needed. Uses ViewSwitcher.

public virtual Task<BindableObject> PopAsync(bool animated = true)

Parameters

animated bool

Returns

Task<BindableObject>

PopModalAsync(PageInStack, bool)

public virtual Task<BindableObject> PopModalAsync(SkiaShell.PageInStack inStack, bool animated)

Parameters

inStack SkiaShell.PageInStack
animated bool

Returns

Task<BindableObject>

PopModalAsync(SkiaControl, bool)

protected Task<SkiaControl> PopModalAsync(SkiaControl modal, bool animated)

Parameters

modal SkiaControl
animated bool

Returns

Task<SkiaControl>

PopModalAsync(bool)

public virtual Task<BindableObject> PopModalAsync(bool animated)

Parameters

animated bool

Returns

Task<BindableObject>

PopTabToRoot()

public Task PopTabToRoot()

Returns

Task

PopToRootAsync()

public Task PopToRootAsync()

Returns

Task

PresentAsync(string, bool?, IDictionary<string, object>)

public virtual Task<SkiaControl> PresentAsync(string registered, bool? animate, IDictionary<string, object> arguments = null)

Parameters

registered string
animate bool?
arguments IDictionary<string, object>

Returns

Task<SkiaControl>

PushAsync(BindableObject, bool, bool)

Uses ViewSwitcher to push a view on the canvas, into the current tab if any.

public virtual Task PushAsync(BindableObject page, bool animated = true, bool notify = true)

Parameters

page BindableObject
animated bool
notify bool

Returns

Task

PushAsync(string, bool, IDictionary<string, object>)

Uses ViewSwitcher to push a view on the canvas, into the current tab if any. We can use a route with arguments to instantiate the view instead of passing an instance.

public virtual Task PushAsync(string registered, bool animated = true, IDictionary<string, object> arguments = null)

Parameters

registered string
animated bool
arguments IDictionary<string, object>

Returns

Task

PushModalAsync(BindableObject, bool, bool, bool, IDictionary<string, object>)

Creates a SkiaDrawer opening over the RootLayout with the passed content. Override this method to create your own implementation. Default freezing background is True, control with frozenLayerBackgroundParameters parameter.

public virtual Task<SkiaControl> PushModalAsync(BindableObject page, bool useGestures, bool animated = true, bool freezeBackground = true, IDictionary<string, object> arguments = null)

Parameters

page BindableObject
useGestures bool
animated bool
freezeBackground bool
arguments IDictionary<string, object>

Returns

Task<SkiaControl>

PushModalAsync(string, bool, bool, bool, IDictionary<string, object>)

public virtual Task PushModalAsync(string registered, bool useGestures, bool animated = true, bool freezeBackground = true, IDictionary<string, object> arguments = null)

Parameters

registered string
useGestures bool
animated bool
freezeBackground bool
arguments IDictionary<string, object>

Returns

Task

PushModalRoute(SkiaControl, string, bool?)

protected virtual Task<SkiaControl> PushModalRoute(SkiaControl skia, string route, bool? animate)

Parameters

skia SkiaControl
route string
animate bool?

Returns

Task<SkiaControl>

PushRegisteredPageAsync(string, bool, IDictionary<string, object>)

public virtual Task PushRegisteredPageAsync(string registered, bool animate, IDictionary<string, object> arguments = null)

Parameters

registered string
animate bool
arguments IDictionary<string, object>

Returns

Task

RegisterActionRoute(string, Action)

public static void RegisterActionRoute(string route, Action switchToTab)

Parameters

route string
switchToTab Action

RegisterRoute(string, TypeRouteFactory)

public static void RegisterRoute(string route, SkiaShell.TypeRouteFactory factory)

Parameters

route string
factory SkiaShell.TypeRouteFactory

RegisterRoute(string, Type)

public void RegisterRoute(string route, Type type)

Parameters

route string
type Type

RemoveAsync(SkiaControl, bool?, IDictionary<string, object>)

public virtual Task<SkiaControl> RemoveAsync(SkiaControl modal, bool? animate, IDictionary<string, object> arguments = null)

Parameters

modal SkiaControl
animate bool?
arguments IDictionary<string, object>

Returns

Task<SkiaControl>

RemoveFromCurrentRouteNodes(SkiaControl)

protected bool RemoveFromCurrentRouteNodes(SkiaControl control)

Parameters

control SkiaControl

Returns

bool

ReplaceRootLayout(ISkiaControl)

protected virtual void ReplaceRootLayout(ISkiaControl newLayout)

Parameters

newLayout ISkiaControl

ReplaceShellLayout(ISkiaControl)

protected virtual void ReplaceShellLayout(ISkiaControl newLayout)

Parameters

newLayout ISkiaControl

Reset()

protected virtual void Reset()

SetArguments(BindableObject, IDictionary<string, object>)

protected virtual void SetArguments(BindableObject page, IDictionary<string, object> arguments)

Parameters

page BindableObject
arguments IDictionary<string, object>

SetCurrentRouteNodes(List<ShellStackChild>)

protected void SetCurrentRouteNodes(List<SkiaShell.ShellStackChild> children)

Parameters

children List<SkiaShell.ShellStackChild>

SetFrozenLayerVisibility(SkiaControl, bool)

Display or hide the background scrrenshot assotiated with an overlay control

protected Task SetFrozenLayerVisibility(SkiaControl control, bool isVisible)

Parameters

control SkiaControl
isVisible bool

Returns

Task

SetRoot(string, bool, IDictionary<string, object>)

Returns true if was replaced

public virtual SkiaControl SetRoot(string host, bool replace, IDictionary<string, object> arguments = null)

Parameters

host string
replace bool
arguments IDictionary<string, object>

Returns

SkiaControl

Exceptions

Exception

SetRoute(BindableObject, string)

public static void SetRoute(BindableObject obj, string value)

Parameters

obj BindableObject
value string

SetupAppeared(SkiaControl)

protected virtual void SetupAppeared(SkiaControl control)

Parameters

control SkiaControl

SetupDisappeared(SkiaControl)

protected virtual void SetupDisappeared(SkiaControl control)

Parameters

control SkiaControl

SetupFrozenLayersVisibility(SkiaControl)

protected void SetupFrozenLayersVisibility(SkiaControl except)

Parameters

except SkiaControl

SetupModalsVisibility(SkiaControl)

public virtual Task<bool> SetupModalsVisibility(SkiaControl control)

Parameters

control SkiaControl

Returns

Task<bool>

SetupRoot(ISkiaControl)

Main control inside RootLayout

protected virtual void SetupRoot(ISkiaControl shellLayout)

Parameters

shellLayout ISkiaControl

ShowToast(SkiaControl, int)

public void ShowToast(SkiaControl content, int msShowTime = 4000)

Parameters

content SkiaControl
msShowTime int

ShowToast(string, int)

public virtual void ShowToast(string text, int msShowTime = 4000)

Parameters

text string
msShowTime int

UnfreezeRootLayout(SkiaControl, bool)

pass who frozen the layout

public virtual Task UnfreezeRootLayout(SkiaControl control, bool animated)

Parameters

control SkiaControl
animated bool

Returns

Task

UnlockLayers(string)

protected virtual void UnlockLayers(string caller = null)

Parameters

caller string

UnlockNavigation(string)

protected virtual void UnlockNavigation(string caller = null)

Parameters

caller string

UpdateLayout()

public void UpdateLayout()

WrapScreenshot(SkiaControl, SKImage, Color, float, bool)

Override this to create your own image with your own effect of the screenshot to be placed under modal controls. Default is image with Darken Effect.

public virtual SkiaImage WrapScreenshot(SkiaControl control, SKImage screenshot, Color tint, float blur, bool animated)

Parameters

control SkiaControl
screenshot SKImage
tint Color
blur float
animated bool

Returns

SkiaImage

Events

ModalStackChanged

public event EventHandler<int> ModalStackChanged

Event Type

EventHandler<int>

Navigated

public event EventHandler<SkiaShellNavigatedArgs> Navigated

Event Type

EventHandler<SkiaShellNavigatedArgs>

Navigating

public event EventHandler<SkiaShellNavigatingArgs> Navigating

Event Type

EventHandler<SkiaShellNavigatingArgs>

OnRotation

public event EventHandler<RotationEventArgs> OnRotation

Event Type

EventHandler<RotationEventArgs>

PagesStackChanged

public event EventHandler<int> PagesStackChanged

Event Type

EventHandler<int>

PopupsStackChanged

public event EventHandler<int> PopupsStackChanged

Event Type

EventHandler<int>

RouteChanged

public event EventHandler RouteChanged

Event Type

EventHandler

TabReselected

public event EventHandler<IndexArgs> TabReselected

Event Type

EventHandler<IndexArgs>

ToastsStackChanged

public event EventHandler<int> ToastsStackChanged

Event Type

EventHandler<int>