From b2f98b587697ac750bfe0ee0cdc11b81d49ec7f1 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 23 Jan 2024 18:59:49 +0200 Subject: [PATCH 1/3] fix: Fix CalendarDatePicker day item corner --- .../UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs | 8 +++++--- .../CalendarView/CalendarViewDayItem.Properties.cs | 3 +++ .../UI/Xaml/Controls/CalendarView/CalendarViewDayItem.cs | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs b/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs index 7fc50bd7bd06..6ef1a7448e1e 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs @@ -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; @@ -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); } } diff --git a/src/Uno.UI/UI/Xaml/Controls/CalendarView/CalendarViewDayItem.Properties.cs b/src/Uno.UI/UI/Xaml/Controls/CalendarView/CalendarViewDayItem.Properties.cs index 5d4315335acf..02a921647137 100644 --- a/src/Uno.UI/UI/Xaml/Controls/CalendarView/CalendarViewDayItem.Properties.cs +++ b/src/Uno.UI/UI/Xaml/Controls/CalendarView/CalendarViewDayItem.Properties.cs @@ -28,6 +28,9 @@ public bool IsBlackout } internal set { +#if DEBUG + put_Date(value); +#endif this.SetValue(DateProperty, value); } } diff --git a/src/Uno.UI/UI/Xaml/Controls/CalendarView/CalendarViewDayItem.cs b/src/Uno.UI/UI/Xaml/Controls/CalendarView/CalendarViewDayItem.cs index dc4f28eba123..88168aa78653 100644 --- a/src/Uno.UI/UI/Xaml/Controls/CalendarView/CalendarViewDayItem.cs +++ b/src/Uno.UI/UI/Xaml/Controls/CalendarView/CalendarViewDayItem.cs @@ -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 From 0e4f9145417d5fc1f5c102f3aac4cec2afde959e Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Wed, 24 Jan 2024 09:50:41 +0000 Subject: [PATCH 2/3] test: Add test for CalendarView item corner radius --- .../Given_CalendarView.cs | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs index 5ac79ec3fed5..8b69c71e892f 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs @@ -1,15 +1,16 @@ 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; +using Microsoft.UI; #if !HAS_UNO_WINUI using Microsoft/* UWP don't rename */.UI.Xaml.Controls; @@ -22,6 +23,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(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()) + { + 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 From ed7d14fa90086b17642063f49412043df3598a29 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Wed, 24 Jan 2024 16:06:07 +0200 Subject: [PATCH 3/3] chore: Fix build --- .../Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs index 8b69c71e892f..dce7f8d8b009 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs @@ -10,7 +10,6 @@ using Uno.UI.Extensions; using Uno.UI.RuntimeTests.Helpers; using System.Linq; -using Microsoft.UI; #if !HAS_UNO_WINUI using Microsoft/* UWP don't rename */.UI.Xaml.Controls; @@ -28,7 +27,7 @@ public class Given_CalendarView public async Task When_ItemCornerRadius() { var calendarView = new CalendarView(); - calendarView.OutOfScopeBackground = new SolidColorBrush(Colors.Red); + calendarView.OutOfScopeBackground = new SolidColorBrush(Microsoft.UI.Colors.Red); calendarView.CalendarItemCornerRadius = new CornerRadius(40); calendarView.DayItemCornerRadius = new CornerRadius(20);