Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding ability to disable animations #553

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/controls/LoadingView.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Source|ILoadable|Gets and sets the source `ILoadable` associated with this contr
LoadingContent|object|Gets or sets the content to be displayed during loading/waiting.
LoadingContentTemplate|DataTemplate|Gets or sets the template to be used to display the LoadingContent during loading/waiting.
LoadingContentTemplateSelector|DataTemplateSelector|Gets or sets the template selector to be used to display the LoadingContent during loading/waiting.
DisableAnimantions|bool|Gets and sets whether animations will run when transitioning between states.
nickrandolph marked this conversation as resolved.
Show resolved Hide resolved

## ILoadable
Describes if this instance is currently in a busy state and notifies subscribers that said state when has changed.
Expand Down
21 changes: 20 additions & 1 deletion src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ private class VisualStateNames
public const string Loaded = nameof(Loaded);
}

#region DependencyProperty: DisableAnimations

public static DependencyProperty DisableAnimationsProperty { get; } = DependencyProperty.Register(
nameof(DisableAnimations),
typeof(bool),
typeof(LoadingView),
new PropertyMetadata(false));

/// <summary>
/// Gets and sets the whether animations will play when transitioning to Loaded state.
/// </summary>
public bool DisableAnimations
{
get => (bool)GetValue(DisableAnimationsProperty);
set => SetValue(DisableAnimationsProperty, value);
}

#endregion

#region DependencyProperty: Source

public static DependencyProperty SourceProperty { get; } = DependencyProperty.Register(
Expand Down Expand Up @@ -131,7 +150,7 @@ private void UpdateVisualState()
? VisualStateNames.Loading
: VisualStateNames.Loaded;

VisualStateManager.GoToState(this, loadingState, IsLoaded);
VisualStateManager.GoToState(this, loadingState, IsLoaded && !DisableAnimations);
}
}
}