[NUI] Fix ContentPageLayout to measure AppBar prior to Content
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Mon, 29 Aug 2022 04:16:41 +0000 (13:16 +0900)
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>
Tue, 30 Aug 2022 07:41:27 +0000 (16:41 +0900)
Content's height is calculated correctly after AppBar's height is
calculated.

Therefore, AppBar is measured and then Content is measured.

src/Tizen.NUI.Components/Controls/Navigation/ContentPage.cs

index 9dd60ec..b92f9d3 100755 (executable)
@@ -211,6 +211,14 @@ namespace Tizen.NUI.Components
                 var appBar = (Owner as ContentPage)?.AppBar;
                 var content = (Owner as ContentPage)?.Content;
 
+                bool measureAppBarLayout = false;
+
+                if ((appBar != null) && (appBar.Layout != null) && (LayoutChildren.Contains(appBar.Layout)) && appBar.Layout.SetPositionByLayout)
+                {
+                    MeasureChildWithoutPadding(appBar.Layout, widthMeasureSpec, heightMeasureSpec);
+                    measureAppBarLayout = true;
+                }
+
                 foreach (var childLayout in LayoutChildren)
                 {
                     if (!childLayout.SetPositionByLayout)
@@ -218,13 +226,13 @@ namespace Tizen.NUI.Components
                         continue;
                     }
 
-                    if ((content != null) && (content == childLayout.Owner) && (content.HeightSpecification == LayoutParamPolicies.MatchParent))
+                    if ((content != null) && (content == childLayout.Owner) && (content.HeightSpecification == LayoutParamPolicies.MatchParent) && measureAppBarLayout)
                     {
                         var contentSizeH = heightMeasureSpec.Size.AsDecimal() - Padding.Top - Padding.Bottom - content.Margin.Top - content.Margin.Bottom - (appBar?.Layout.MeasuredHeight.Size.AsDecimal() ?? 0);
                         MeasureSpecification contentHeightSpec = new MeasureSpecification(new LayoutLength(contentSizeH), MeasureSpecification.ModeType.Exactly);
                         MeasureChildWithoutPadding(childLayout, widthMeasureSpec, contentHeightSpec);
                     }
-                    else
+                    else if (!measureAppBarLayout || (appBar != childLayout.Owner)) // if childLayout is not appBar.Layout
                     {
                         MeasureChildWithoutPadding(childLayout, widthMeasureSpec, heightMeasureSpec);
                     }