Skip to content

Commit

Permalink
Fix Frame measure (dotnet#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
myroot committed Aug 25, 2022
1 parent 2aab70c commit 636ed9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using SkiaSharp;
using Tizen.UIExtensions.NUI;
using IMeasurable = Tizen.UIExtensions.Common.IMeasurable;
using TColor = Tizen.UIExtensions.Common.Color;
using NColor = Tizen.NUI.Color;
using TShadow = Tizen.NUI.Shadow;
using TColor = Tizen.UIExtensions.Common.Color;
using TLayoutParamPolicies = Tizen.NUI.BaseComponents.LayoutParamPolicies;
using TShadow = Tizen.NUI.Shadow;
using TSize = Tizen.UIExtensions.Common.Size;

namespace Microsoft.Maui.Controls.Handlers.Compatibility
{
Expand Down Expand Up @@ -171,7 +172,7 @@ void UpdateShadow()

if (Element.HasShadow)
{
BoxShadow = new TShadow(6.0.ToScaledPixel(), TColor.FromHex("#111111").ToNative());
BoxShadow = new TShadow(2.0.ToScaledPixel(), TColor.FromHex("#111111").ToNative());
}
else
{
Expand Down Expand Up @@ -217,19 +218,25 @@ void UpdateContent()
}
}

#region IPlatformViewHandler
Size IViewHandler.GetDesiredSize(double widthConstraint, double heightConstraint)

TSize IMeasurable.Measure(double availableWidth, double availableHeight)
{
if (Element?.Handler is IPlatformViewHandler pvh && Element is IContentView cv)
{
return pvh.MeasureVirtualView(widthConstraint, heightConstraint, cv.CrossPlatformMeasure);
return pvh.MeasureVirtualView(availableWidth.ToScaledDP(), availableHeight.ToScaledDP(), cv.CrossPlatformMeasure).ToPixel();
}
else
{
return Graphics.Size.Zero;
return NaturalSize2D.ToCommon();
}
}

#region IPlatformViewHandler
Size IViewHandler.GetDesiredSize(double widthConstraint, double heightConstraint)
{
return this.GetDesiredSizeFromHandler(widthConstraint, heightConstraint);
}

bool IViewHandler.HasContainer { get => false; set { } }

object? IViewHandler.ContainerView => null;
Expand Down
1 change: 1 addition & 0 deletions src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public static IMauiHandlersCollection AddMauiControlsHandlers(this IMauiHandlers
#endif
#if TIZEN
handlersCollection.AddHandler(typeof(Frame), typeof(Handlers.Compatibility.FrameRenderer));
handlersCollection.AddHandler<ContentView, ContentViewHandler>();
#endif

#if WINDOWS || MACCATALYST
Expand Down

0 comments on commit 636ed9d

Please sign in to comment.