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

Commit

Permalink
Merge branch '4.7.0' into 4.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
samhouts committed Jul 30, 2020
2 parents bc51d24 + 9355d6b commit 57aefa6
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 12 deletions.
40 changes: 40 additions & 0 deletions Xamarin.Forms.ControlGallery.Android/RippleEffect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Android.Util;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.Android;
using AView = Android.Views.View;

[assembly: ExportEffect(typeof(Xamarin.Forms.ControlGallery.Android.RippleEffect), nameof(Xamarin.Forms.ControlGallery.Android.RippleEffect))]
namespace Xamarin.Forms.ControlGallery.Android
{
[Preserve(AllMembers = true)]
public class RippleEffect : PlatformEffect
{
protected override void OnAttached()
{
try
{
if (Container is AView view)
{
view.Clickable = true;
view.Focusable = true;

using (var outValue = new TypedValue())
{
view.Context.Theme.ResolveAttribute(Resource.Attribute.selectableItemBackground, outValue, true);
view.SetBackgroundResource(outValue.ResourceId);
}
}
}
catch
{

}
}

protected override void OnDetached()
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
<Compile Include="Issue7249SwitchRenderer.cs" />
<Compile Include="_9087CustomRenderer.cs" />
<Compile Include="_10940CustomRenderer.cs" />
<Compile Include="RippleEffect.cs" />
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\default.css" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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"
xmlns:local="using:Xamarin.Forms.Controls"
xmlns:effects="clr-namespace:Xamarin.Forms.Controls.Issues"
mc:Ignorable="d"
Title="Test 11374"
x:Class="Xamarin.Forms.Controls.Issues.Issue11374">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label
Padding="12"
BackgroundColor="Black"
TextColor="White"
Text="Swipe an Item to the right or left. If you can open the SwipeView, the test has passed."/>
<ListView
x:Name="ItemsListView"
Grid.Row="1"
ItemsSource="{Binding Items}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
SelectionMode="Single"
SeparatorVisibility="None"
CachingStrategy="RecycleElementAndDataTemplate">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Height="64">
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems
SwipeBehaviorOnInvoked="Close">
<SwipeItemView>
<Label
Text="Left Swipe"
Padding="25,0,25,0"
VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center">
</Label>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
<SwipeView.RightItems>
<SwipeItems SwipeBehaviorOnInvoked="Close">
<SwipeItemView>
<Label
Text="Right Swipe"
Padding="25,0,25,0"
VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center">
</Label>
</SwipeItemView>
</SwipeItems>
</SwipeView.RightItems>
<ContentView
BackgroundColor="White">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.Effects>
<effects:RippleEffect />
</Grid.Effects>
<StackLayout Padding="10">
<Label
Text="{Binding .}"
d:Text="{Binding .}"
LineBreakMode="NoWrap"
FontSize="16" />
</StackLayout>
</Grid>
</ContentView>
</SwipeView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</local:TestContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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, 11374,
"[Bug] [Android] SwipeView in ListView is not working with RippleEffect and Release configuration",
PlatformAffected.Android)]
public partial class Issue11374 : TestContentPage
{
public Issue11374()
{
#if APP
Device.SetFlags(new List<string> { ExperimentalFlags.SwipeViewExperimental });

InitializeComponent();
#endif
}

protected override void Init()
{
BindingContext = new Issue11374ViewModel();
}
}

[Preserve(AllMembers = true)]
public class Issue11374ViewModel : BindableObject
{
public ObservableCollection<string> Items { get; set; }

public Command LoadItemsCommand { get; set; }

public Issue11374ViewModel()
{
LoadItems();
}

void LoadItems()
{
Items = new ObservableCollection<string>
{
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5"
};
}
}

