Added support for “ViewRepresentable” on iOS

This commit is contained in:
Jon Lipsky 2019-07-11 11:11:38 -05:00
Родитель 1ec2f80f02
Коммит 524fd5a388
11 изменённых файлов: 237 добавлений и 72 удалений

136
HotUI.sln
Просмотреть файл

@ -37,15 +37,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotUI.Android", "src\HotUI.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{586C3CCB-82A5-47F0-A099-B9A31BB4EA88}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotUI.Tests", "tests\HotUI.Tests\HotUI.Tests.csproj", "{EA098E78-E56C-43B2-9D78-D4565EC04D09}"
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "HotUI.UWP.Sample", "sample\HotUI.UWP.Sample\HotUI.UWP.Sample.csproj", "{FF9663EE-49AF-41D8-A25F-1C56C67274D3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotUI.UWP.Sample", "sample\HotUI.UWP.Sample\HotUI.UWP.Sample.csproj", "{35664234-EB75-47BA-A082-9F96BDF6FC92}"
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "HotUI.WPF.Sample", "sample\HotUI.WPF.Sample\HotUI.WPF.Sample.csproj", "{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotUI.WPF.Sample", "sample\HotUI.WPF.Sample\HotUI.WPF.Sample.csproj", "{0FC87DE5-B5E5-4846-894B-824497118143}"
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "HotUI.UWP", "src\HotUI.UWP\HotUI.UWP.csproj", "{8BC94226-339B-4183-9AC2-EB3FD0D5D811}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotUI.UWP", "src\HotUI.UWP\HotUI.UWP.csproj", "{2D337300-B3E9-4A36-8387-76A9A1100C5B}"
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "HotUI.WPF", "src\HotUI.WPF\HotUI.WPF.csproj", "{425DF4F6-3C01-4B6A-A678-701F36919C4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotUI.WPF", "src\HotUI.WPF\HotUI.WPF.csproj", "{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}"
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "HotUI.Tests", "tests\HotUI.Tests\HotUI.Tests.csproj", "{EDC997D0-2358-416F-A628-5DFD85728060}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -214,64 +214,64 @@ Global
{1E8FBBC2-9E06-4960-A116-65CDEFEFE11D}.Release|iPhone.Build.0 = Release|Any CPU
{1E8FBBC2-9E06-4960-A116-65CDEFEFE11D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{1E8FBBC2-9E06-4960-A116-65CDEFEFE11D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Debug|iPhone.Build.0 = Debug|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Release|Any CPU.Build.0 = Debug|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Release|iPhone.ActiveCfg = Release|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Release|iPhone.Build.0 = Release|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{EA098E78-E56C-43B2-9D78-D4565EC04D09}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Debug|iPhone.Build.0 = Debug|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Release|Any CPU.Build.0 = Debug|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Release|iPhone.ActiveCfg = Release|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Release|iPhone.Build.0 = Release|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Debug|Any CPU.ActiveCfg = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Debug|Any CPU.Build.0 = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Debug|Any CPU.Deploy.0 = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Debug|iPhone.ActiveCfg = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Debug|iPhone.Build.0 = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Debug|iPhoneSimulator.ActiveCfg = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Release|Any CPU.ActiveCfg = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Release|Any CPU.Build.0 = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Release|Any CPU.Deploy.0 = Debug|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Release|iPhone.ActiveCfg = Release|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Release|iPhone.Build.0 = Release|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Release|iPhoneSimulator.ActiveCfg = Release|x86
{35664234-EB75-47BA-A082-9F96BDF6FC92}.Release|iPhoneSimulator.Build.0 = Release|x86
{0FC87DE5-B5E5-4846-894B-824497118143}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Debug|iPhone.Build.0 = Debug|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Release|Any CPU.Build.0 = Debug|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Release|iPhone.ActiveCfg = Release|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Release|iPhone.Build.0 = Release|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{0FC87DE5-B5E5-4846-894B-824497118143}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Debug|iPhone.Build.0 = Debug|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Release|Any CPU.Build.0 = Debug|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Release|iPhone.ActiveCfg = Release|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Release|iPhone.Build.0 = Release|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{2D337300-B3E9-4A36-8387-76A9A1100C5B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Debug|Any CPU.ActiveCfg = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Debug|Any CPU.Build.0 = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Debug|Any CPU.Deploy.0 = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Debug|iPhone.ActiveCfg = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Debug|iPhone.Build.0 = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Debug|iPhoneSimulator.ActiveCfg = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Release|Any CPU.ActiveCfg = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Release|Any CPU.Build.0 = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Release|Any CPU.Deploy.0 = Debug|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Release|iPhone.ActiveCfg = Release|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Release|iPhone.Build.0 = Release|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Release|iPhoneSimulator.ActiveCfg = Release|x86
{FF9663EE-49AF-41D8-A25F-1C56C67274D3}.Release|iPhoneSimulator.Build.0 = Release|x86
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Debug|iPhone.Build.0 = Debug|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Release|Any CPU.Build.0 = Debug|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Release|iPhone.ActiveCfg = Release|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Release|iPhone.Build.0 = Release|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Debug|iPhone.Build.0 = Debug|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Release|Any CPU.Build.0 = Debug|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Release|iPhone.ActiveCfg = Release|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Release|iPhone.Build.0 = Release|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{8BC94226-339B-4183-9AC2-EB3FD0D5D811}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Debug|iPhone.Build.0 = Debug|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Release|Any CPU.Build.0 = Debug|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Release|iPhone.ActiveCfg = Release|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Release|iPhone.Build.0 = Release|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{425DF4F6-3C01-4B6A-A678-701F36919C4D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Debug|iPhone.Build.0 = Debug|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Release|Any CPU.Build.0 = Debug|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Release|iPhone.ActiveCfg = Release|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Release|iPhone.Build.0 = Release|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{EDC997D0-2358-416F-A628-5DFD85728060}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -290,11 +290,11 @@ Global
{6F6832FA-2E11-4324-B336-5673DFE15862} = {C3FDCDB7-0C29-472D-A406-E2F21A4B0EAE}
{BCAF5569-30DB-4D44-BF46-DFFE93DDCBD0} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
{1E8FBBC2-9E06-4960-A116-65CDEFEFE11D} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
{EA098E78-E56C-43B2-9D78-D4565EC04D09} = {586C3CCB-82A5-47F0-A099-B9A31BB4EA88}
{35664234-EB75-47BA-A082-9F96BDF6FC92} = {C3FDCDB7-0C29-472D-A406-E2F21A4B0EAE}
{0FC87DE5-B5E5-4846-894B-824497118143} = {C3FDCDB7-0C29-472D-A406-E2F21A4B0EAE}
{2D337300-B3E9-4A36-8387-76A9A1100C5B} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
{FF9663EE-49AF-41D8-A25F-1C56C67274D3} = {C3FDCDB7-0C29-472D-A406-E2F21A4B0EAE}
{5ACE2391-4864-4EE7-80D8-F7464C6F2D24} = {C3FDCDB7-0C29-472D-A406-E2F21A4B0EAE}
{8BC94226-339B-4183-9AC2-EB3FD0D5D811} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
{425DF4F6-3C01-4B6A-A678-701F36919C4D} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
{EDC997D0-2358-416F-A628-5DFD85728060} = {586C3CCB-82A5-47F0-A099-B9A31BB4EA88}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0653DB4A-5BBE-4D78-99B2-DB1C82663246}

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

@ -30,7 +30,7 @@ namespace HotUI.Samples.Comparisons
new Image("turtlerock.jpg")
.ClipShape(new Circle())
.Overlay(new Circle().Stroke(Color.White, lineWidth: 4))
.Shadow(radius: 10)
//.Shadow(radius: 10)
};
}
}

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

