Skip to content

Commit

Permalink
Wrong initial ActionView Layout using Drag SwipeTransitionMode (xamar…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz committed Oct 19, 2021
1 parent 94be14a commit 7dd033f
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="utf-8" ?>
<local:TestContentPage
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"
Title="Test 13495" xmlns:local="using:Xamarin.Forms.Controls"
x:Class="Xamarin.Forms.Controls.Issues.Issue13495"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core">
<StackLayout>
<Label
Padding="12"
BackgroundColor="Black"
TextColor="White"
Text="Swipe any SwipeView several times, without a SwipeItem glitch when pulled out (using Drag SwipeTransitionMode), the test has passed."/>
<Label
Text="Left Items"/>
<CollectionView
HeightRequest="100"
ItemSizingStrategy="MeasureFirstItem">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Item 1</x:String>
<x:String>Item 2</x:String>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<SwipeView
ios:SwipeView.SwipeTransitionMode="Drag">
<SwipeView.LeftItems>
<SwipeItems
SwipeBehaviorOnInvoked="RemainOpen">
<SwipeItem
Text="Delete"
BackgroundColor="Red"/>
</SwipeItems>
</SwipeView.LeftItems>
<Grid>
<Frame
HorizontalOptions="Start"
BackgroundColor="LightGray"
CornerRadius="12"
Padding="6"
HasShadow="False"
Margin="6"
Opacity="0.75">
<Label
Text="{Binding .}"/>
</Frame>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Label
Text="Top Items"/>
<CollectionView
HeightRequest="100"
ItemSizingStrategy="MeasureFirstItem">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Item 1</x:String>
<x:String>Item 2</x:String>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<SwipeView
ios:SwipeView.SwipeTransitionMode="Drag">
<SwipeView.TopItems>
<SwipeItems
SwipeBehaviorOnInvoked="RemainOpen">
<SwipeItem
Text="Delete"
BackgroundColor="Red"/>
</SwipeItems>
</SwipeView.TopItems>
<Grid>
<Frame
BackgroundColor="LightGray"
CornerRadius="12"
Padding="6"
HasShadow="False"
Margin="6"
Opacity="0.75">
<Label
Text="{Binding .}"/>
</Frame>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Label
Text="Right Items"/>
<CollectionView
HeightRequest="100"
ItemSizingStrategy="MeasureFirstItem">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Item 1</x:String>
<x:String>Item 2</x:String>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<SwipeView
ios:SwipeView.SwipeTransitionMode="Drag">
<SwipeView.RightItems>
<SwipeItems
SwipeBehaviorOnInvoked="RemainOpen">
<SwipeItem
Text="Delete"
BackgroundColor="Red"/>
</SwipeItems>
</SwipeView.RightItems>
<Grid>
<Frame
HorizontalOptions="End"
BackgroundColor="LightGray"
CornerRadius="12"
Padding="6"
HasShadow="False"
Margin="6"
Opacity="0.75">
<Label
Text="{Binding .}"/>
</Frame>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Label
Text="Bottom Items"/>
<CollectionView
HeightRequest="100"
ItemSizingStrategy="MeasureFirstItem">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Item 1</x:String>
<x:String>Item 2</x:String>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<SwipeView
ios:SwipeView.SwipeTransitionMode="Drag">
<SwipeView.BottomItems>
<SwipeItems
SwipeBehaviorOnInvoked="RemainOpen">
<SwipeItem
Text="Delete"
BackgroundColor="Red"/>
</SwipeItems>
</SwipeView.BottomItems>
<Grid>
<Frame
BackgroundColor="LightGray"
CornerRadius="12"
Padding="6"
HasShadow="False"
Margin="6"
Opacity="0.75">
<Label
Text="{Binding .}"/>
</Frame>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</local:TestContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Xamarin.Forms.CustomAttributes;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Issue(IssueTracker.Github, 13495,
"[Bug] Regression in XF5: SwipeView glitches when pulled out",
PlatformAffected.iOS)]
public partial class Issue13495 : TestContentPage
{
public Issue13495()
{
#if APP
InitializeComponent();
#endif
}

protected override void Init()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ShellFlyoutHeaderBehavior.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue8701.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13390.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13495.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13616.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13670.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13684.xaml.cs" />
Expand Down Expand Up @@ -2231,6 +2232,9 @@
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue13436.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue13495.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue13315.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Expand Down
24 changes: 22 additions & 2 deletions Xamarin.Forms.Platform.iOS/Renderers/SwipeViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,30 @@ void UpdateSwipeItems()

_actionView = new UIStackView
{
Axis = UILayoutConstraintAxis.Horizontal,
Frame = new CGRect(0, 0, swipeItemsWidth, _contentView.Frame.Height)
Axis = UILayoutConstraintAxis.Horizontal
};

if (_swipeTransitionMode == SwipeTransitionMode.Reveal)
_actionView.Frame = new CGRect(0, 0, swipeItemsWidth, _contentView.Frame.Height);
else
{
switch (_swipeDirection)
{
case SwipeDirection.Left:
_actionView.Frame = new CGRect(swipeItemsWidth, 0, swipeItemsWidth, _contentView.Frame.Height);
break;
case SwipeDirection.Right:
_actionView.Frame = new CGRect(-swipeItemsWidth, 0, swipeItemsWidth, _contentView.Frame.Height);
break;
case SwipeDirection.Up:
_actionView.Frame = new CGRect(0, _contentView.Frame.Height, swipeItemsWidth, _contentView.Frame.Height);
break;
case SwipeDirection.Down:
_actionView.Frame = new CGRect(0, -_contentView.Frame.Height, swipeItemsWidth, _contentView.Frame.Height);
break;
}
}

foreach (var item in items)
{
UIView swipeItem = null;
Expand Down

0 comments on commit 7dd033f

Please sign in to comment.