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
Binary file not shown.
27 changes: 25 additions & 2 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29086.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<SwipeItemView>
<Button
Text="+"
AutomationId="AddButton"
AutomationId="{Binding Value, StringFormat='AddButton{0}'}"
WidthRequest="40"
BackgroundColor="LightGreen"
Command="{Binding Source={x:Reference Self}, Path=IncrementCommand}"
Expand All @@ -32,9 +32,32 @@
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
<SwipeView.RightItems>
<SwipeItems
Mode="Reveal"
SwipeBehaviorOnInvoked="RemainOpen">
<SwipeItemView>
<Button
Text="+"
AutomationId="{Binding Value, StringFormat='AddButtonRight{0}'}"
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.RightItems>

<Grid Padding="10"
AutomationId="SwipeItem"
AutomationId="{Binding Value, StringFormat='SwipeItem{0}'}"
BackgroundColor="LightBlue">
<Label Text="{Binding Value}"
FontSize="18"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public Issue29086()
Numbers = new ObservableCollection<NumberItem>
{
new NumberItem { Value = 1 },
new NumberItem { Value = 2 },
};

IncrementCommand = new Command<NumberItem>((item) => item.Value++);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public Issue29086(TestDevice testDevice) : base(testDevice)
[Category(UITestCategories.SwipeView)]
public void SwipeViewShouldNotClose()
{
App.WaitForElement("SwipeItem");
App.SwipeLeftToRight("SwipeItem");
App.WaitForElement("AddButton");
App.Click("AddButton");
App.WaitForElement("AddButton");
App.Click("AddButton");
VerifyScreenshot();
App.WaitForElement("SwipeItem1");
App.SwipeLeftToRight("SwipeItem1");
App.SwipeRightToLeft("SwipeItem2");
App.WaitForElement("AddButton1");
App.WaitForElement("AddButtonRight2");
App.Click("AddButton1");
App.Click("AddButtonRight2");
App.WaitForNoElement("AddButton1");
App.WaitForNoElement("AddButtonRight2");
}
}
#endif
11 changes: 6 additions & 5 deletions src/Core/src/Platform/iOS/MauiSwipeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -801,20 +801,21 @@ void SwipeToThreshold(bool animated = true)
Animate(completeAnimationDuration, 0.0, UIViewAnimationOptions.CurveEaseIn,
() =>
{
_swipeOffset = GetSwipeThreshold();
_swipeOffset = Math.Abs(GetSwipeThreshold());

// If the user swiped left or up, we need a negative offset to move content in the correct direction on the screen.
if (_swipeDirection == SwipeDirection.Left || _swipeDirection == SwipeDirection.Up)
_swipeOffset = -_swipeOffset;

double swipeThreshold = _swipeOffset;

switch (_swipeDirection)
{
case SwipeDirection.Left:
_contentView.Frame = new CGRect(_originalBounds.X - swipeThreshold, _originalBounds.Y, _originalBounds.Width, _originalBounds.Height);
break;
case SwipeDirection.Right:
_contentView.Frame = new CGRect(_originalBounds.X + swipeThreshold, _originalBounds.Y, _originalBounds.Width, _originalBounds.Height);
break;
case SwipeDirection.Up:
_contentView.Frame = new CGRect(_originalBounds.X, _originalBounds.Y - swipeThreshold, _originalBounds.Width, _originalBounds.Height);
break;
case SwipeDirection.Down:
_contentView.Frame = new CGRect(_originalBounds.X, _originalBounds.Y + swipeThreshold, _originalBounds.Width, _originalBounds.Height);
break;
Expand Down