diff options
author | Samantha Houts <samantha@teamredwall.com> | 2016-04-07 05:30:13 -0700 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-04-07 13:30:13 +0100 |
commit | bb7bf53447538d5f17cac48052585a6a9282f70b (patch) | |
tree | 826a599e2ca665c41e4bfdf4b36d293db4a2ed00 | |
parent | c98d338e15a29897e3a9a9d03d30dd3c70347925 (diff) | |
download | xamarin-forms-bb7bf53447538d5f17cac48052585a6a9282f70b.tar.gz xamarin-forms-bb7bf53447538d5f17cac48052585a6a9282f70b.tar.bz2 xamarin-forms-bb7bf53447538d5f17cac48052585a6a9282f70b.zip |
Merge pull request #45 from xamarin/fix-bugzilla25662
[A] SwitchCell IsEnabled bit now affects the toggle
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25662.cs | 30 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Android/Cells/SwitchCellRenderer.cs | 11 |
2 files changed, 32 insertions, 9 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25662.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25662.cs index 6a34cdf7..c9a95a9c 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25662.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25662.cs @@ -1,24 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.CustomAttributes; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif namespace Xamarin.Forms.Controls.Issues { [Preserve (AllMembers = true)] [Issue (IssueTracker.Bugzilla, 25662, "Setting IsEnabled does not disable SwitchCell")] - public class Bugzilla25662 : ContentPage + public class Bugzilla25662 : TestContentPage { + [Preserve(AllMembers = true)] class MySwitch : SwitchCell { public MySwitch () { IsEnabled = false; + SetBinding(SwitchCell.TextProperty, new Binding(".")); + OnChanged += (sender, e) => Text = "FAIL"; } } - - public Bugzilla25662 () + protected override void Init () { var list = new ListView { ItemsSource = new[] { @@ -28,8 +32,16 @@ namespace Xamarin.Forms.Controls.Issues }; Content = list; - Title = "My page"; + } +#if UITEST + [Test] + public void Bugzilla25662Test () + { + RunningApp.WaitForElement (q => q.Marked ("One")); + RunningApp.Tap(q => q.Marked("One")); + RunningApp.WaitForNoElement(q => q.Marked("FAIL")); } - } +#endif + } } diff --git a/Xamarin.Forms.Platform.Android/Cells/SwitchCellRenderer.cs b/Xamarin.Forms.Platform.Android/Cells/SwitchCellRenderer.cs index bba9d260..f2ea5cc3 100644 --- a/Xamarin.Forms.Platform.Android/Cells/SwitchCellRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Cells/SwitchCellRenderer.cs @@ -23,6 +23,7 @@ namespace Xamarin.Forms.Platform.Android UpdateText(); UpdateChecked(); UpdateHeight(); + UpdateIsEnabled(_view, cell); return _view; } @@ -35,6 +36,8 @@ namespace Xamarin.Forms.Platform.Android UpdateChecked(); else if (args.PropertyName == "RenderHeight") UpdateHeight(); + else if (args.PropertyName == Cell.IsEnabledProperty.PropertyName) + UpdateIsEnabled(_view, (SwitchCell)sender); } void UpdateChecked() @@ -42,6 +45,14 @@ namespace Xamarin.Forms.Platform.Android ((ASwitch)_view.AccessoryView).Checked = ((SwitchCell)Cell).On; } + void UpdateIsEnabled(SwitchCellView cell, SwitchCell switchCell) + { + cell.Enabled = switchCell.IsEnabled; + var aSwitch = cell.AccessoryView as ASwitch; + if (aSwitch != null) + aSwitch.Enabled = switchCell.IsEnabled; + } + void UpdateHeight() { _view.SetRenderHeight(Cell.RenderHeight); |