diff --git a/demo/Semi.Avalonia.Demo/Pages/RefreshContainerDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/RefreshContainerDemo.axaml index de3762c..4bb484e 100644 --- a/demo/Semi.Avalonia.Demo/Pages/RefreshContainerDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/RefreshContainerDemo.axaml @@ -4,12 +4,24 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:pages="clr-namespace:Semi.Avalonia.Demo.Pages" d:DesignHeight="450" d:DesignWidth="800" + x:DataType="pages:RefreshContainerDemoViewModel" + x:CompileBindings="True" mc:Ignorable="d"> - - - + + + + - + diff --git a/demo/Semi.Avalonia.Demo/Pages/RefreshContainerDemo.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/RefreshContainerDemo.axaml.cs index 0add79b..7e13123 100644 --- a/demo/Semi.Avalonia.Demo/Pages/RefreshContainerDemo.axaml.cs +++ b/demo/Semi.Avalonia.Demo/Pages/RefreshContainerDemo.axaml.cs @@ -1,14 +1,46 @@ -using Avalonia; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; +using CommunityToolkit.Mvvm.ComponentModel; namespace Semi.Avalonia.Demo.Pages; public partial class RefreshContainerDemo : UserControl { + private RefreshContainerDemoViewModel _viewModel; + public RefreshContainerDemo() { InitializeComponent(); + + _viewModel = new RefreshContainerDemoViewModel(); + + DataContext = _viewModel; + } + + private async void RefreshContainerPage_RefreshRequested(object? sender, RefreshRequestedEventArgs e) + { + var deferral = e.GetDeferral(); + + await _viewModel.AddToTop(); + + deferral.Complete(); + } +} + +public class RefreshContainerDemoViewModel : ObservableObject +{ + public ObservableCollection Items { get; } + + public RefreshContainerDemoViewModel() + { + Items = new ObservableCollection(Enumerable.Range(1, 200).Select(i => $"Item {i}")); + } + + public async Task AddToTop() + { + await Task.Delay(1000); + Items.Insert(0, $"Item {200 - Items.Count}"); } } \ No newline at end of file diff --git a/src/Semi.Avalonia/Controls/RefreshContainer.axaml b/src/Semi.Avalonia/Controls/RefreshContainer.axaml index 238c078..48497c7 100644 --- a/src/Semi.Avalonia/Controls/RefreshContainer.axaml +++ b/src/Semi.Avalonia/Controls/RefreshContainer.axaml @@ -28,21 +28,27 @@ - - + + + + + - - - - - + - + \ No newline at end of file diff --git a/src/Semi.Avalonia/Themes/Dark/RefreshContainer.axaml b/src/Semi.Avalonia/Themes/Dark/RefreshContainer.axaml index 9be9ad3..a77eb29 100644 --- a/src/Semi.Avalonia/Themes/Dark/RefreshContainer.axaml +++ b/src/Semi.Avalonia/Themes/Dark/RefreshContainer.axaml @@ -1,4 +1,4 @@ - - + + \ No newline at end of file diff --git a/src/Semi.Avalonia/Themes/Light/RefreshContainer.axaml b/src/Semi.Avalonia/Themes/Light/RefreshContainer.axaml index 397a7bb..e67b05b 100644 --- a/src/Semi.Avalonia/Themes/Light/RefreshContainer.axaml +++ b/src/Semi.Avalonia/Themes/Light/RefreshContainer.axaml @@ -1,4 +1,4 @@ - - + + \ No newline at end of file diff --git a/src/Semi.Avalonia/Themes/Shared/RefreshContainer.axaml b/src/Semi.Avalonia/Themes/Shared/RefreshContainer.axaml index 9a5161c..e41e85f 100644 --- a/src/Semi.Avalonia/Themes/Shared/RefreshContainer.axaml +++ b/src/Semi.Avalonia/Themes/Shared/RefreshContainer.axaml @@ -1,3 +1,3 @@ - M14.2 3.78966C9.66551 2.57466 5.00465 5.26561 3.78964 9.80007C3.12066 12.2967 3.63433 14.8301 4.99177 16.8102C5.46019 17.4935 5.28601 18.4271 4.60273 18.8955C3.91945 19.364 2.98581 19.1898 2.51739 18.5065C0.685557 15.8344 -0.0134454 12.4023 0.891867 9.02361C2.5357 2.88875 8.84157 -0.751945 14.9764 0.891885C21.1113 2.53572 24.752 8.84159 23.1082 14.9765C22.8937 15.7767 22.0712 16.2515 21.271 16.0371C20.4708 15.8227 19.996 15.0002 20.2104 14.2C21.4254 9.66553 18.7344 5.00467 14.2 3.78966Z + 24 \ No newline at end of file