Add basic Xamarin.iOS support
This commit is contained in:
13
csharp/Facebook.Yoga/ios/ApiDefinition.cs
Normal file
13
csharp/Facebook.Yoga/ios/ApiDefinition.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
using UIKit;
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
using CoreGraphics;
|
||||
|
||||
namespace Facebook.Yoga.iOS
|
||||
{
|
||||
// We're actually abusing the Xamarin.iOS binding project
|
||||
// to bundle in the static lib for us. There is no objective-c
|
||||
// lib to bind, but the build will fail without ApiDefinition.cs
|
||||
}
|
11
csharp/Facebook.Yoga/ios/CustomBuildAction.targets
Normal file
11
csharp/Facebook.Yoga/ios/CustomBuildAction.targets
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<PropertyGroup>
|
||||
<CompileDependsOn>CopyInNativeLib;$(CompileDependsOn)</CompileDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- The # and , in this path does not play nice with the binding project logic, so make a copy -->
|
||||
<Target Name="CopyInNativeLib" Inputs="..\..\..\buck-out\gen\yoga#default,static\libyoga.a" Outputs="$(ProjectDir)libyoga.a">
|
||||
<Copy SourceFiles="..\..\..\buck-out\gen\yoga#default,static\libyoga.a" DestinationFiles="$(ProjectDir)/libyoga.a" />
|
||||
</Target>
|
||||
</Project>
|
@@ -0,0 +1,59 @@
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace Facebook.Yoga.iOS.Test
|
||||
{
|
||||
// The UIApplicationDelegate for the application. This class is responsible for launching the
|
||||
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
|
||||
[Register("AppDelegate")]
|
||||
public class AppDelegate : UIApplicationDelegate
|
||||
{
|
||||
// class-level declarations
|
||||
|
||||
public override UIWindow Window
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
// If not required for your application you can safely delete this method
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnResignActivation(UIApplication application)
|
||||
{
|
||||
// Invoked when the application is about to move from active to inactive state.
|
||||
// This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
|
||||
// or when the user quits the application and it begins the transition to the background state.
|
||||
// Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
public override void DidEnterBackground(UIApplication application)
|
||||
{
|
||||
// Use this method to release shared resources, save user data, invalidate timers and store the application state.
|
||||
// If your application supports background exection this method is called instead of WillTerminate when the user quits.
|
||||
}
|
||||
|
||||
public override void WillEnterForeground(UIApplication application)
|
||||
{
|
||||
// Called as part of the transiton from background to active state.
|
||||
// Here you can undo many of the changes made on entering the background.
|
||||
}
|
||||
|
||||
public override void OnActivated(UIApplication application)
|
||||
{
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive.
|
||||
// If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
public override void WillTerminate(UIApplication application)
|
||||
{
|
||||
// Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,157 @@
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "29x29",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "29x29",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "29x29",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "40x40",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "40x40",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "57x57",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "57x57",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "60x60",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"size": "60x60",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "29x29",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "29x29",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "40x40",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "40x40",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "50x50",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "50x50",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "72x72",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "72x72",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "76x76",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"idiom": "ipad",
|
||||
"size": "76x76",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "24x24",
|
||||
"idiom": "watch",
|
||||
"scale": "2x",
|
||||
"role": "notificationCenter",
|
||||
"subtype": "38mm"
|
||||
},
|
||||
{
|
||||
"size": "27.5x27.5",
|
||||
"idiom": "watch",
|
||||
"scale": "2x",
|
||||
"role": "notificationCenter",
|
||||
"subtype": "42mm"
|
||||
},
|
||||
{
|
||||
"size": "29x29",
|
||||
"idiom": "watch",
|
||||
"role": "companionSettings",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "29x29",
|
||||
"idiom": "watch",
|
||||
"role": "companionSettings",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"size": "40x40",
|
||||
"idiom": "watch",
|
||||
"scale": "2x",
|
||||
"role": "appLauncher",
|
||||
"subtype": "38mm"
|
||||
},
|
||||
{
|
||||
"size": "44x44",
|
||||
"idiom": "watch",
|
||||
"scale": "2x",
|
||||
"role": "longLook",
|
||||
"subtype": "42mm"
|
||||
},
|
||||
{
|
||||
"size": "86x86",
|
||||
"idiom": "watch",
|
||||
"scale": "2x",
|
||||
"role": "quickLook",
|
||||
"subtype": "38mm"
|
||||
},
|
||||
{
|
||||
"size": "98x98",
|
||||
"idiom": "watch",
|
||||
"scale": "2x",
|
||||
"role": "quickLook",
|
||||
"subtype": "42mm"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
</dict>
|
||||
</plist>
|
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProjectGuid>{3B27656A-129D-4779-BDAD-1A088DFDD9C5}</ProjectGuid>
|
||||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Facebook.Yoga.iOS.Test</RootNamespace>
|
||||
<AssemblyName>Facebook.Yoga.iOS.Test</AssemblyName>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchFastDev>true</MtouchFastDev>
|
||||
<MtouchProfiling>true</MtouchProfiling>
|
||||
<MtouchUseSGen>true</MtouchUseSGen>
|
||||
<MtouchUseRefCounting>true</MtouchUseRefCounting>
|
||||
<IOSDebuggerPort>22979</IOSDebuggerPort>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
|
||||
<MtouchTlsProvider>Default</MtouchTlsProvider>
|
||||
<DeviceSpecificBuild>false</DeviceSpecificBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchUseSGen>true</MtouchUseSGen>
|
||||
<MtouchUseRefCounting>true</MtouchUseRefCounting>
|
||||
<MtouchFloat32>true</MtouchFloat32>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchLink>SdkOnly</MtouchLink>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
|
||||
<MtouchTlsProvider>Default</MtouchTlsProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchUseSGen>true</MtouchUseSGen>
|
||||
<MtouchUseRefCounting>true</MtouchUseRefCounting>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
|
||||
<MtouchTlsProvider>Default</MtouchTlsProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<DeviceSpecificBuild>true</DeviceSpecificBuild>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchFastDev>true</MtouchFastDev>
|
||||
<MtouchProfiling>true</MtouchProfiling>
|
||||
<MtouchUseSGen>true</MtouchUseSGen>
|
||||
<MtouchUseRefCounting>true</MtouchUseRefCounting>
|
||||
<MtouchFloat32>true</MtouchFloat32>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchLink>SdkOnly</MtouchLink>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
|
||||
<MtouchTlsProvider>Default</MtouchTlsProvider>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.iOS" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
|
||||
<ImageAsset Include="Assets.xcassets\Contents.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="LaunchScreen.storyboard" />
|
||||
<InterfaceDefinition Include="Main.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="Entitlements.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="ViewController.cs" />
|
||||
<Compile Include="ViewController.designer.cs">
|
||||
<DependentUpon>ViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Facebook.Yoga.iOS.csproj">
|
||||
<Project>{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}</Project>
|
||||
<Name>Facebook.Yoga.iOS</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
</Project>
|
39
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.Test/Info.plist
Normal file
39
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.Test/Info.plist
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleName</key>
|
||||
<string>Facebook.Yoga.iOS.Test</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.xamarin.facebook-yoga-ios-test</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>10.1</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||
</dict>
|
||||
</plist>
|
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS" />
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530" />
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb" />
|
||||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok" />
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600" />
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" />
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder" />
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375" />
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
15
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.Test/Main.cs
Normal file
15
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.Test/Main.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using UIKit;
|
||||
|
||||
namespace Facebook.Yoga.iOS.Test
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
// This is the main entry point of the application.
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main(args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204" />
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ" />
|
||||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE" />
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600" />
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" />
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder" />
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using CoreGraphics;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace Facebook.Yoga.iOS.Test
|
||||
{
|
||||
|
||||
public static class UIViewYogaExtensions
|
||||
{
|
||||
public static void ApplyYogaLayout(this UIView view, YogaNode n)
|
||||
{
|
||||
view.Frame = new CGRect(n.LayoutX, n.LayoutY, n.LayoutWidth, n.LayoutHeight);
|
||||
// This assumes your YogaNode and NSView children were inserted in same order
|
||||
for (int i = 0; i < n.Count; ++i)
|
||||
{
|
||||
YogaNode childNode = n[i];
|
||||
view.Subviews[i].Frame = new CGRect(childNode.LayoutX, childNode.LayoutY, childNode.LayoutWidth, childNode.LayoutHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ViewController : UIViewController
|
||||
{
|
||||
protected ViewController(IntPtr handle) : base(handle)
|
||||
{
|
||||
// Note: this .ctor should not contain any initialization logic.
|
||||
}
|
||||
|
||||
public override void ViewDidLoad()
|
||||
{
|
||||
base.ViewDidLoad();
|
||||
UIImage image = FromUrl("https://placehold.it/50x50");
|
||||
|
||||
UIView root = CreateViewHierarchy(image);
|
||||
|
||||
var rootNode = CalculateLayout(image.Size);
|
||||
|
||||
root.ApplyYogaLayout(rootNode);
|
||||
|
||||
View.AddSubview(root);
|
||||
|
||||
}
|
||||
static UIImage FromUrl(string uri)
|
||||
{
|
||||
using (var url = new NSUrl(uri))
|
||||
using (var data = NSData.FromUrl(url))
|
||||
return UIImage.LoadFromData(data);
|
||||
}
|
||||
static UIView CreateViewHierarchy(UIImage image)
|
||||
{
|
||||
var root = new UIView();
|
||||
UIImageView imageView = new UIImageView()
|
||||
{
|
||||
Image = image
|
||||
};
|
||||
root.AddSubview(imageView);
|
||||
|
||||
UITextField text = new UITextField()
|
||||
{
|
||||
Text = "Hello World",
|
||||
};
|
||||
root.AddSubview(text);
|
||||
return root;
|
||||
}
|
||||
|
||||
static YogaNode CalculateLayout(CGSize imageSize)
|
||||
{
|
||||
var rootNode = new YogaNode()
|
||||
{
|
||||
Width = 400,
|
||||
Height = 120,
|
||||
FlexDirection = YogaFlexDirection.Row
|
||||
};
|
||||
rootNode.SetPadding(YogaEdge.All, 20);
|
||||
|
||||
var imageNode = new YogaNode()
|
||||
{
|
||||
Width = (float)imageSize.Width,
|
||||
};
|
||||
imageNode.SetMargin(YogaEdge.End, 20);
|
||||
|
||||
var textNode = new YogaNode()
|
||||
{
|
||||
AlignSelf = YogaAlign.Center,
|
||||
FlexGrow = 1,
|
||||
};
|
||||
rootNode.Insert(0, imageNode);
|
||||
rootNode.Insert(1, textNode);
|
||||
rootNode.CalculateLayout();
|
||||
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
public override void DidReceiveMemoryWarning()
|
||||
{
|
||||
base.DidReceiveMemoryWarning();
|
||||
// Release any cached data, images, etc that aren't in use.
|
||||
}
|
||||
}
|
||||
}
|
17
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.Test/ViewController.designer.cs
generated
Normal file
17
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.Test/ViewController.designer.cs
generated
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// This file has been generated automatically by MonoDevelop to store outlets and
|
||||
// actions made in the Xcode designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using Foundation;
|
||||
|
||||
namespace Facebook.Yoga.iOS.Test
|
||||
{
|
||||
[Register("ViewController")]
|
||||
partial class ViewController
|
||||
{
|
||||
void ReleaseDesignerOutlets()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
121
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.csproj
Normal file
121
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.csproj
Normal file
@@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}</ProjectGuid>
|
||||
<ProjectTypeGuids>{8FFB629D-F513-41CE-95D2-7ECE97B6EEEC};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Facebook.Yoga.iOS</RootNamespace>
|
||||
<AssemblyName>Facebook.Yoga.iOS</AssemblyName>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Xamarin.iOS" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="..\MeasureFunction.cs">
|
||||
<Link>MeasureFunction.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MeasureOutput.cs">
|
||||
<Link>MeasureOutput.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Native.cs">
|
||||
<Link>Native.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spacing.cs">
|
||||
<Link>Spacing.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaAlign.cs">
|
||||
<Link>YogaAlign.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaConstants.cs">
|
||||
<Link>YogaConstants.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaDimension.cs">
|
||||
<Link>YogaDimension.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaDirection.cs">
|
||||
<Link>YogaDirection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaEdge.cs">
|
||||
<Link>YogaEdge.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaExperimentalFeature.cs">
|
||||
<Link>YogaExperimentalFeature.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaFlexDirection.cs">
|
||||
<Link>YogaFlexDirection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaJustify.cs">
|
||||
<Link>YogaJustify.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaLogger.cs">
|
||||
<Link>YogaLogger.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaLogLevel.cs">
|
||||
<Link>YogaLogLevel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaMeasureFunc.cs">
|
||||
<Link>YogaMeasureFunc.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaMeasureMode.cs">
|
||||
<Link>YogaMeasureMode.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaNode.Create.cs">
|
||||
<Link>YogaNode.Create.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaNode.cs">
|
||||
<Link>YogaNode.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaOverflow.cs">
|
||||
<Link>YogaOverflow.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaPositionType.cs">
|
||||
<Link>YogaPositionType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaPrintOptions.cs">
|
||||
<Link>YogaPrintOptions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaSize.cs">
|
||||
<Link>YogaSize.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\YogaWrap.cs">
|
||||
<Link>YogaWrap.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="CustomBuildAction.targets" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<NativeReference Include="libyoga.a">
|
||||
<Kind>Static</Kind>
|
||||
<SmartLink>False</SmartLink>
|
||||
</NativeReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />
|
||||
<Import Project="CustomBuildAction.targets" />
|
||||
</Project>
|
43
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.sln
Normal file
43
csharp/Facebook.Yoga/ios/Facebook.Yoga.iOS.sln
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.iOS", "Facebook.Yoga.iOS.csproj", "{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.iOS.Test", "Facebook.Yoga.iOS.Test\Facebook.Yoga.iOS.Test.csproj", "{3B27656A-129D-4779-BDAD-1A088DFDD9C5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||
Release|iPhone = Release|iPhone
|
||||
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||
Debug|iPhone = Debug|iPhone
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{BE4CBFDA-02E2-4DF0-A81A-CEFB7987A708}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Release|Any CPU.ActiveCfg = Release|iPhone
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Release|Any CPU.Build.0 = Release|iPhone
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{3B27656A-129D-4779-BDAD-1A088DFDD9C5}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
EndGlobalSection
|
||||
EndGlobal
|
34
csharp/Facebook.Yoga/ios/Properties/AssemblyInfo.cs
Normal file
34
csharp/Facebook.Yoga/ios/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using Foundation;
|
||||
|
||||
// This attribute allows you to mark your assemblies as “safe to link”.
|
||||
// When the attribute is present, the linker—if enabled—will process the assembly
|
||||
// even if you’re using the “Link SDK assemblies only” option, which is the default for device builds.
|
||||
|
||||
[assembly: LinkerSafe]
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("Facebook.Yoga.iOS")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("rmarinho")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
Reference in New Issue
Block a user