This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Fix incorrect refresh indicador position using RefreshView with…
… CollectionView Header (#13773) * Added repro sample * Fix the issue * Update issue description * Changes to use another approach to detect if the CollectionView has header or not
- Loading branch information
1 parent
7644b5b
commit 1d0578c
Showing
5 changed files
with
232 additions
and
10 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8282.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,62 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<controls:TestContentPage | ||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls" | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://xamarin.com/schemas/2014/forms/design" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue8282" | ||
Title="Issue 8282"> | ||
<Grid | ||
RowSpacing="0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<Label | ||
Padding="12" | ||
BackgroundColor="Black" | ||
TextColor="White" | ||
Text="Pull to Refresh. If the loading indicator appears above the CollectionView header, the test has passed. "/> | ||
<Grid | ||
Grid.Row="1"> | ||
<RefreshView | ||
BackgroundColor="Yellow" | ||
RefreshColor="Black" | ||
IsRefreshing="{Binding IsRefreshing}" | ||
Command="{Binding RefreshCommand}"> | ||
<CollectionView | ||
ItemsSource="{Binding Items}"> | ||
<CollectionView.Header> | ||
<Grid | ||
HeightRequest="200" | ||
BackgroundColor="#aadddddd"> | ||
<Label | ||
Text="Issue 8282" | ||
HorizontalOptions="Center" | ||
VerticalOptions="Center"/> | ||
</Grid> | ||
</CollectionView.Header> | ||
<CollectionView.ItemsLayout> | ||
<LinearItemsLayout | ||
Orientation="Vertical" | ||
ItemSpacing="5"/> | ||
</CollectionView.ItemsLayout> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<Grid | ||
HeightRequest="100" | ||
BackgroundColor="Beige"> | ||
<Label | ||
Text="{Binding Position}" | ||
HorizontalTextAlignment="Center" | ||
VerticalTextAlignment="Center"/> | ||
</Grid> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</RefreshView> | ||
</Grid> | ||
</Grid> | ||
</controls:TestContentPage> |
123 changes: 123 additions & 0 deletions
123
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8282.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,123 @@ | ||
using System.Collections.ObjectModel; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
using Xamarin.Forms.Xaml; | ||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using Xamarin.UITest.Queries; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
#if UITEST | ||
[NUnit.Framework.Category(UITestCategories.RefreshView)] | ||
#endif | ||
#if APP | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
#endif | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 8282, "[Bug] [iOS] RefreshView draws behind CollectionView Header", PlatformAffected.iOS)] | ||
public partial class Issue8282 : TestContentPage | ||
{ | ||
public Issue8282() | ||
{ | ||
#if APP | ||
Title = "Issue 8282"; | ||
InitializeComponent(); | ||
BindingContext = new Issue8282ViewModel(); | ||
#endif | ||
} | ||
|
||
protected override void Init() | ||
{ | ||
|
||
} | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class Issue8282Model : INotifyPropertyChanged | ||
{ | ||
private int _position; | ||
|
||
public int Position | ||
{ | ||
get | ||
{ | ||
return _position; | ||
} | ||
set | ||
{ | ||
_position = value; | ||
|
||
OnPropertyChanged("Position"); | ||
} | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected void OnPropertyChanged(string name) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); | ||
} | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class Issue8282ViewModel : INotifyPropertyChanged | ||
{ | ||
bool _isRefreshing; | ||
|
||
public Issue8282ViewModel() | ||
{ | ||
PopulateItems(); | ||
|
||
RefreshCommand = new Command(async () => | ||
{ | ||
IsRefreshing = true; | ||
await Task.Delay(2000); | ||
PopulateItems(); | ||
IsRefreshing = false; | ||
}); | ||
} | ||
|
||
public ObservableCollection<Issue8282Model> Items { get; set; } = new ObservableCollection<Issue8282Model>(); | ||
|
||
public bool IsRefreshing | ||
{ | ||
get | ||
{ | ||
return _isRefreshing; | ||
} | ||
set | ||
{ | ||
_isRefreshing = value; | ||
|
||
OnPropertyChanged("IsRefreshing"); | ||
} | ||
} | ||
|
||
|
||
public Command RefreshCommand { get; set; } | ||
|
||
void PopulateItems() | ||
{ | ||
var count = Items.Count; | ||
|
||
for (var i = count; i < count + 10; i++) | ||
Items.Add(new Issue8282Model() { Position = i }); | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected void OnPropertyChanged(string name) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); | ||
} | ||
} | ||
} |
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