[Preserve(AllMembers = true)]
public class RippleEffect : RoutingEffect
{
public RippleEffect() : base($"{Effects.ResolutionGroupName}.{nameof(RippleEffect)}")
{

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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
{
#if UITEST
[Category(UITestCategories.Frame)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 11430,
"[Bug] [iOS] Button stays in Pressed state if the touch-up event occurs outside",
PlatformAffected.iOS)]
public class Issue11430 : TestContentPage
{
public Issue11430()
{
}

protected override void Init()
{
Title = "Issue 11430";

var layout = new StackLayout();

var instructions = new Label
{
Padding = 12,
BackgroundColor = Color.Black,
TextColor = Color.White,
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."
};

var button = new Button
{
Text = "Click Me"
};

layout.Children.Add(instructions);
layout.Children.Add(button);

Content = layout;

button.Clicked += (sender, args) =>
{
DisplayAlert("Issue 11430", "Button Clicked.", "Ok");
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms.Internals;
using Xamarin.Forms.CustomAttributes;
using System.ComponentModel;
using System.Threading.Tasks;

namespace Xamarin.Forms.Controls.Issues
{
[Issue(IssueTracker.Github, 9451,
"[Bug] RelativeLayout Constraint can not go back to zero", PlatformAffected.All)]
public class Issue9451 : TestContentPage
{
public StackLayout StackLayout { get; set; }
public Button TriggerButton { get; set; }

protected override void Init()
{
var relativeLayout = new RelativeLayout() { WidthRequest = 400, HeightRequest = 400 };
StackLayout = new StackLayout() { BackgroundColor = Color.Red };

TriggerButton = new Button() { Text = "Set View Width To Zero" };

StackLayout.Children.Add(TriggerButton);

relativeLayout.Children.Add(StackLayout,
Xamarin.Forms.Constraint.Constant(0),
Xamarin.Forms.Constraint.Constant(0),
Xamarin.Forms.Constraint.RelativeToParent(x => x.Width / 2),
Xamarin.Forms.Constraint.RelativeToParent(y => y.Height));

Content = relativeLayout;
}

protected override void OnAppearing()
{
base.OnAppearing();

TriggerButton.Clicked += Button_Clicked;
}

protected override void OnDisappearing()
{
base.OnDisappearing();

TriggerButton.Clicked -= Button_Clicked;
}

private void Button_Clicked(object sender, EventArgs e)
{
RelativeLayout.SetWidthConstraint(StackLayout, Xamarin.Forms.Constraint.Constant(0.0));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue11272.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11563.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11547.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue9451.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11374.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11430.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11247.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -1725,6 +1728,9 @@
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11224.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11374.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11262.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ bool ShouldInterceptTouch(MotionEvent e)

public override bool OnInterceptTouchEvent(MotionEvent e)
{
return false;
return ShouldInterceptTouch(e);
}

public override bool DispatchTouchEvent(MotionEvent e)
Expand Down
14 changes: 3 additions & 11 deletions Xamarin.Forms.Platform.UAP/FormsTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public class FormsTextBox : TextBox

InputScope _passwordInputScope;
InputScope _numericPasswordInputScope;
Border _borderElement;
Windows.UI.Xaml.Controls.ScrollViewer _scrollViewer;
ScrollViewer _scrollViewer;
Windows.UI.Xaml.Controls.Grid _rootGrid;
Windows.UI.Xaml.VisualState _DeleteButtonVisibleState;
Windows.UI.Xaml.VisualStateGroup _DeleteButtonVisibleStateGroups;
Expand Down Expand Up @@ -157,14 +156,7 @@ protected override void OnApplyTemplate()
{
base.OnApplyTemplate();

if (Device.Idiom == TargetIdiom.Phone)
{
// If we're on the phone, we need to grab this from the template
// so we can manually handle its background when focused
_borderElement = (Border)GetTemplateChild("BorderElement");
}

_rootGrid = (Windows.UI.Xaml.Controls.Grid)GetTemplateChild("RootGrid");
_rootGrid = GetTemplateChild("RootGrid") as Windows.UI.Xaml.Controls.Grid;
if (_rootGrid != null)
{
var stateGroups = WVisualStateManager.GetVisualStateGroups(_rootGrid).ToList();
Expand All @@ -173,7 +165,7 @@ protected override void OnApplyTemplate()
_DeleteButtonVisibleState = _DeleteButtonVisibleStateGroups.States.SingleOrDefault(s => s.Name == "ButtonVisible");
}

_scrollViewer= (Windows.UI.Xaml.Controls.ScrollViewer)GetTemplateChild("ContentElement");
_scrollViewer= GetTemplateChild("ContentElement") as ScrollViewer;
}

void OnSizeChanged(object sender, SizeChangedEventArgs e)
Expand Down
5 changes: 5 additions & 0 deletions Xamarin.Forms.Platform.iOS/Renderers/ButtonElementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,10 @@ internal static void OnButtonTouchUpInside(IButtonController element)
element?.SendReleased();
element?.SendClicked();
}

internal static void OnButtonTouchUpOutside(IButtonController element)
{
element?.SendReleased();
}
}
}
Loading

0 comments on commit 57aefa6

Please sign in to comment.