Table of Contents

Class SkiaLottie

Namespace
DrawnUi.Controls
Assembly
DrawnUi.Maui.dll
public class SkiaLottie : AnimatedFramesRenderer, INotifyPropertyChanged, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, IVisualElementController, IElementController, IView, ITransform, IElement, IVisualTreeElement, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISkiaGestureListener, IHasAfterEffects, ISkiaControl, IDrawnBase, ICanBeUpdatedWithContext, ICanBeUpdated, ISkiaDisposable, IDisposable
Inheritance
SkiaLottie
Implements
Inherited Members
Extension Methods

Constructors

SkiaLottie()

public SkiaLottie()

Fields

ApplyIsOnWhenNotPlayingProperty

public static readonly BindableProperty ApplyIsOnWhenNotPlayingProperty

Field Value

BindableProperty

CachedAnimations

To avoid reloading same files multiple times..

public static ConcurrentDictionary<string, string> CachedAnimations

Field Value

ConcurrentDictionary<string, string>

ColorTintProperty

public static readonly BindableProperty ColorTintProperty

Field Value

BindableProperty

ColorsProperty

public static readonly BindableProperty ColorsProperty

Field Value

BindableProperty

DefaultFrameWhenOnProperty

public static readonly BindableProperty DefaultFrameWhenOnProperty

Field Value

BindableProperty

IsOnProperty

public static readonly BindableProperty IsOnProperty

Field Value

BindableProperty

ProcessJson

public Func<string, string> ProcessJson

Field Value

Func<string, string>

SourceProperty

public static readonly BindableProperty SourceProperty

Field Value

BindableProperty

Properties

Animation

public Animation Animation { get; set; }

Property Value

Animation

ApplyIsOnWhenNotPlaying

Gets or sets whether the IsOn state should be applied when the animation is not playing. When true (default), changing IsOn will immediately seek to the appropriate frame. When false, IsOn state is only applied during animation playback.

public bool ApplyIsOnWhenNotPlaying { get; set; }

Property Value

bool

ColorTint

Gets or sets a global color tint applied to the entire Lottie animation. This provides a quick way to theme animations without modifying the source file. For multiple color replacements, use the Colors collection instead.

public Color ColorTint { get; set; }

Property Value

Color

Colors

public IList<Color> Colors { get; set; }

Property Value

IList<Color>

DefaultFrameWhenOn

For the case IsOn = True. What frame should we display at start or when stopped. 0 (START) is default, can specify other number. if value is less than 0 then will seek to the last available frame (END).

public int DefaultFrameWhenOn { get; set; }

Property Value

int

IsOn

Gets or sets the toggle state for animations with distinct on/off states. When true, displays DefaultFrameWhenOn frame when stopped. When false, displays DefaultFrame when stopped. Perfect for animated toggles, checkboxes, or switch controls.

public bool IsOn { get; set; }

Property Value

bool

Source

Gets or sets the path or URL to the Lottie JSON file. Supports web URLs, native file system paths (file://), and bundled resources from Resources/Raw folder. Example: "Lottie/animation.json" loads from Resources/Raw/Lottie/animation.json

public string Source { get; set; }

Property Value

string

Methods

ApplyDefaultFrame()

protected override void ApplyDefaultFrame()

ApplySpeed()

protected override void ApplySpeed()

ApplyTint(string, IList<Color>)

public static string ApplyTint(string json, IList<Color> newTints)

Parameters

json string
newTints IList<Color>

Returns

string

CalculateSaturation(Color)

public static float CalculateSaturation(Color color)

Parameters

color Color

Returns

float

CheckCanStartAnimator()

protected override bool CheckCanStartAnimator()

Returns

bool

ColorToArrayString(Color)

public static string ColorToArrayString(Color color)

Parameters

color Color

Returns

string

ColorToHexString(Color)

public static string ColorToHexString(Color color)

Parameters

color Color

Returns

string

ColorToRGBHexString(Color)

public static string ColorToRGBHexString(Color color)

Parameters

color Color

Returns

string

ColorToString(Color)

public static string ColorToString(Color color)

Parameters

color Color

Returns

string

CreateAnimation(string)

public Animation CreateAnimation(string json)

Parameters

json string

Returns

Animation

FindColorProperties(JToken, List<(JToken Token, Color Color)>)

public static void FindColorProperties(JToken token, List<(JToken Token, Color Color)> colorList)

Parameters

token JToken
colorList List<(JToken Token, Color Color)>

GoToEnd()

public virtual void GoToEnd()

GoToStart()

public virtual void GoToStart()

LoadAnimationFromJson(string)

This is not replacing current animation, use SetAnimation for that.

public Animation LoadAnimationFromJson(string json)

Parameters

json string

Returns

Animation

LoadLocalJson(string)

public string LoadLocalJson(string fileName)

Parameters

fileName string

Returns

string

LoadSource(string)

This is not replacing current animation, only pre-loading! Use SetAnimation after that if needed.

public Task<Animation> LoadSource(string fileName)

Parameters

fileName string

Returns

Task<Animation>

OnAnimatorInitializing()

protected override void OnAnimatorInitializing()

OnAnimatorSeeking(double)

protected override void OnAnimatorSeeking(double frame)

Parameters

frame double

OnAnimatorStarting()

protected override void OnAnimatorStarting()

OnAnimatorUpdated(double)

Override this to react on animator running.

protected override void OnAnimatorUpdated(double value)

Parameters

value double

OnDisposing()

Base performs some cleanup actions with Superview

public override void OnDisposing()

OnFinished()

protected override void OnFinished()

OnJsonLoaded(string)

Called by LoadAnimationFromResources after file was loaded so we can modify json if needed before it it consumed. Return json to be used. This is not called by LoadAnimationFromJson.

protected virtual string OnJsonLoaded(string json)

Parameters

json string

Returns

string

OnLayoutChanged()

DrawingRect size changed

protected override void OnLayoutChanged()

ReloadSource()

public virtual void ReloadSource()

RenderFrame(DrawingContext)

protected override void RenderFrame(DrawingContext ctx)

Parameters

ctx DrawingContext

SeekToDefaultFrame()

public virtual void SeekToDefaultFrame()

SetAnimation(Animation, bool)

public void SetAnimation(Animation animation, bool disposePrevious)

Parameters

animation Animation
disposePrevious bool

Stop()

public override void Stop()

StreamFromResourceUrl(string, Assembly)

public static Stream StreamFromResourceUrl(string url, Assembly assembly = null)

Parameters

url string
assembly Assembly

Returns

Stream

StringToXamarinColor(string)

public static Color StringToXamarinColor(string colorString)

Parameters

colorString string

Returns

Color

StringToXamarinColorFromHex(string)

public static Color StringToXamarinColorFromHex(string hexColor)

Parameters

hexColor string

Returns

Color