Partial work on providing support for View / Cells

This commit is contained in:
Dave Thomas 2017-06-26 11:16:52 +01:00
Родитель cae790593f
Коммит 67c7ab0822
11 изменённых файлов: 99 добавлений и 82 удалений

Просмотреть файл

@ -25,6 +25,6 @@
<key>UIMainStoryboardFile~ipad</key>
<string>MainStoryboard_iPad</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.3</string>
</dict>
</plist>

Просмотреть файл

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4451" systemVersion="13A461" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--class Prefix:identifier View Controller-->
<!--Single View Universal View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="SingleViewUniversalViewController" sceneMemberID="viewController">
@ -15,36 +16,40 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="5" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5">
<rect key="frame" x="138" y="974" width="141" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="iPad Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" minimumFontSize="10" id="9" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="9">
<rect key="frame" x="663" y="974" width="42" height="21"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="13" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="13">
<rect key="frame" x="110" y="115" width="46" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<connections>
<outlet property="button1iPad" destination="13" id="name-outlet-13"/>
<outlet property="ipadButtonOne" destination="5" id="name-outlet-5"/>
<outlet property="button1" destination="13" id="name-outlet-13"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="0.0" y="0.0"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
@ -53,6 +58,6 @@
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
<resources>
<image name="Default-568h.png" width="640" height="1136"/>
<image name="Default-568h.png" width="320" height="568"/>
</resources>
</document>

Просмотреть файл

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4451" systemVersion="13A461" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--class Prefix:identifier View Controller-->
<!--Single View Universal View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="SingleViewUniversalViewController" sceneMemberID="viewController">
@ -13,46 +14,50 @@
<viewControllerLayoutGuide type="bottom" id="4"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="5" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5">
<rect key="frame" x="93" y="518" width="126" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="iPhone Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" minimumFontSize="10" id="9" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="9">
<rect key="frame" x="238" y="522" width="42" height="21"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="13" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="13">
<rect key="frame" x="39" y="53" width="46" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<connections>
<outlet property="myButton" destination="13" id="name-outlet-13"/>
<outlet property="iPhoneButtonOne" destination="5" id="name-outlet-5"/>
<outlet property="button1" destination="13" id="name-outlet-13"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="0.0" y="0.0"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
<simulatedScreenMetrics key="destination" type="retina47"/>
</simulatedMetricsContainer>
<resources>
<image name="Default-568h.png" width="640" height="1136"/>
<image name="Default-568h.png" width="320" height="568"/>
</resources>
</document>

Просмотреть файл

@ -18,7 +18,7 @@ type MyViewController (handle) =
override x.ViewDidLoad () =
base.ViewDidLoad ()
x.button1.TouchUpInside.Add(fun _ -> x.View.BackgroundColor <- UIColor.Blue)
x.myButton.TouchUpInside.Add(fun _ -> x.View.BackgroundColor <- UIColor.Blue)
// Perform any additional setup after loading the view, typically from a nib.

Просмотреть файл

@ -1,14 +1,11 @@
namespace Xamarin.UIProviders.DesignTime
open System
open System.IO
open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Quotations
open ProvidedTypes
open ExtCore.Control
open Swensen.Unquote
module Sanitise =
let cleanTrailing = String.trimEnd [|':'|]

Просмотреть файл

@ -1,9 +1,6 @@
namespace Xamarin.UIProviders.DesignTime
open System
open System.IO
open System.Xml
open System.Xml.Linq
open System.Linq
open ExtCore
open ExtCore.Control
open MonoTouch.Design
@ -19,35 +16,45 @@ module IOS =
let! destination = vc.FindById(ac.Destination) |> Option.ofObj
return {Selector=ac.Selector;ElementName= destination.Element.Name.LocalName}}
let createScene (scene : MonoTouch.Design.Scene) =
let vc = scene.ViewController
let outlets = vc.Outlets
let newOutlets =
outlets
|> Seq.choose (outletMap vc)
|> Seq.toList
let actions = maybe {
let! view = vc.View |> Option.ofObj
let! subviews = view.Subviews |> Option.ofObj
return subviews
|> Seq.collect (fun sv -> sv.Actions)
|> Seq.distinct
|> Seq.choose (actionMap vc)
|> Seq.toList } |> Option.fill List.empty
let newVc = {ViewController.XmlType = vc.Element.Name.LocalName
CustomClass = vc.CustomClass
Outlets = newOutlets
Actions = actions}
let view = Unchecked.defaultof<_>
let scene = {ViewController = newVc
View = view }
scene
let scenesFromXDoc (xdoc:XDocument) =
let idProvider = MonoTouch.Design.DefaultIdProvider()
let context = ModelObjectContext.Create(idProvider, Version(8,3,2), DeviceFamily.Undefined)
let scenes =
match Parser.Instance.Parse(xdoc.Root, DeviceFamily.Undefined) with
match Parser.Instance.Parse(xdoc.Root, DeviceFamily.Undefined, context) with
| :? Storyboard as sb -> sb.Scenes
| :? Xib as _xib -> failwith "Xib files are currently not supported"
| _ -> failwith "Could not parse file, no supported files were found"
scenes
|> Seq.map (fun scene ->
let vc = scene.ViewController
let outlets = vc.Outlets
let newOutlets =
outlets
|> Seq.choose (outletMap vc)
|> Seq.toList
let actions = maybe {
let! view = vc.View |> Option.ofObj
let! subviews = view.Subviews |> Option.ofObj
return subviews
|> Seq.collect (fun sv -> sv.Actions)
|> Seq.distinct
|> Seq.choose (actionMap vc)
|> Seq.toList } |> Option.fill List.empty
let newVc = {XmlType = vc.Element.Name.LocalName
CustomClass = vc.CustomClass
Outlets = newOutlets
Actions = actions}
let scene = {ViewController=newVc}
scene)
|> Seq.choose (fun scene ->
if String.IsNullOrWhiteSpace scene.CustomClass
then None
else Some (createScene scene))

