From 521712e31182827e90d0df651e30137a5282c514 Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Wed, 26 Apr 2023 02:00:03 +1000 Subject: [PATCH 01/11] feat: switching to useTransitions --- doc/controls/LoadingView.md | 2 +- .../Controls/LoadingView/LoadingView.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/controls/LoadingView.md b/doc/controls/LoadingView.md index 19c122edf..6bb7e39eb 100644 --- a/doc/controls/LoadingView.md +++ b/doc/controls/LoadingView.md @@ -11,7 +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. +UseTransitions|bool|Gets and sets whether transitions will run when going between states. ## ILoadable Describes if this instance is currently in a busy state and notifies subscribers that said state when has changed. diff --git a/src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs b/src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs index e108f088d..33bde1a35 100644 --- a/src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs +++ b/src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs @@ -26,21 +26,21 @@ private class VisualStateNames public const string Loaded = nameof(Loaded); } - #region DependencyProperty: DisableAnimations + #region DependencyProperty: UseTransitions - public static DependencyProperty DisableAnimationsProperty { get; } = DependencyProperty.Register( - nameof(DisableAnimations), + public static DependencyProperty UseTransitionsProperty { get; } = DependencyProperty.Register( + nameof(UseTransitions), typeof(bool), typeof(LoadingView), - new PropertyMetadata(false)); + new PropertyMetadata(true)); /// - /// Gets and sets the whether animations will play when transitioning to Loaded state. + /// Gets and sets the whether transitions will play when going between states. /// - public bool DisableAnimations + public bool UseTransitions { - get => (bool)GetValue(DisableAnimationsProperty); - set => SetValue(DisableAnimationsProperty, value); + get => (bool)GetValue(UseTransitionsProperty); + set => SetValue(UseTransitionsProperty, value); } #endregion @@ -150,7 +150,7 @@ private void UpdateVisualState() ? VisualStateNames.Loading : VisualStateNames.Loaded; - VisualStateManager.GoToState(this, loadingState, IsLoaded && !DisableAnimations); + VisualStateManager.GoToState(this, loadingState, IsLoaded && UseTransitions); } } } From 910904554c36e575d32be91351970edd71a453bc Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Wed, 26 Apr 2023 18:24:30 +1000 Subject: [PATCH 02/11] fix: Preventing unnecessary calls to gotostate --- src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs b/src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs index 33bde1a35..f17276eff 100644 --- a/src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs +++ b/src/Uno.Toolkit.UI/Controls/LoadingView/LoadingView.cs @@ -120,6 +120,7 @@ public DataTemplateSelector LoadingContentTemplateSelector private readonly SerialDisposable _subscription = new(); private bool _isReady; + private string _currentState = string.Empty; public LoadingView() { @@ -141,7 +142,6 @@ private void OnSourceChanged(DependencyPropertyChangedEventArgs e) _subscription.Disposable = Source?.BindIsExecuting(UpdateVisualState); } - private void UpdateVisualState() { if (!_isReady) return; @@ -149,7 +149,11 @@ private void UpdateVisualState() var loadingState = Source?.IsExecuting ?? true ? VisualStateNames.Loading : VisualStateNames.Loaded; - + if(loadingState == _currentState) + { + return; + } + _currentState = loadingState; VisualStateManager.GoToState(this, loadingState, IsLoaded && UseTransitions); } } From 867d843d1b7bd3ef7a630809306e6051445d99ad Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Wed, 26 Apr 2023 18:26:37 +1000 Subject: [PATCH 03/11] fix: Separate extended splash animation duration from loadingview duration --- .../ExtendedSplashScreen/ExtendedSplashScreen.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Uno.Toolkit.UI/Controls/ExtendedSplashScreen/ExtendedSplashScreen.xaml b/src/Uno.Toolkit.UI/Controls/ExtendedSplashScreen/ExtendedSplashScreen.xaml index a3e0dca69..fe53105ff 100644 --- a/src/Uno.Toolkit.UI/Controls/ExtendedSplashScreen/ExtendedSplashScreen.xaml +++ b/src/Uno.Toolkit.UI/Controls/ExtendedSplashScreen/ExtendedSplashScreen.xaml @@ -5,7 +5,7 @@ xmlns:utu="using:Uno.Toolkit.UI" mc:Ignorable="d"> - 00:00:00.083 + 00:00:00.083 - -