forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Android SwipeView issue using a GestureRecognizer (xamarin#11340)
Co-authored-by: Samantha Houts <samhouts@users.noreply.github.com> fixes xamarin#11333
- Loading branch information
1 parent
907d1df
commit 12c001b
Showing
3 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue11333.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,76 @@ | ||
<?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 11333" | ||
xmlns:local="using:Xamarin.Forms.Controls" | ||
xmlns:issues="using:Xamarin.Forms.Controls.Issues" | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue11333"> | ||
<StackLayout Padding="0,8,0,0"> | ||
<Label | ||
Padding="12" | ||
Text="If can swipe to the left the test has passed." /> | ||
<!-- Place new controls here --> | ||
<Frame HasShadow="True" | ||
CornerRadius="0" Padding="0,20" > | ||
<StackLayout> | ||
<Label Text="TESTING" Padding="20,0" /> | ||
<Grid Padding="20,0"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Label Text="Name" | ||
Grid.Column="0" | ||
TextColor="LightGray"/> | ||
<Label Text="Description" | ||
TextColor="LightGray" | ||
Grid.Column="1"/> | ||
</Grid> | ||
<BoxView HeightRequest="1" Color="LightGray"/> | ||
<StackLayout> | ||
<BindableLayout.ItemsSource> | ||
<x:Array Type="{x:Type issues:Issue11333Model}"> | ||
<issues:Issue11333Model Title="Item 1" Description="Loren ipsum" /> | ||
<issues:Issue11333Model Title="Item 2" Description="Loren ipsum" /> | ||
<issues:Issue11333Model Title="Item 3" Description="Loren ipsum" /> | ||
<issues:Issue11333Model Title="Item 4" Description="Loren ipsum" /> | ||
<issues:Issue11333Model Title="Item 5" Description="Loren ipsum" /> | ||
</x:Array> | ||
</BindableLayout.ItemsSource> | ||
<BindableLayout.ItemTemplate> | ||
<DataTemplate x:DataType="issues:Issue11333Model"> | ||
<SwipeView | ||
AutomationId="SwipeViewId" | ||
SwipeEnded="OnSwipeViewSwipeEnded"> | ||
<SwipeView.RightItems> | ||
<SwipeItem Text="Item 1" BackgroundColor="CadetBlue" /> | ||
<SwipeItem Text="Item 2" BackgroundColor="CadetBlue" /> | ||
</SwipeView.RightItems> | ||
<Frame HasShadow="False" BackgroundColor="AliceBlue"> | ||
<Frame.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="OnTapGestureRecognizerOnTapped" /> | ||
</Frame.GestureRecognizers> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Label Text="{Binding Title}" Grid.Column="0" /> | ||
<Label Text="{Binding Description}" Grid.Column="1" /> | ||
</Grid> | ||
</Frame> | ||
</SwipeView> | ||
</DataTemplate> | ||
</BindableLayout.ItemTemplate> | ||
</StackLayout> | ||
<Label | ||
x:Name="ResultLabel" | ||
Text="Close"/> | ||
</StackLayout> | ||
</Frame> | ||
</StackLayout> | ||
</local:TestContentPage> |
66 changes: 66 additions & 0 deletions
66
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue11333.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,66 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 11333, | ||
"[Bug] SwipeView does not work on Android if child has TapGestureRecognizer", | ||
PlatformAffected.Android)] | ||
public partial class Issue11333 : TestContentPage | ||
{ | ||
const string SwipeViewId = "SwipeViewId"; | ||
|
||
public Issue11333() | ||
{ | ||
#if APP | ||
Device.SetFlags(new List<string> { ExperimentalFlags.SwipeViewExperimental }); | ||
InitializeComponent(); | ||
#endif | ||
} | ||
|
||
protected override void Init() | ||
{ | ||
} | ||
|
||
#if APP | ||
void OnTapGestureRecognizerOnTapped(object sender, EventArgs e) | ||
{ | ||
Debug.WriteLine("Tapped"); | ||
} | ||
|
||
void OnSwipeViewSwipeEnded(object sender, SwipeEndedEventArgs e) | ||
{ | ||
ResultLabel.Text = e.IsOpen ? "Open" : "Close"; | ||
} | ||
#endif | ||
|
||
#if UITEST | ||
[Test] | ||
[Category(UITestCategories.SwipeView)] | ||
public void SwipeWithChildGestureRecognizer() | ||
{ | ||
RunningApp.WaitForElement(SwipeViewId); | ||
RunningApp.SwipeRightToLeft(); | ||
RunningApp.Tap(SwipeViewId); | ||
RunningApp.WaitForElement(q => q.Marked("Open")); | ||
} | ||
#endif | ||
} | ||
|
||
[Preserve(AllMembers = true)] | ||
public class Issue11333Model | ||
{ | ||
public string Title { get; set; } | ||
public string Description { get; set; } | ||
} | ||
} |
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