Skip to content

Commit

Permalink
Fix WrapperView Width/HeightSpecification (dotnet#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
myroot committed Aug 24, 2022
1 parent 47ffe36 commit 9ac1b15
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Core/src/Handlers/View/ViewHandlerOfT.Tizen.cs
Expand Up @@ -60,7 +60,11 @@ protected override void SetupContainer()
parent?.Remove(PlatformView);
}

ContainerView ??= new WrapperView();
ContainerView ??= new WrapperView()
{
WidthSpecification = PlatformView.WidthSpecification,
HeightSpecification = PlatformView.HeightSpecification
};
PlatformView.UpdatePosition(new Point(0, 0));
ContainerView.Content = PlatformView;

Expand Down
27 changes: 24 additions & 3 deletions src/Core/src/Platform/Tizen/NaviPage.cs
@@ -1,17 +1,22 @@
using Tizen.NUI.BaseComponents;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using Tizen.NUI.BaseComponents;
using Tizen.UIExtensions.Common;
using Tizen.UIExtensions.NUI;
using NLayoutGroup = Tizen.NUI.LayoutGroup;
using NLinearLayout = Tizen.NUI.LinearLayout;
using NView = Tizen.NUI.BaseComponents.View;


namespace Microsoft.Maui
{
public class NaviPage : NView
public class NaviPage : NView, IContainable<NView>
{
TitleView? _titleView;
NView? _content;

ObservableCollection<NView> _children = new ObservableCollection<NView>();

public NaviPage()
{
HeightSpecification = LayoutParamPolicies.MatchParent;
Expand All @@ -21,6 +26,8 @@ public NaviPage()
{
LinearOrientation = NLinearLayout.Orientation.Vertical
};

_children.CollectionChanged += OnCollectionChanged;
}

public TitleView? TitleView
Expand Down Expand Up @@ -66,5 +73,19 @@ public NaviPage()
}
}
}

IList<NView> IContainable<NView>.Children => _children;

void OnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems != null)
{
Content = e.NewItems[0] as NView;
}
else if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Reset)
{
Content = null;
}
}
}
}

0 comments on commit 9ac1b15

Please sign in to comment.