Skip to content

Commit

Permalink
Merge pull request unoplatform#15188 from Youssef1313/calendardatepic…
Browse files Browse the repository at this point in the history
…ker-bug

fix: Fix CalendarDatePicker day item corner
  • Loading branch information
MartinZikmund authored Jan 25, 2024
2 parents e573143 + ed7d14f commit 73751af
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Threading.Tasks;
using Private.Infrastructure;
using Microsoft.UI.Xaml.Controls;
using MUXControlsTestApp.Utilities;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using Uno.UI.RuntimeTests.MUX.Helpers;
using Windows.UI;
using Microsoft.UI.Xaml.Input;
using System.Reflection;
using MUXControlsTestApp.Utilities;
using Private.Infrastructure;
using Uno.UI.Extensions;
using Uno.UI.RuntimeTests.Helpers;
using System.Linq;

#if !HAS_UNO_WINUI
using Microsoft/* UWP don't rename */.UI.Xaml.Controls;
Expand All @@ -22,6 +22,34 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls;
[RunsOnUIThread]
public class Given_CalendarView
{
#if __WASM__
[TestMethod]
public async Task When_ItemCornerRadius()
{
var calendarView = new CalendarView();
calendarView.OutOfScopeBackground = new SolidColorBrush(Microsoft.UI.Colors.Red);
calendarView.CalendarItemCornerRadius = new CornerRadius(40);
calendarView.DayItemCornerRadius = new CornerRadius(20);

await UITestHelper.Load(calendarView);
await TestServices.WindowHelper.WaitForIdle();

var hasOutOfScope = false;

foreach (var dayItem in calendarView.EnumerateDescendants().OfType<CalendarViewDayItem>())
{
var color = Uno.Foundation.WebAssemblyRuntime.InvokeJS($"document.getElementById({dayItem.HtmlId}).style[\"background-color\"]");
if (color == "rgb(255, 0, 0)")
{
hasOutOfScope = true;
var result = Uno.Foundation.WebAssemblyRuntime.InvokeJS($"document.getElementById({dayItem.HtmlId}).style[\"border-radius\"]");
Assert.AreEqual("21px", result);
}
}

Assert.IsTrue(hasOutOfScope);
}
#endif
#if __ANDROID__ || __IOS__ || __MACOS__
[Ignore("Test fails on these platforms")]
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
using Uno;
using Uno.UI.Helpers;
using Uno.UI.Extensions;
using Windows.Foundation;

namespace Microsoft.UI.Xaml.Shapes
{
partial class BorderLayerRenderer
{
private Brush _background;
private (Brush, Thickness, CornerRadius) _border;
private (Brush, Thickness, CornerRadius, Size) _border;

private Action _backgroundChanged;

Expand All @@ -38,9 +39,10 @@ public void UpdateLayer(
SetAndObserveBackgroundBrush(fwElt, oldValue, background, ref _backgroundChanged);
}

if (_border != (borderBrush, borderThickness, cornerRadius))
var renderSize = element.RenderSize;
if (_border != (borderBrush, borderThickness, cornerRadius, renderSize))
{
_border = (borderBrush, borderThickness, cornerRadius);
_border = (borderBrush, borderThickness, cornerRadius, renderSize);
SetBorder(element, borderThickness, borderBrush, cornerRadius);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public bool IsBlackout
}
internal set
{
#if DEBUG
put_Date(value);
#endif
this.SetValue(DateProperty, value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ protected override void OnKeyDown(

}

#if DEBUG && false
#if DEBUG
private void put_Date(DateTime value)
{
SetDateForDebug(value);
CalendarViewDayItemGenerated.Date = value;
//CalendarViewDayItemGenerated.Date = value;

}
#endif
Expand Down

0 comments on commit 73751af

Please sign in to comment.