Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Core/src/Platform/iOS/CheckBoxExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public static void UpdateForeground(this MauiCheckBox platformCheckBox, ICheckBo
{
platformCheckBox.CheckBoxTintColor = solid.Color;
}
else if (check.Foreground is null)
{
// Color was cleared; reset to null so the view inherits the default tint color
platformCheckBox.CheckBoxTintColor = null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,31 @@ async Task ValidateColor(ICheckBox checkBoxStub, Color color, Action action = nu
});
Assert.Equal(expected, color);
}

[Fact(DisplayName = "Foreground Resets to Default When Set to Null")]
public async Task ForegroundResetsToDefaultWhenSetToNull()
{
var checkBoxStub = new CheckBoxStub
{
Foreground = new SolidPaint(Colors.Red),
IsChecked = true
};

await InvokeOnMainThreadAsync(() =>
{
var handler = CreateHandler(checkBoxStub);
var native = GetNativeCheckBox(handler);

// Confirm that the red tint was applied initially
Assert.NotNull(native.CheckBoxTintColor);

// Simulate a dynamic Color = null (Foreground reset to default)
checkBoxStub.Foreground = null;
handler.UpdateValue(nameof(ICheckBox.Foreground));

// After reset, the native tint must be null so iOS reverts to its inherited default
Assert.Null(native.CheckBoxTintColor);
});
}
}
}
Loading