static void AttachNodesFromViewHierachy()

in csharp/Facebook.YogaKit/YogaLayout.cs [816:854]


		static void AttachNodesFromViewHierachy(NativeView view)
		{
			YogaLayout yoga = view.Yoga() as YogaLayout;
			var node = yoga._node;
			// Only leaf nodes should have a measure function
			if (yoga.IsLeaf)
			{
				RemoveAllChildren(node);
				node.SetMeasureFunction(MeasureView);
			}
			else
			{
				node.SetMeasureFunction(null);
				// Create a list of all the subviews that we are going to use for layout.
				var subviewsToInclude = new List<NativeView>();
				foreach (var subview in view.Subviews)
				{
					if (subview.Yoga().IsEnabled && subview.Yoga().IsIncludeInLayout)
					{
						subviewsToInclude.Add(subview);
					}
				}

				if (!NodeHasExactSameChildren(node, subviewsToInclude.ToArray()))
				{
					RemoveAllChildren(node);
					for (int i = 0; i < subviewsToInclude.Count; i++)
					{
						YogaLayout yogaSubview = subviewsToInclude[i].Yoga() as YogaLayout;
						node.Insert(i, yogaSubview._node);
					}
				}

				foreach (var subView in subviewsToInclude)
				{
					AttachNodesFromViewHierachy(subView);
				}
			}
		}