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

Commit 57aefa6

Browse files
committed
Merge branch '4.7.0' into 4.8.0
2 parents bc51d24 + 9355d6b commit 57aefa6

File tree

11 files changed

+325
-12
lines changed

11 files changed

+325
-12
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Android.Util;
2+
using Xamarin.Forms;
3+
using Xamarin.Forms.Internals;
4+
using Xamarin.Forms.Platform.Android;
5+
using AView = Android.Views.View;
6+
7+
[assembly: ExportEffect(typeof(Xamarin.Forms.ControlGallery.Android.RippleEffect), nameof(Xamarin.Forms.ControlGallery.Android.RippleEffect))]
8+
namespace Xamarin.Forms.ControlGallery.Android
9+
{
10+
[Preserve(AllMembers = true)]
11+
public class RippleEffect : PlatformEffect
12+
{
13+
protected override void OnAttached()
14+
{
15+
try
16+
{
17+
if (Container is AView view)
18+
{
19+
view.Clickable = true;
20+
view.Focusable = true;
21+
22+
using (var outValue = new TypedValue())
23+
{
24+
view.Context.Theme.ResolveAttribute(Resource.Attribute.selectableItemBackground, outValue, true);
25+
view.SetBackgroundResource(outValue.ResourceId);
26+
}
27+
}
28+
}
29+
catch
30+
{
31+
32+
}
33+
}
34+
35+
protected override void OnDetached()
36+
{
37+
38+
}
39+
}
40+
}

Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
<Compile Include="Issue7249SwitchRenderer.cs" />
138138
<Compile Include="_9087CustomRenderer.cs" />
139139
<Compile Include="_10940CustomRenderer.cs" />
140+
<Compile Include="RippleEffect.cs" />
140141
</ItemGroup>
141142
<ItemGroup>
142143
<AndroidAsset Include="Assets\default.css" />
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<local:TestContentPage xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="using:Xamarin.Forms.Controls"
7+
xmlns:effects="clr-namespace:Xamarin.Forms.Controls.Issues"
8+
mc:Ignorable="d"
9+
Title="Test 11374"
10+
x:Class="Xamarin.Forms.Controls.Issues.Issue11374">
11+
<Grid>
12+
<Grid.RowDefinitions>
13+
<RowDefinition Height="Auto" />
14+
<RowDefinition Height="*" />
15+
</Grid.RowDefinitions>
16+
<Label
17+
Padding="12"
18+
BackgroundColor="Black"
19+
TextColor="White"
20+
Text="Swipe an Item to the right or left. If you can open the SwipeView, the test has passed."/>
21+
<ListView
22+
x:Name="ItemsListView"
23+
Grid.Row="1"
24+
ItemsSource="{Binding Items}"
25+
VerticalOptions="FillAndExpand"
26+
HasUnevenRows="true"
27+
SelectionMode="Single"
28+
SeparatorVisibility="None"
29+
CachingStrategy="RecycleElementAndDataTemplate">
30+
<ListView.ItemTemplate>
31+
<DataTemplate>
32+
<ViewCell Height="64">
33+
<SwipeView>
34+
<SwipeView.LeftItems>
35+
<SwipeItems
36+
SwipeBehaviorOnInvoked="Close">
37+
<SwipeItemView>
38+
<Label
39+
Text="Left Swipe"
40+
Padding="25,0,25,0"
41+
VerticalOptions="FillAndExpand"
42+
VerticalTextAlignment="Center">
43+
</Label>
44+
</SwipeItemView>
45+
</SwipeItems>
46+
</SwipeView.LeftItems>
47+
<SwipeView.RightItems>
48+
<SwipeItems SwipeBehaviorOnInvoked="Close">
49+
<SwipeItemView>
50+
<Label
51+
Text="Right Swipe"
52+
Padding="25,0,25,0"
53+
VerticalOptions="FillAndExpand"
54+
VerticalTextAlignment="Center">
55+
</Label>
56+
</SwipeItemView>
57+
</SwipeItems>
58+
</SwipeView.RightItems>
59+
<ContentView
60+
BackgroundColor="White">
61+
<Grid>
62+
<Grid.ColumnDefinitions>
63+
<ColumnDefinition Width="*" />
64+
</Grid.ColumnDefinitions>
65+
<Grid.Effects>
66+
<effects:RippleEffect />
67+
</Grid.Effects>
68+
<StackLayout Padding="10">
69+
<Label
70+
Text="{Binding .}"
71+
d:Text="{Binding .}"
72+
LineBreakMode="NoWrap"
73+
FontSize="16" />
74+
</StackLayout>
75+
</Grid>
76+
</ContentView>
77+
</SwipeView>
78+
</ViewCell>
79+
</DataTemplate>
80+
</ListView.ItemTemplate>
81+
</ListView>
82+
</Grid>
83+
</local:TestContentPage>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using Xamarin.Forms.CustomAttributes;
5+
using Xamarin.Forms.Internals;
6+
7+
#if UITEST
8+
using Xamarin.UITest;
9+
using NUnit.Framework;
10+
using Xamarin.Forms.Core.UITests;
11+
#endif
12+
13+
namespace Xamarin.Forms.Controls.Issues
14+
{
15+
[Preserve(AllMembers = true)]
16+
[Issue(IssueTracker.Github, 11374,
17+
"[Bug] [Android] SwipeView in ListView is not working with RippleEffect and Release configuration",
18+
PlatformAffected.Android)]
19+
public partial class Issue11374 : TestContentPage
20+
{
21+
public Issue11374()
22+
{
23+
#if APP
24+
Device.SetFlags(new List<string> { ExperimentalFlags.SwipeViewExperimental });
25+
26+
InitializeComponent();
27+
#endif
28+
}
29+
30+
protected override void Init()
31+
{
32+
BindingContext = new Issue11374ViewModel();
33+
}
34+
}
35+
36+
[Preserve(AllMembers = true)]
37+
public class Issue11374ViewModel : BindableObject
38+
{
39+
public ObservableCollection<string> Items { get; set; }
40+
41+
public Command LoadItemsCommand { get; set; }
42+
43+
public Issue11374ViewModel()
44+
{
45+
LoadItems();
46+
}
47+
48+
void LoadItems()
49+
{
50+
Items = new ObservableCollection<string>
51+
{
52+
"Item 1",
53+
"Item 2",
54+
"Item 3",
55+
"Item 4",
56+
"Item 5"
57+
};
58+
}
59+
}
60+
61+
[Preserve(AllMembers = true)]
62+
public class RippleEffect : RoutingEffect
63+
{
64+
public RippleEffect() : base($"{Effects.ResolutionGroupName}.{nameof(RippleEffect)}")
65+
{
66+
67+
}
68+
}
69+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Xamarin.Forms.CustomAttributes;
2+
using Xamarin.Forms.Internals;
3+
4+
#if UITEST
5+
using Xamarin.UITest;
6+
using NUnit.Framework;
7+
using Xamarin.Forms.Core.UITests;
8+
#endif
9+
10+
namespace Xamarin.Forms.Controls.Issues
11+
{
12+
#if UITEST
13+
[Category(UITestCategories.Frame)]
14+
#endif
15+
[Preserve(AllMembers = true)]
16+
[Issue(IssueTracker.Github, 11430,
17+
"[Bug] [iOS] Button stays in Pressed state if the touch-up event occurs outside",
18+
PlatformAffected.iOS)]
19+
public class Issue11430 : TestContentPage
20+
{
21+
public Issue11430()
22+
{
23+
}
24+
25+
protected override void Init()
26+
{
27+
Title = "Issue 11430";
28+
29+
var layout = new StackLayout();
30+
31+
var instructions = new Label
32+
{
33+
Padding = 12,
34+
BackgroundColor = Color.Black,
35+
TextColor = Color.White,
36+
Text = "Tap a Button, drag your finger outside the Button and lift up your finger. If the Button state is Normal, the test has passed."
37+
};
38+
39+
var button = new Button
40+
{
41+
Text = "Click Me"
42+
};
43+
44+
layout.Children.Add(instructions);
45+
layout.Children.Add(button);
46+
47+
Content = layout;
48+
49+
button.Clicked += (sender, args) =>
50+
{
51+
DisplayAlert("Issue 11430", "Button Clicked.", "Ok");
52+
};
53+
}
54+
}
55+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Xamarin.Forms.Internals;
5+
using Xamarin.Forms.CustomAttributes;
6+
using System.ComponentModel;
7+
using System.Threading.Tasks;
8+
9+
namespace Xamarin.Forms.Controls.Issues
10+
{
11+
[Issue(IssueTracker.Github, 9451,
12+
"[Bug] RelativeLayout Constraint can not go back to zero", PlatformAffected.All)]
13+
public class Issue9451 : TestContentPage
14+
{
15+
public StackLayout StackLayout { get; set; }
16+
public Button TriggerButton { get; set; }
17+
18+
protected override void Init()
19+
{
20+
var relativeLayout = new RelativeLayout() { WidthRequest = 400, HeightRequest = 400 };
21+
StackLayout = new StackLayout() { BackgroundColor = Color.Red };
22+
23+
TriggerButton = new Button() { Text = "Set View Width To Zero" };
24+
25+
StackLayout.Children.Add(TriggerButton);
26+
27+
relativeLayout.Children.Add(StackLayout,
28+
Xamarin.Forms.Constraint.Constant(0),
29+
Xamarin.Forms.Constraint.Constant(0),
30+
Xamarin.Forms.Constraint.RelativeToParent(x => x.Width / 2),
31+
Xamarin.Forms.Constraint.RelativeToParent(y => y.Height));
32+
33+
Content = relativeLayout;
34+
}
35+
36+
protected override void OnAppearing()
37+
{
38+
base.OnAppearing();
39+
40+
TriggerButton.Clicked += Button_Clicked;
41+
}
42+
43+
protected override void OnDisappearing()
44+
{
45+
base.OnDisappearing();
46+
47+
TriggerButton.Clicked -= Button_Clicked;
48+
}
49+
50+
private void Button_Clicked(object sender, EventArgs e)
51+
{
52+
RelativeLayout.SetWidthConstraint(StackLayout, Xamarin.Forms.Constraint.Constant(0.0));
53+
}
54+
}
55+
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,9 @@
14641464
<Compile Include="$(MSBuildThisFileDirectory)Issue11272.cs" />
14651465
<Compile Include="$(MSBuildThisFileDirectory)Issue11563.cs" />
14661466
<Compile Include="$(MSBuildThisFileDirectory)Issue11547.xaml.cs" />
1467+
<Compile Include="$(MSBuildThisFileDirectory)Issue9451.cs" />
1468+
<Compile Include="$(MSBuildThisFileDirectory)Issue11374.xaml.cs" />
1469+
<Compile Include="$(MSBuildThisFileDirectory)Issue11430.cs" />
14671470
<Compile Include="$(MSBuildThisFileDirectory)Issue11247.cs" />
14681471
</ItemGroup>
14691472
<ItemGroup>
@@ -1725,6 +1728,9 @@
17251728
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11224.xaml">
17261729
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
17271730
</EmbeddedResource>
1731+
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11374.xaml">
1732+
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
1733+
</EmbeddedResource>
17281734
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11262.xaml">
17291735
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
17301736
</EmbeddedResource>

Xamarin.Forms.Platform.Android/Renderers/SwipeViewRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ bool ShouldInterceptTouch(MotionEvent e)
290290

291291
public override bool OnInterceptTouchEvent(MotionEvent e)
292292
{
293-
return false;
293+
return ShouldInterceptTouch(e);
294294
}
295295

296296
public override bool DispatchTouchEvent(MotionEvent e)

Xamarin.Forms.Platform.UAP/FormsTextBox.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public class FormsTextBox : TextBox
4747

4848
InputScope _passwordInputScope;
4949
InputScope _numericPasswordInputScope;
50-
Border _borderElement;
51-
Windows.UI.Xaml.Controls.ScrollViewer _scrollViewer;
50+
ScrollViewer _scrollViewer;
5251
Windows.UI.Xaml.Controls.Grid _rootGrid;
5352
Windows.UI.Xaml.VisualState _DeleteButtonVisibleState;
5453
Windows.UI.Xaml.VisualStateGroup _DeleteButtonVisibleStateGroups;
@@ -157,14 +156,7 @@ protected override void OnApplyTemplate()
157156
{
158157
base.OnApplyTemplate();
159158

160-
if (Device.Idiom == TargetIdiom.Phone)
161-
{
162-
// If we're on the phone, we need to grab this from the template
163-
// so we can manually handle its background when focused
164-
_borderElement = (Border)GetTemplateChild("BorderElement");
165-
}
166-
167-
_rootGrid = (Windows.UI.Xaml.Controls.Grid)GetTemplateChild("RootGrid");
159+
_rootGrid = GetTemplateChild("RootGrid") as Windows.UI.Xaml.Controls.Grid;
168160
if (_rootGrid != null)
169161
{
170162
var stateGroups = WVisualStateManager.GetVisualStateGroups(_rootGrid).ToList();
@@ -173,7 +165,7 @@ protected override void OnApplyTemplate()
173165
_DeleteButtonVisibleState = _DeleteButtonVisibleStateGroups.States.SingleOrDefault(s => s.Name == "ButtonVisible");
174166
}
175167

176-
_scrollViewer= (Windows.UI.Xaml.Controls.ScrollViewer)GetTemplateChild("ContentElement");
168+
_scrollViewer= GetTemplateChild("ContentElement") as ScrollViewer;
177169
}
178170

179171
void OnSizeChanged(object sender, SizeChangedEventArgs e)

Xamarin.Forms.Platform.iOS/Renderers/ButtonElementManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,10 @@ internal static void OnButtonTouchUpInside(IButtonController element)
8585
element?.SendReleased();
8686
element?.SendClicked();
8787
}
88+
89+
internal static void OnButtonTouchUpOutside(IButtonController element)
90+
{
91+
element?.SendReleased();
92+
}
8893
}
8994
}

0 commit comments

Comments
 (0)