diff options
author | Samantha Houts <samhouts@users.noreply.github.com> | 2017-03-23 16:12:41 -0700 |
---|---|---|
committer | E.Z. Hart <hartez@users.noreply.github.com> | 2017-03-23 17:12:41 -0600 |
commit | 79ecf97d92331c790b5ba5c99f453607260f40cb (patch) | |
tree | 684071dda7a8ae360de7616b724438f1244b5547 | |
parent | f27f5a3650f37894d4a1ac925d6fab4dc7350087 (diff) | |
download | xamarin-forms-79ecf97d92331c790b5ba5c99f453607260f40cb.tar.gz xamarin-forms-79ecf97d92331c790b5ba5c99f453607260f40cb.tar.bz2 xamarin-forms-79ecf97d92331c790b5ba5c99f453607260f40cb.zip |
[Android] ScrollView can now consume Effects (#836)
* Add repro
* [Android] Make ScrollView an IEffectControlProvider
5 files changed, 70 insertions, 1 deletions
diff --git a/Xamarin.Forms.ControlGallery.Android/Activity1.cs b/Xamarin.Forms.ControlGallery.Android/Activity1.cs index 6f2b22dc..b0491b0f 100644 --- a/Xamarin.Forms.ControlGallery.Android/Activity1.cs +++ b/Xamarin.Forms.ControlGallery.Android/Activity1.cs @@ -39,6 +39,10 @@ namespace Xamarin.Forms.ControlGallery.Android protected override void OnAttached () { Control.SetBackgroundColor (global::Android.Graphics.Color.Aqua); + + var childLabel = (Element as ScrollView)?.Content as Label; + if (childLabel != null) + childLabel.Text = "Success"; } protected override void OnDetached () diff --git a/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs b/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs index 1aed7738..03f145b1 100644 --- a/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs +++ b/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs @@ -25,6 +25,10 @@ namespace Xamarin.Forms.ControlGallery.iOS protected override void OnAttached() { Control.BackgroundColor = UIColor.Blue; + + var childLabel = (Element as ScrollView)?.Content as Label; + if (childLabel != null) + childLabel.Text = "Success"; } protected override void OnDetached() diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45874.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45874.cs new file mode 100644 index 00000000..46c53607 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45874.cs @@ -0,0 +1,44 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +// Apply the default category of "Issues" to all of the tests in this assembly +// We use this as a catch-all for tests which haven't been individually categorized +#if UITEST +[assembly: NUnit.Framework.Category("Issues")] +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 45874, "Effect not attaching to ScrollView", PlatformAffected.iOS | PlatformAffected.Android)] + public class Bugzilla45874 : TestContentPage + { + const string Success = "Success"; + + protected override void Init() + { + var label = new Label { Text = "FAIL" }; + + var scrollView = new ScrollView { Content = label }; + + var effect = Effect.Resolve("XamControl.BorderEffect"); + + scrollView.Effects.Add(effect); + + Content = scrollView; + } + +#if UITEST + [Test] + public void Bugzilla45874Test() + { + RunningApp.WaitForElement(q => q.Marked(Success)); + } +#endif + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index ced1ef52..5a8d41fa 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -266,6 +266,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla51505.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla52533.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla53362.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla45874.cs" /> <Compile Include="$(MSBuildThisFileDirectory)_Template.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Issue1075.cs" /> diff --git a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs index a2e3ddb3..b7961411 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs @@ -5,11 +5,12 @@ using Android.Animation; using Android.Graphics; using Android.Views; using Android.Widget; +using Xamarin.Forms.Internals; using AScrollView = Android.Widget.ScrollView; namespace Xamarin.Forms.Platform.Android { - public class ScrollViewRenderer : AScrollView, IVisualElementRenderer + public class ScrollViewRenderer : AScrollView, IVisualElementRenderer, IEffectControlProvider { ScrollViewContainer _container; HorizontalScrollView _hScrollView; @@ -77,6 +78,8 @@ namespace Xamarin.Forms.Platform.Android if (!string.IsNullOrEmpty(element.AutomationId)) ContentDescription = element.AutomationId; } + + EffectUtilities.RegisterEffectControlProvider(this, oldElement, element); } public VisualElementTracker Tracker { get; private set; } @@ -216,6 +219,19 @@ namespace Xamarin.Forms.Platform.Android } } + void IEffectControlProvider.RegisterEffect(Effect effect) + { + var platformEffect = effect as PlatformEffect; + if (platformEffect != null) + OnRegisterEffect(platformEffect); + } + + void OnRegisterEffect(PlatformEffect effect) + { + effect.SetContainer(this); + effect.SetControl(this); + } + static int GetDistance(double start, double position, double v) { return (int)(start + (position - start) * v); |