forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android/iOS] RefreshView (xamarin#7214)
* Swipe To Refresh * pull in pull to refresh * api changes * Added RefreshView CoreGallery and Gallery Samples (using ScrollView, ListView, CollectionView, etc.) * Code refactoring in RefreshViewRenderer (iOS) * Updated RefreshView Android Renderer * Fixed RefreshView Android samples in Core Gallery * Added initial RefreshView UWP implementation * Added another UWP RefreshView renderer using WinUI NuGet controls (RefreshContainer) * - additional linker settings * - uwp fixes * - disable SkipMicrosoftUIXamlCheckTargetPlatformVersion check * Update .nuspec/Xamarin.Forms.targets * Limited RefreshView in Android to support only content using scroll. Small changes in RefreshView iOS renderer. Updated Core Gallery RefreshView samples. * Fixed Visualizer colors in UWP RefreshView * Added UWP RefreshPullDirection Platform Specific * Small changes in code syntax in iOS renderer. * Removed some unnecessary curly braces . * Register effect provider in iOS RefreshView * Changes in RefreshView UWP Dispose * Added conditional code to manage the refresh control differently if it is iOS 10 or higher. * Fixed error in Android Core Gallery (Linker) Code refactoring and small changes (PR Feedback) * Changes disposing the Android renderer * - fix SkipMicrosoftUIXamlCheckTargetPlatformVersion so it can be turned off * Removed UWP RefreshView renderer and Platform Specific * - remove winui from nuspec * - remove skip checks from targets * - remove XamlControlsResources * - remove skip check on UAP platform * Revert changes in Android Core Gallery manifiest * Revert unnecessary space in UAP Platform csproj * Removed unnecessary new line in UWP Resources * Simplified RefreshView iOS Renderer. fixes xamarin#5882
- Loading branch information
1 parent
540a700
commit f224edf
Showing
26 changed files
with
1,098 additions
and
5 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
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
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
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
120 changes: 120 additions & 0 deletions
120
Xamarin.Forms.Controls/CoreGalleryPages/RefreshViewCoreGalleyPage.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,120 @@ | ||
using System; | ||
using System.Windows.Input; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
namespace Xamarin.Forms.Controls | ||
{ | ||
[Preserve(AllMembers = true)] | ||
internal class RefreshViewCoreGalleryPage : CoreGalleryPage<RefreshView> | ||
{ | ||
protected override bool SupportsFocus | ||
{ | ||
get { return false; } | ||
} | ||
|
||
protected override bool SupportsScroll | ||
{ | ||
get { return false; } | ||
} | ||
|
||
protected override void InitializeElement(RefreshView element) | ||
{ | ||
base.InitializeElement(element); | ||
|
||
BindingContext = new RefreshCoreGalleryViewModel(); | ||
|
||
element.Content = CreateContent(); | ||
element.SetBinding(RefreshView.CommandProperty, "RefreshCommand"); | ||
element.SetBinding(RefreshView.IsRefreshingProperty, "IsRefreshing"); | ||
} | ||
|
||
protected override void Build(StackLayout stackLayout) | ||
{ | ||
base.Build(stackLayout); | ||
|
||
var refreshColorContainer = new ViewContainer<RefreshView>(Test.RefreshView.RefreshColor, new RefreshView | ||
{ | ||
Content = CreateContent(), | ||
RefreshColor = Color.Red | ||
}); | ||
|
||
refreshColorContainer.View.SetBinding(RefreshView.CommandProperty, "RefreshCommand"); | ||
refreshColorContainer.View.SetBinding(RefreshView.IsRefreshingProperty, "IsRefreshing"); | ||
|
||
Add(refreshColorContainer); | ||
} | ||
|
||
ScrollView CreateContent() | ||
{ | ||
var scrollView = new ScrollView | ||
{ | ||
BackgroundColor = Color.Green, | ||
HeightRequest = 250 | ||
}; | ||
|
||
var content = new Grid(); | ||
|
||
var refreshLabel = new Label | ||
{ | ||
HorizontalOptions = LayoutOptions.Center, | ||
VerticalOptions = LayoutOptions.Center, | ||
TextColor = Color.White | ||
}; | ||
|
||
refreshLabel.SetBinding(Label.TextProperty, "Info"); | ||
content.Children.Add(refreshLabel); | ||
scrollView.Content = content; | ||
|
||
return scrollView; | ||
} | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class RefreshCoreGalleryViewModel : BindableObject | ||
{ | ||
const int RefreshDuration = 1; | ||
|
||
private bool _isRefresing; | ||
private string _info; | ||
|
||
public RefreshCoreGalleryViewModel() | ||
{ | ||
Info = "RefreshView (Pull To Refresh)"; | ||
} | ||
|
||
public bool IsRefreshing | ||
{ | ||
get { return _isRefresing; } | ||
set | ||
{ | ||
_isRefresing = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public string Info | ||
{ | ||
get { return _info; } | ||
set | ||
{ | ||
_info = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public ICommand RefreshCommand => new Command(ExecuteRefresh); | ||
|
||
private void ExecuteRefresh() | ||
{ | ||
IsRefreshing = true; | ||
|
||
Device.StartTimer(TimeSpan.FromSeconds(RefreshDuration), () => | ||
{ | ||
IsRefreshing = false; | ||
Info = "Refreshed (Pull To Refresh again)"; | ||
return false; | ||
}); | ||
} | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
Xamarin.Forms.Controls/GalleryPages/RefreshViewGalleries/RefreshCollectionViewGallery.xaml
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,36 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ContentPage | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Xamarin.Forms.Controls.GalleryPages.RefreshViewGalleries.RefreshCollectionViewGallery" | ||
Title="CollectionView (Pull To Refresh)"> | ||
<ContentPage.Content> | ||
<RefreshView | ||
IsRefreshing="{Binding IsRefreshing}" | ||
RefreshColor="Pink" | ||
Command="{Binding RefreshCommand}" | ||
HorizontalOptions="FillAndExpand" | ||
VerticalOptions="FillAndExpand"> | ||
<CollectionView | ||
ItemsSource="{Binding Items}"> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="48" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<BoxView | ||
Grid.Column="0" | ||
Color="{Binding Color}" | ||
HeightRequest="48"/> | ||
<Label | ||
Grid.Column="1" | ||
Text="{Binding Name}"/> | ||
</Grid> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</RefreshView> | ||
</ContentPage.Content> | ||
</ContentPage> |
14 changes: 14 additions & 0 deletions
14
...rin.Forms.Controls/GalleryPages/RefreshViewGalleries/RefreshCollectionViewGallery.xaml.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,14 @@ | ||
using Xamarin.Forms.Internals; | ||
|
||
namespace Xamarin.Forms.Controls.GalleryPages.RefreshViewGalleries | ||
{ | ||
[Preserve(AllMembers = true)] | ||
public partial class RefreshCollectionViewGallery : ContentPage | ||
{ | ||
public RefreshCollectionViewGallery() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = new RefreshViewModel(); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
Xamarin.Forms.Controls/GalleryPages/RefreshViewGalleries/RefreshLayoutGallery.xaml
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,48 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ContentPage | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Xamarin.Forms.Controls.GalleryPages.RefreshViewGalleries.RefreshLayoutGallery" | ||
Title="Layout (Pull To Refresh)"> | ||
<ContentPage.Resources> | ||
<ResourceDictionary> | ||
|
||
<DataTemplate x:Key="RefreshItemTemplate"> | ||
<Grid | ||
HeightRequest="100" | ||
WidthRequest="100"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<BoxView | ||
Grid.Row="0" | ||
Color="{Binding Color}"/> | ||
<Label | ||
Grid.Row="1" | ||
Text="{Binding Name}"/> | ||
</Grid> | ||
</DataTemplate> | ||
|
||
</ResourceDictionary> | ||
</ContentPage.Resources> | ||
<ContentPage.Content> | ||
<RefreshView | ||
IsRefreshing="{Binding IsRefreshing}" | ||
RefreshColor="Red" | ||
Command="{Binding RefreshCommand}" | ||
HorizontalOptions="FillAndExpand" | ||
VerticalOptions="FillAndExpand"> | ||
<StackLayout | ||
Padding="6"> | ||
<Label | ||
FontSize="Medium" | ||
FontAttributes="Bold" | ||
Text="The Content of a RefreshView must be a scrollable control, such as ScrollView, CollectionView, ListView, etc."/> | ||
<Label | ||
FontSize="Small" | ||
Text="Setting the Content to a control like Grid will result in undefined behavior."/> | ||
</StackLayout> | ||
</RefreshView> | ||
</ContentPage.Content> | ||
</ContentPage> |
14 changes: 14 additions & 0 deletions
14
Xamarin.Forms.Controls/GalleryPages/RefreshViewGalleries/RefreshLayoutGallery.xaml.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,14 @@ | ||
using Xamarin.Forms.Internals; | ||
|
||
namespace Xamarin.Forms.Controls.GalleryPages.RefreshViewGalleries | ||
{ | ||
[Preserve(AllMembers = true)] | ||
public partial class RefreshLayoutGallery : ContentPage | ||
{ | ||
public RefreshLayoutGallery() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = new RefreshViewModel(); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
Xamarin.Forms.Controls/GalleryPages/RefreshViewGalleries/RefreshListViewGallery.xaml
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,48 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ContentPage | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Xamarin.Forms.Controls.GalleryPages.RefreshViewGalleries.RefreshListViewGallery" | ||
Title="ListView (Pull To Refresh)"> | ||
<ContentPage.Content> | ||
<StackLayout> | ||
<Button | ||
Text="Trigger Refresh" | ||
Command="{Binding RefreshCommand}"/> | ||
<RefreshView | ||
IsRefreshing="{Binding IsRefreshing}" | ||
BackgroundColor="Red" | ||
RefreshColor="Yellow" | ||
Command="{Binding RefreshCommand}" | ||
HorizontalOptions="FillAndExpand" | ||
VerticalOptions="FillAndExpand"> | ||
<ListView | ||
ItemsSource="{Binding Items}" | ||
Header = "Header" | ||
Footer = "Footer" | ||
HasUnevenRows="True" | ||
SeparatorVisibility="None"> | ||
<ListView.ItemTemplate> | ||
<DataTemplate> | ||
<ViewCell> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="48" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<BoxView | ||
Grid.Column="0" | ||
Color="{Binding Color}" | ||
HeightRequest="48"/> | ||
<Label | ||
Grid.Column="1" | ||
Text="{Binding Name}"/> | ||
</Grid> | ||
</ViewCell> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
</ListView> | ||
</RefreshView> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</ContentPage> |
14 changes: 14 additions & 0 deletions
14
Xamarin.Forms.Controls/GalleryPages/RefreshViewGalleries/RefreshListViewGallery.xaml.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,14 @@ | ||
using Xamarin.Forms.Internals; | ||
|
||
namespace Xamarin.Forms.Controls.GalleryPages.RefreshViewGalleries | ||
{ | ||
[Preserve(AllMembers = true)] | ||
public partial class RefreshListViewGallery : ContentPage | ||
{ | ||
public RefreshListViewGallery() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = new RefreshViewModel(); | ||
} | ||
} | ||
} |
Oops, something went wrong.