Skip to content

Commit

Permalink
Fix CheckBox's VisualStates (#8605) Fixes #8596
Browse files Browse the repository at this point in the history
* Propagate CheckBox Color property changes to handlers

* Added device test
  • Loading branch information
jsuarezruiz committed Sep 12, 2022
1 parent f2a9211 commit 6f92b8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Controls/src/Core/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class CheckBox : View, IElementConfiguration<CheckBox>, IBorderEl
BindableProperty.Create(nameof(IsChecked), typeof(bool), typeof(CheckBox), false,
propertyChanged: (bindable, oldValue, newValue) =>
{
((CheckBox)bindable).Handler?.UpdateValue(nameof(ICheckBox.Foreground));
((CheckBox)bindable).CheckedChanged?.Invoke(bindable, new CheckedChangedEventArgs((bool)newValue));
((CheckBox)bindable).ChangeVisualState();
}, defaultBindingMode: BindingMode.TwoWay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public async Task IsCheckedInitializesCorrectly(bool isChecked)
await ValidatePropertyInitValue(checkBoxStub, () => checkBoxStub.IsChecked, GetNativeIsChecked, checkBoxStub.IsChecked);
}

[Fact(DisplayName = "Foreground Updates Correctly")]
public async Task ForegroundUpdatesCorrectly()
[Fact(DisplayName = "Foreground Initializes Correctly")]
public async Task ForegroundInitializesCorrectly()
{
var checkBoxStub = new CheckBoxStub()
{
Expand All @@ -33,5 +33,22 @@ public async Task ForegroundUpdatesCorrectly()

await ValidateColor(checkBoxStub, Colors.Red);
}

[Theory(DisplayName = "Foreground Updates Correctly")]
[InlineData(0xFF0000)]
[InlineData(0x0000FF)]
public async Task ForegroundUpdatesCorrectly(uint color)
{
var checkBoxStub = new CheckBoxStub
{
Foreground = new SolidPaint(Colors.Black),
IsChecked = true
};

var expected = Color.FromUint(color);
checkBoxStub.Foreground = new SolidPaint(expected);

await ValidateColor(checkBoxStub, expected);
}
}
}

0 comments on commit 6f92b8c

Please sign in to comment.