@ -32,8 +32,11 @@ namespace HotUI.Samples {
new MenuItem("SwiftUI Tutorial Section 4b", ()=> new Section4b()),
new MenuItem("SwiftUI Tutorial Section 4c", ()=> new Section4c()),
};
public MainPage ()
public MainPage (List<MenuItem> additionalPage = null)
{
if (additionalPage != null)
pages.AddRange(additionalPage);
Body = () => new NavigationView {
new ListView<MenuItem> (pages) {
Cell = (page) => new NavigationButton (page.Title,page.Page),

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

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using CoreLocation;
using Foundation;
using HotUI.Samples;
using MapKit;
using UIKit;
namespace HotUI.iOS.Sample {
@ -31,7 +34,11 @@ namespace HotUI.iOS.Sample {
"turtlerock.jpg".LoadImage();
window = new UIWindow {
RootViewController = new MainPage ().ToViewController (),
RootViewController = new MainPage (new List<MenuItem>
{
new MenuItem("SwiftUI Tutorial Section 5 (Native)", () => new Section5Native()),
new MenuItem("SwiftUI Tutorial Section 5b (Native)", () => new Section5NativeB())
}).ToViewController (),
};
window.MakeKeyAndVisible ();
@ -69,5 +76,48 @@ namespace HotUI.iOS.Sample {
// Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
}
}
public class Section5Native : View
{
public Section5Native()
{
Body = () => new VStack
{
new ViewRepresentable()
{
MakeView = () => new MKMapView(UIScreen.MainScreen.Bounds),
UpdateView = (view, data) =>
{
var mapView = (MKMapView)view;
var coordinate = new CLLocationCoordinate2D(latitude: 34.011286, longitude: -116.166868);
var span = new MKCoordinateSpan(latitudeDelta: 2.0, longitudeDelta: 2.0);
var region = new MKCoordinateRegion(center: coordinate, span: span);
mapView.SetRegion(region, animated: true);
}
}
};
}
}
public class Section5NativeB : View
{
public Section5NativeB()
{
Body = () => new VStack
{
new UIViewRepresentable<MKMapView>()
{
MakeView = () => new MKMapView(UIScreen.MainScreen.Bounds),
UpdateView = (view, data) =>
{
var coordinate = new CLLocationCoordinate2D(latitude: 34.011286, longitude: -116.166868);
var span = new MKCoordinateSpan(latitudeDelta: 2.0, longitudeDelta: 2.0);
var region = new MKCoordinateRegion(center: coordinate, span: span);
view.SetRegion(region, animated: true);
}
}
};
}
}
}

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

@ -137,6 +137,7 @@
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="Section5Native.cs" Condition=" '$(EnableDefaultCompileItems)' == 'true' " />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\HotUI\HotUI.csproj">

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

@ -7,7 +7,7 @@ namespace HotUI.iOS.Sample {
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main (args, null, "AppDelegate");
UIApplication.Main (args, null, "AppDelegate");
}
}
}

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

@ -0,0 +1,32 @@
using System;
using UIKit;
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable MemberCanBePrivate.Global
namespace HotUI.iOS
{
public class ViewRepresentableHandler : AbstractHandler<ViewRepresentable, UIView>
{
public static readonly PropertyMapper<ViewRepresentable> Mapper = new PropertyMapper<ViewRepresentable>(ViewHandler.Mapper)
{
[nameof(ViewRepresentable.Data)] = MapDataProperty
};
public ViewRepresentableHandler() : base(Mapper)
{
}
protected override UIView CreateView()
{
return VirtualView?.MakeView() as UIView;
}
public static void MapDataProperty(IViewHandler viewHandler, ViewRepresentable virtualView)
{
var data = virtualView.Data;
virtualView.UpdateView?.Invoke(viewHandler.NativeView, data);
}
}
}

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

@ -73,6 +73,8 @@
<Compile Include="ViewChangedEventArgs.cs" />
<Compile Include="Handlers\ShapeViewHandler.cs" />
<Compile Include="Controls\HUIShapeView.cs" />
<Compile Include="Handlers\ViewRepresentableHandler.cs" />
<Compile Include="UIViewRepresentable.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HotUI\HotUI.csproj">

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

@ -28,6 +28,7 @@ namespace HotUI.iOS {
Registrar.Handlers.Register<ContentView, ContentViewHandler> ();
Registrar.Handlers.Register<Spacer, SpacerHandler>();
Registrar.Handlers.Register<ShapeView, ShapeViewHandler>();
Registrar.Handlers.Register<ViewRepresentable, ViewRepresentableHandler>();
ModalView.PerformPresent = (o) => {
PresentingViewController.PresentViewController (o.ToViewController(), true,null);

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

@ -0,0 +1,22 @@
using System;
using UIKit;
namespace HotUI.iOS
{
public class UIViewRepresentable<T> : ViewRepresentable where T:UIView
{
public delegate void UpdateUIView(T view, object state);
public new Func<UIView> MakeView
{
get => () => base.MakeView?.Invoke() as T;
set => base.MakeView = () => value?.Invoke();
}
public new UpdateUIView UpdateView
{
get => (view, state) => base.UpdateView?.Invoke(view, state);
set => base.UpdateView = (view, state) => value?.Invoke(view as T, state);
}
}
}

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

@ -0,0 +1,54 @@
using System;
namespace HotUI
{
public delegate void UpdateView(object view, object state);
public class ViewRepresentable : View
{
public ViewRepresentable()
{
}
public ViewRepresentable(object data) : base (true)
{
Data = data;
}
public ViewRepresentable(Func<object> dataBuilder)
{
DataBinding = dataBuilder;
}
public Func<object> MakeView { get; set; }
public UpdateView UpdateView { get; set; }
private object context;
public object Data
{
get => context;
private set => (this).SetValue(base.State, ref context, value, base.ViewPropertyChanged);
}
public Func<object> DataBinding { get; private set; }
protected override void WillUpdateView ()
{
base.WillUpdateView ();
if (DataBinding != null)
{
base.State.StartProperty ();
var text = DataBinding.Invoke ();
var props = base.State.EndProperty ();
var propCount = props.Length;
if (propCount > 0)
{
base.State.BindingState.AddViewProperty (props, (s, o) => Data = DataBinding.Invoke ());
}
Data = text;
}
}
}
}