Просмотреть файл

@ -70,7 +70,7 @@ module Mac =
|> Seq.collect (fun scene -> let vcElement = scene.Descendants(xn "viewController")
vcElement
|> Seq.choose (viewControllerMapping tryLookup)
|> Seq.map (fun vc -> {ViewController=vc}))
|> Seq.map (fun vc -> {ViewControllers=vc}))
let scenesFromStoryBoardFileName (sb:string) =
let xdoc = XDocument.Load(new StreamReader(sb, true))

Просмотреть файл

@ -17,6 +17,12 @@ type ViewController = {
CustomClass : string
Outlets: Outlet List
Actions: Action List}
type View = {
XmlType: string
CustomClass : string
Outlets: Outlet List}
type Scene = {
ViewController : ViewController }
ViewController : ViewController
View : View list }

Просмотреть файл

@ -1,9 +1,6 @@
namespace Xamarin.UIProviders.DesignTime
open System
open System.Reflection
open System.IO
open System.Xml
open System.Xml.Linq
module internal MacMappings =
let rawmap =

Просмотреть файл

@ -16,11 +16,6 @@
<ErrorReport>prompt</ErrorReport>
<PlatformTarget></PlatformTarget>
<Externalconsole>true</Externalconsole>
<CustomCommands>
<CustomCommands>
<Command type="Execute" command="../../../monodevelop/main/build/bin/MonoDevelop.exe --no-redirect" workingdir="../../../monodevelop/main/build/" />
</CustomCommands>
</CustomCommands>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
</PropertyGroup>
@ -35,6 +30,13 @@
<Tailcalls>true</Tailcalls>
<DefineConstants></DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
<StartAction>Program</StartAction>
<StartProgram>..\..\..\..\..\..\Applications\Visual Studio.app\Contents\Resources\lib\monodevelop\bin\VisualStudio.exe</StartProgram>
<StartArguments>--no-redirect</StartArguments>
<StartWorkingDirectory>..\..\..\..\..\..\Applications\Visual Studio.app\Contents\Resources\lib\monodevelop\bin\</StartWorkingDirectory>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -42,10 +44,10 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="MonoTouch.Design">
<HintPath>\Applications\Xamarin Studio.app\Contents\Resources\lib\monodevelop\AddIns\MonoDevelop.IPhone\MonoTouch.Design.dll</HintPath>
<HintPath>/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.IPhone/MonoTouch.Design.dll</HintPath>
</Reference>
<Reference Include="MonoTouch.Design.Client">
<HintPath>\Applications\Xamarin Studio.app\Contents\Resources\lib\monodevelop\AddIns\MonoDevelop.IPhone\MonoTouch.Design.Client.dll</HintPath>
<HintPath>/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.IPhone/MonoTouch.Design.Client.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="ExtCore">
@ -55,9 +57,13 @@
<HintPath>..\packages\Unquote.3.1.1\lib\net45\Unquote.dll</HintPath>
</Reference>
<Reference Include="MonoDevelop.MacDev">
<HintPath>..\..\..\md-addins\MonoDevelop.MacDev\build\MonoDevelop.MacDev.dll</HintPath>
<HintPath>/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.MacDev/MonoDevelop.MacDev.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Designer">
<HintPath>..\..\..\..\..\..\Applications\Visual Studio.app\Contents\Resources\lib\monodevelop\AddIns\Xamarin.Ide\Xamarin.Designer.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" />
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="ProvidedTypes.fsi" />
@ -73,9 +79,6 @@
<Compile Include="IOSParsing.fs" />
<Compile Include="Designtime.fs" />
<Compile Include="iOSDesignerProvider.fs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" />
<ItemGroup>
<None Include="packages.config" />
<None Include="Script.fsx" />
<None Include="Debug.fs" />

Просмотреть файл

@ -8,7 +8,6 @@ open System.Xml.Linq
open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open MonoTouch.Design
open ProvidedTypes
[<TypeProvider>]
@ -46,9 +45,8 @@ type iOSDesignerProvider(config: TypeProviderConfig) as this =
| RunTime.TVOS -> IOS.scenesFromXDoc xdoc
yield! scenes }
let groupedViewControllers =
let groupedViewControllers =
query {for scene in scenes do
where (not (String.IsNullOrWhiteSpace scene.ViewController.CustomClass))
groupValBy scene.ViewController scene.ViewController.CustomClass}
@ -57,9 +55,8 @@ type iOSDesignerProvider(config: TypeProviderConfig) as this =
let generatedTypes =
[ for sc in groupedViewControllers do
let vcs = sc.AsEnumerable()
// if not (String.IsNullOrWhiteSpace sc.ViewController.CustomClass) then
yield TypeBuilder.buildController runtimeBinding vcs isAbstract addUnitCtor register config ]
let viewControllers = sc.AsEnumerable()
yield TypeBuilder.buildController runtimeBinding viewControllers isAbstract addUnitCtor register config ]
//Add the types to the container
container.AddMembers generatedTypes