Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29086.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Name="Self"
x:Class="Maui.Controls.Sample.Issues.Issue29086">
<CollectionView ItemsSource="{Binding Numbers}"
Margin="60">
<CollectionView.ItemTemplate>
<DataTemplate>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems
Mode="Reveal"
SwipeBehaviorOnInvoked="RemainOpen">
<SwipeItemView>
<Button
Text="+"
AutomationId="AddButton"
WidthRequest="40"
BackgroundColor="LightGreen"
Command="{Binding Source={x:Reference Self}, Path=IncrementCommand}"
CommandParameter="{Binding .}"/>
</SwipeItemView>
<SwipeItemView>
<Button
Text="-"
WidthRequest="40"
BackgroundColor="LightCoral"
Command="{Binding Source={x:Reference Self}, Path=DecrementCommand}"
CommandParameter="{Binding .}"/>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>

<Grid Padding="10"
AutomationId="SwipeItem"
BackgroundColor="LightBlue">
<Label Text="{Binding Value}"
FontSize="18"
HorizontalOptions="Center"/>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage>
37 changes: 37 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29086.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections.ObjectModel;
using System.Windows.Input;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 29086, "SwipeView Closes when Content Changes even with SwipeBehaviorOnInvoked='RemainOpen'", PlatformAffected.iOS)]
public partial class Issue29086 : ContentPage
{
public ObservableCollection<NumberItem> Numbers { get; set; }
public ICommand IncrementCommand { get; }
public ICommand DecrementCommand { get; }

public Issue29086()
{
InitializeComponent();

Numbers = new ObservableCollection<NumberItem>
{
new NumberItem { Value = 1 },
};

IncrementCommand = new Command<NumberItem>((item) => item.Value++);
DecrementCommand = new Command<NumberItem>((item) => item.Value--);

BindingContext = this;
}

public class NumberItem : ViewModelBase
{
int _value;
public int Value
{
get => _value;
set { _value = value; OnPropertyChanged(); }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue29086 : _IssuesUITest
{

public Issue29086(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "SwipeView Closes when Content Changes even with SwipeBehaviorOnInvoked='RemainOpen'";

[Test]
[Category(UITestCategories.SwipeView)]
public void SwipeViewShouldNotClose()
{
App.WaitForElement("SwipeItem");
App.SwipeLeftToRight("SwipeItem");
App.Click("AddButton");
App.Click("AddButton");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just trigger a build. Pending test snapshots in all the platforms.

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions src/Core/src/Platform/iOS/MauiSwipeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public override void LayoutSubviews()

if (_contentView != null && _contentView.Frame.IsEmpty)
_contentView.Frame = Bounds;

if (_isOpen)
{
Swipe(animated: false);
}
}

public override void TouchesEnded(NSSet touches, UIEvent? evt)
Expand Down Expand Up @@ -581,7 +586,7 @@ void Swipe(bool animated = false)

if (_swipeTransitionMode == SwipeTransitionMode.Reveal)
{
Animate(swipeAnimationDuration, 0.0, UIViewAnimationOptions.CurveEaseOut, () =>
void SetFrame()
{
switch (_swipeDirection)
{
Expand All @@ -598,7 +603,16 @@ void Swipe(bool animated = false)
_contentView.Frame = new CGRect(_originalBounds.X, _originalBounds.Y + offset, _originalBounds.Width, _originalBounds.Height);
break;
}
}, null);
}

if (animated)
{
Animate(swipeAnimationDuration, 0.0, UIViewAnimationOptions.CurveEaseOut, SetFrame, null);
}
else
{
SetFrame();
}
}

if (_swipeTransitionMode == SwipeTransitionMode.Drag)
Expand Down
Loading