-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add refresh indication support for non-mobile platforms
- Loading branch information
1 parent
d7494e5
commit 7aeee51
Showing
4 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...oft/UI/Xaml/Controls/PullToRefresh/ProgressRing/ProgressRingRefreshInfoProviderAdapter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Microsoft.UI.Private.Controls; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Windows.Foundation; | ||
using Windows.UI.Xaml; | ||
|
||
namespace Uno.UI.Xaml.Controls; | ||
|
||
internal class ProgressRingRefreshInfoProviderAdapter : IRefreshInfoProviderAdapter | ||
{ | ||
private readonly RefreshContainer _refreshContainer; | ||
private IRefreshInfoProvider _refreshInfoProvider; | ||
private ProgressRingRefreshVisualizer _progressRingVisualizer; | ||
|
||
public ProgressRingRefreshInfoProviderAdapter(RefreshContainer refreshContainer) | ||
{ | ||
_refreshContainer = refreshContainer; | ||
} | ||
|
||
public IRefreshInfoProvider AdaptFromTree(UIElement root, Size visualizerSize) | ||
{ | ||
_refreshInfoProvider = new RefreshInfoProviderImpl(); | ||
_refreshInfoProvider.RefreshStarted += OnRefreshStarted; | ||
_refreshInfoProvider.RefreshCompleted += OnRefreshCompleted; | ||
return _refreshInfoProvider; | ||
} | ||
|
||
private void OnRefreshStarted(IRefreshInfoProvider sender, object args) | ||
{ | ||
_progressRingVisualizer.Visibility = Visibility.Visible; | ||
_progressRingVisualizer.ProgressRing.Visibility = Visibility.Visible; | ||
_progressRingVisualizer.ProgressRing.IsActive = true; | ||
} | ||
|
||
private void OnRefreshCompleted(IRefreshInfoProvider sender, object args) | ||
{ | ||
_progressRingVisualizer.Visibility = Visibility.Collapsed; | ||
_progressRingVisualizer.ProgressRing.Visibility = Visibility.Collapsed; | ||
_progressRingVisualizer.ProgressRing.IsActive = false; | ||
} | ||
|
||
public void SetAnimations(UIElement refreshVisualizerAnimatableContainer) | ||
{ | ||
if (refreshVisualizerAnimatableContainer is ProgressRingRefreshVisualizer progressRingVisualizer) | ||
{ | ||
if (_progressRingVisualizer != progressRingVisualizer) | ||
{ | ||
progressRingVisualizer.Visibility = Visibility.Collapsed; | ||
progressRingVisualizer.ProgressRing.IsActive = false; | ||
_progressRingVisualizer = progressRingVisualizer; | ||
} | ||
} | ||
else | ||
{ | ||
_progressRingVisualizer = null; | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
// Unsubscribe events. | ||
if (_refreshInfoProvider != null) | ||
{ | ||
_refreshInfoProvider.RefreshStarted -= OnRefreshStarted; | ||
_refreshInfoProvider.RefreshCompleted -= OnRefreshCompleted; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...UI/Microsoft/UI/Xaml/Controls/PullToRefresh/ProgressRing/ProgressRingRefreshVisualizer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
using WUXProgressRing = Windows.UI.Xaml.Controls.ProgressRing; | ||
|
||
namespace Uno.UI.Xaml.Controls; | ||
|
||
internal class ProgressRingRefreshVisualizer : RefreshVisualizer | ||
{ | ||
public ProgressRingRefreshVisualizer() | ||
{ | ||
Content = ProgressRing; | ||
} | ||
|
||
internal WUXProgressRing ProgressRing { get; } = new WUXProgressRing(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters