Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Fixed issue with SwipeView and grouped ListView with scroll (#11055)
Browse files Browse the repository at this point in the history
Co-authored-by: Samantha Houts <samhouts@users.noreply.github.com>
fixes #10908
  • Loading branch information
jsuarezruiz committed Jul 2, 2020
1 parent dcc1117 commit c68071a
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 1 deletion.
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.Issues.Issue10908"
Title="Issue 10908">
<ContentPage.Content>
<ListView
x:Name ="lstView"
IsGroupingEnabled="true"
HasUnevenRows="True"
SeparatorVisibility="None"
GroupDisplayBinding="{Binding LongName}"
GroupShortNameBinding="{Binding ShortName}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItem
BackgroundColor="Red"
IconImageSource="icon.png"
Text="Delete"/>
</SwipeView.LeftItems>
<StackLayout
HeightRequest="60">
<Label Text="{Binding Name}" />
<Label Text="{Binding Comment}" />
</StackLayout>
</SwipeView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System.Collections.ObjectModel;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 10908, "[Bug] [iOS]SwipeView not working on Grouped ListView", PlatformAffected.iOS)]
public partial class Issue10908 : ContentPage
{
public Issue10908()
{
#if APP
InitializeComponent ();

Grouped = new ObservableCollection<GroupedIssue10908Model>();

var veggieGroup = new GroupedIssue10908Model() { LongName = "vegetables", ShortName = "v" };
var fruitGroup = new GroupedIssue10908Model() { LongName = "fruit", ShortName = "f" };
var veggie1Group = new GroupedIssue10908Model() { LongName = "vegetables1", ShortName = "v1" };
var fruit1Group = new GroupedIssue10908Model() { LongName = "fruit1", ShortName = "f1" };
var veggie2Group = new GroupedIssue10908Model() { LongName = "vegetables2", ShortName = "v2" };
var fruit2Group = new GroupedIssue10908Model() { LongName = "fruit2", ShortName = "f2" };
veggieGroup.Add(new Issue10908Model() { Name = "celery", IsReallyAVeggie = true, Comment = "try ants on a log" });
veggieGroup.Add(new Issue10908Model() { Name = "tomato", IsReallyAVeggie = false, Comment = "pairs well with basil" });
veggieGroup.Add(new Issue10908Model() { Name = "zucchini", IsReallyAVeggie = true, Comment = "zucchini bread > bannana bread" });
veggieGroup.Add(new Issue10908Model() { Name = "peas", IsReallyAVeggie = true, Comment = "like peas in a pod" });
fruitGroup.Add(new Issue10908Model() { Name = "banana", IsReallyAVeggie = false, Comment = "available in chip form factor" });
fruitGroup.Add(new Issue10908Model() { Name = "strawberry", IsReallyAVeggie = false, Comment = "spring plant" });
fruitGroup.Add(new Issue10908Model() { Name = "cherry", IsReallyAVeggie = false, Comment = "topper for icecream" });

veggie1Group.Add(new Issue10908Model() { Name = "celery", IsReallyAVeggie = true, Comment = "try ants on a log" });
veggie1Group.Add(new Issue10908Model() { Name = "tomato", IsReallyAVeggie = false, Comment = "pairs well with basil" });
veggie1Group.Add(new Issue10908Model() { Name = "zucchini", IsReallyAVeggie = true, Comment = "zucchini bread > bannana bread" });
veggie1Group.Add(new Issue10908Model() { Name = "peas", IsReallyAVeggie = true, Comment = "like peas in a pod" });
fruit1Group.Add(new Issue10908Model() { Name = "banana", IsReallyAVeggie = false, Comment = "available in chip form factor" });
fruit1Group.Add(new Issue10908Model() { Name = "strawberry", IsReallyAVeggie = false, Comment = "spring plant" });
fruit1Group.Add(new Issue10908Model() { Name = "cherry", IsReallyAVeggie = false, Comment = "topper for icecream" });

veggie2Group.Add(new Issue10908Model() { Name = "celery", IsReallyAVeggie = true, Comment = "try ants on a log" });
veggie2Group.Add(new Issue10908Model() { Name = "tomato", IsReallyAVeggie = false, Comment = "pairs well with basil" });
veggie2Group.Add(new Issue10908Model() { Name = "zucchini", IsReallyAVeggie = true, Comment = "zucchini bread > bannana bread" });
veggie2Group.Add(new Issue10908Model() { Name = "peas", IsReallyAVeggie = true, Comment = "like peas in a pod" });
fruit2Group.Add(new Issue10908Model() { Name = "banana", IsReallyAVeggie = false, Comment = "available in chip form factor" });
fruit2Group.Add(new Issue10908Model() { Name = "strawberry", IsReallyAVeggie = false, Comment = "spring plant" });
fruit2Group.Add(new Issue10908Model() { Name = "cherry", IsReallyAVeggie = false, Comment = "topper for icecream" });

Grouped.Add(veggieGroup);
Grouped.Add(fruitGroup);
Grouped.Add(veggie1Group);
Grouped.Add(fruit1Group);
Grouped.Add(veggie2Group);
Grouped.Add(fruit2Group);

lstView.ItemsSource = Grouped;
#endif
}

ObservableCollection<GroupedIssue10908Model> Grouped { get; set; }
}

[Preserve(AllMembers = true)]
public class Issue10908Model
{
public string Name { get; set; }
public string Comment { get; set; }
public bool IsReallyAVeggie { get; set; }
public string Image { get; set; }
}

[Preserve(AllMembers = true)]
public class GroupedIssue10908Model : ObservableCollection<Issue10908Model>
{
public string LongName { get; set; }
public string ShortName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue11031.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue10940.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue10908.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11132.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11113.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue10182.cs" />
Expand Down Expand Up @@ -1666,6 +1667,9 @@
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue9555.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue10908.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11113.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Platform.iOS/Renderers/SwipeViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void HandlePan(UIPanGestureRecognizer panGestureRecognizer)
{
if (panGestureRecognizer != null)
{
var point = panGestureRecognizer.LocationInView(Control);
CGPoint point = panGestureRecognizer.LocationInView(this);
var navigationController = GetUINavigationController(GetViewController());

switch (panGestureRecognizer.State)
Expand Down

0 comments on commit c68071a

Please sign in to comment.