Summary: This change applies all Arcanist recommended lint changes, which amounts to changing copyright headers and some cases of whitespace changes. Reviewed By: yungsters Differential Revision: D40060899 fbshipit-source-id: b62f9472e6ef58a3fc3d22eed661578a2635cb1f
67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
using System.Collections.Generic;
|
|
using CoreGraphics;
|
|
using Facebook.Yoga;
|
|
using Foundation;
|
|
using UIKit;
|
|
|
|
namespace Facebook.YogaKit
|
|
{
|
|
public partial class YogaLayout : NSObject
|
|
{
|
|
static IEnumerable<UIView> GetChildren(UIView view) => view.Subviews;
|
|
|
|
static void MeasureNativeView(UIView view, float constrainedWidth, float constrainedHeight, out float sizeThatFitsWidth, out float sizeThatFitsHeight)
|
|
{
|
|
var sizeThatFits = view.SizeThatFits(new CGSize(constrainedWidth, constrainedHeight));
|
|
sizeThatFitsWidth = (float)sizeThatFits.Width;
|
|
sizeThatFitsHeight = (float)sizeThatFits.Height;
|
|
}
|
|
|
|
static void GetWidthHeightOfNativeView(UIView view, out float width, out float height)
|
|
{
|
|
width = (float)view.Bounds.Width;
|
|
height = (float)view.Bounds.Height;
|
|
}
|
|
|
|
static float NativePixelScale => (float)UIScreen.MainScreen.Scale;
|
|
|
|
|
|
static void ApplyLayoutToNativeView(UIView view, YogaNode node)
|
|
{
|
|
var topLeft = new CGPoint(node.LayoutX, node.LayoutY);
|
|
var bottomRight = new CGPoint(topLeft.X + node.LayoutWidth, topLeft.Y + node.LayoutHeight);
|
|
if (view is UIScrollView scrollView)
|
|
{
|
|
scrollView.ContentSize = new CGSize(RoundPointValue((float)bottomRight.X) - RoundPointValue((float)topLeft.X), RoundPointValue((float)bottomRight.Y) - RoundPointValue((float)topLeft.Y));
|
|
}
|
|
else
|
|
{
|
|
view.Frame = new CGRect(RoundPointValue((float)topLeft.X), RoundPointValue((float)topLeft.Y), RoundPointValue((float)bottomRight.X) - RoundPointValue((float)topLeft.X), RoundPointValue((float)bottomRight.Y) - RoundPointValue((float)topLeft.Y));
|
|
}
|
|
}
|
|
|
|
bool _disposed;
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && !_disposed)
|
|
{
|
|
_disposed = true;
|
|
if (YogaKit.Bridges.ContainsKey(_node))
|
|
{
|
|
YogaKit.Bridges.Remove(_node);
|
|
}
|
|
_node = null;
|
|
_viewRef = null;
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
}
|