зеркало из https://github.com/jsuarezruiz/HotUI.git
Mac/iOS Additions
This commit is contained in:
Родитель
d2e129b602
Коммит
87742eac9b
28
HotUI.sln
28
HotUI.sln
|
@ -47,7 +47,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotUI.Tests", "tests\HotUI.
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotUI.Skia", "src\HotUI.Skia\HotUI.Skia.csproj", "{BF15264B-D7C7-4F09-B13B-487D60D649BD}"
|
||||
EndProject
|
||||
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "HotUI.WPF", "src\HotUI.WPF\HotUI.WPF.csproj", "{3736E3D3-64BC-4729-8DDC-93276CBB5B08}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotUI.WPF", "src\HotUI.WPF\HotUI.WPF.csproj", "{F8BA5DE0-AEC0-4423-B036-5F9157E939D0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -321,18 +321,18 @@ Global
|
|||
{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
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08}.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}.Debug|iPhoneSimulator.Build.0 = 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
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -356,7 +356,7 @@ Global
|
|||
{2D337300-B3E9-4A36-8387-76A9A1100C5B} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
|
||||
{EDC997D0-2358-416F-A628-5DFD85728060} = {586C3CCB-82A5-47F0-A099-B9A31BB4EA88}
|
||||
{9ACC68A5-5A5C-409D-A379-D62220A9F49F} = {D83B3108-A837-4D1C-B66D-C4B15037BBFB}
|
||||
{3736E3D3-64BC-4729-8DDC-93276CBB5B08} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
|
||||
{F8BA5DE0-AEC0-4423-B036-5F9157E939D0} = {AB9AD206-4B1E-4B0C-88A2-5C769314E8A4}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0653DB4A-5BBE-4D78-99B2-DB1C82663246}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace HotUI.Samples
|
|||
|
||||
[Body]
|
||||
View body() => new VStack {
|
||||
new Text("AspectFill"),
|
||||
new Text("None"),
|
||||
new Image("turtlerock.jpg")
|
||||
.ClipShape(new Path(PuzzlePiece,PathScaling.None))
|
||||
.Overlay(new Rectangle().Stroke(Color.Blue, lineWidth: 1))
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace HotUI.Samples {
|
|||
new MenuItem("SecureFieldSample1", ()=> new SecureFieldSample1()),
|
||||
new MenuItem("SecureFieldSample2", ()=> new SecureFieldSample2()),
|
||||
new MenuItem("SecureFieldSample3", ()=> new SecureFieldSample3()),
|
||||
new MenuItem("ShapeSample1", ()=> new ShapeSample1()),
|
||||
new MenuItem("SliderSample1", ()=> new SliderSample1()),
|
||||
new MenuItem("TextFieldSample1", ()=> new TextFieldSample1()),
|
||||
new MenuItem("TextFieldSample2", ()=> new TextFieldSample2()),
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace HotUI.Samples
|
||||
{
|
||||
public class ShapeSample1 : View
|
||||
{
|
||||
private static readonly string PuzzlePiece = "M19.99792 22.13909 C19.99792 22.13909 47.86481 28.87755 49.04228 23.53727 C50.19575 18.30595 44.05524 17.74318 43.54738 11.65272 C43.0568 5.768704 47.91793 -0.09640692 56.49963 0.001201655 C65.03629 0.09829985 69.88357 5.380321 70.23681 11.26433 C70.70629 19.08429 64.00743 19.07113 66.15493 23.53727 C68.47058 28.35323 94.21521 22.23512 97.55423 26.25595 C101.2632 30.72237 100.5764 43.05355 96.69075 49.17059 C92.80509 55.28766 89.80248 46.60727 83.97403 48.00547 C78.14549 49.40363 78.51836 53.65646 78.87164 59.42395 C79.22488 65.19144 79.95097 68.25968 85.77946 69.13351 C91.60799 70.00739 94.49277 58.8802 96.69075 64.08453 C98.88867 69.28887 99.12417 90.30046 94.5713 95.77667 C90.39147 100.8041 65.07446 101.7156 63.95695 96.47578 C62.68137 90.49467 69.02008 92.63074 68.66684 87.38759 C68.3136 82.14436 62.0141 79.87233 55.47915 78.99846 C48.94418 78.12459 44.82301 78.64893 42.52691 83.8921 C40.23085 89.13531 48.45356 91.38793 46.68734 96.47578 C44.82262 101.8474 15.44503 96.47578 15.44503 96.47578 C15.44503 96.47578 22.30525 68.48328 15.91602 64.86131 C10.12676 61.57945 9.714652 69.26945 4.062778 66.64789 C-1.5891 64.02629 -0.07800946 57.98692 1.15834 52.04465 C2.394689 46.10238 5.970265 42.56891 10.18563 42.87878 C13.61994 43.13125 20.97916 53.19039 22.74536 49.17059 C24.51158 45.15082 19.99792 22.13909 19.99792 22.13909 Z ";
|
||||
|
||||
[Body]
|
||||
View body() => new VStack
|
||||
{
|
||||
new ShapeView(new Circle().Stroke(Color.Blue, 2)).Frame(100,60),
|
||||
new ShapeView(new Rectangle().Stroke(Color.Magenta, 2)).Frame(100,60),
|
||||
new ShapeView(new RoundedRectangle(6).Stroke(Color.Purple, 2)).Frame(100,60),
|
||||
new ShapeView(new Capsule().Stroke(Color.Orange, 2)).Frame(100,30),
|
||||
new ShapeView(new Ellipse().Stroke(Color.Green, 2)).Frame(100,60),
|
||||
new ShapeView(new Path(PuzzlePiece).Stroke(Color.Red, 2)).Frame(60,60),
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using CoreGraphics;
|
||||
using AppKit;
|
||||
using HotUI.Mac.Extensions;
|
||||
|
||||
namespace HotUI.Mac
|
||||
{
|
||||
public class HUIShapeView : NSView
|
||||
{
|
||||
public HUIShapeView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Shape Shape
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public override void DrawRect(CGRect rect)
|
||||
{
|
||||
var context = NSGraphicsContext.CurrentContext.GraphicsPort;
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
var stroke = Shape.GetStroke(1);
|
||||
var color = Shape.GetColor(Color.Black);
|
||||
|
||||
context.SetLineWidth(stroke);
|
||||
context.SetStrokeColor(color.ToCGColor());
|
||||
|
||||
var shapeBounds = new RectangleF(
|
||||
(float)rect.X + (stroke / 2),
|
||||
(float)rect.Y + (stroke / 2),
|
||||
(float)rect.Width - stroke,
|
||||
(float)rect.Height - stroke);
|
||||
|
||||
var path = Shape.PathForBounds(shapeBounds);
|
||||
context.AddPath(path.ToCGPath());
|
||||
context.StrokePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ namespace HotUI.Mac.Extensions
|
|||
: Font.Custom(font.FamilyName, (float)font.PointSize);
|
||||
}
|
||||
|
||||
public static NSFont ToUIFont(this Font font)
|
||||
public static NSFont ToNSFont(this Font font)
|
||||
{
|
||||
if (font == null)
|
||||
return NSFont.SystemFontOfSize(12);
|
||||
|
|
|
@ -36,11 +36,11 @@ namespace HotUI.Mac.Handlers
|
|||
|
||||
private void HandleTouchUpInside(object sender, EventArgs e) => VirtualView?.OnClick();
|
||||
|
||||
public static void MapTextProperty(IViewHandler viewHandler, Button virtualButton)
|
||||
public static void MapTextProperty(IViewHandler viewHandler, Button virtualView)
|
||||
{
|
||||
var nativeButton = (NSButton) viewHandler.NativeView;
|
||||
nativeButton.Title = virtualButton.Text;
|
||||
nativeButton.SizeToFit();
|
||||
nativeButton.Title = virtualView.Text;
|
||||
virtualView.InvalidateMeasurement();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using AppKit;
|
||||
|
||||
namespace HotUI.Mac.Handlers
|
||||
{
|
||||
public class SecureFieldHandler : AbstractControlHandler<TextField, NSSecureTextField>
|
||||
{
|
||||
public static readonly PropertyMapper<TextField> Mapper = new PropertyMapper<TextField>(ViewHandler.Mapper)
|
||||
{
|
||||
[nameof(TextField.Text)] = MapTextProperty
|
||||
};
|
||||
|
||||
public SecureFieldHandler() : base(Mapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override NSSecureTextField CreateView()
|
||||
{
|
||||
var textField = new NSSecureTextField();
|
||||
textField.EditingEnded += HandleEditingEnded;
|
||||
textField.Changed += HandleEditingChanged;
|
||||
return textField;
|
||||
}
|
||||
|
||||
protected override void DisposeView(NSSecureTextField nativeView)
|
||||
{
|
||||
nativeView.EditingEnded -= HandleEditingEnded;
|
||||
nativeView.Changed -= HandleEditingChanged;
|
||||
}
|
||||
|
||||
private void HandleEditingChanged(object sender, EventArgs e)
|
||||
{
|
||||
VirtualView?.OnEditingChanged?.Invoke(TypedNativeView.StringValue);
|
||||
}
|
||||
|
||||
void HandleEditingEnded(object sender, EventArgs e)
|
||||
{
|
||||
VirtualView?.OnCommit?.Invoke(TypedNativeView.StringValue);
|
||||
}
|
||||
|
||||
public static void MapTextProperty(IViewHandler viewHandler, TextField virtualView)
|
||||
{
|
||||
var nativeView = (NSSecureTextField) viewHandler.NativeView;
|
||||
nativeView.StringValue = virtualView.Text;
|
||||
virtualView.InvalidateMeasurement();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
namespace HotUI.Mac.Handlers
|
||||
{
|
||||
public class ShapeViewHandler : AbstractControlHandler<ShapeView, HUIShapeView>
|
||||
{
|
||||
public static readonly PropertyMapper<ShapeView> Mapper = new PropertyMapper<ShapeView>(ViewHandler.Mapper)
|
||||
{
|
||||
[nameof(HotUI.ShapeView.Shape)] = MapShapeProperty,
|
||||
};
|
||||
|
||||
|
||||
public ShapeViewHandler() : base(Mapper)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override HUIShapeView CreateView() => new HUIShapeView();
|
||||
|
||||
protected override void DisposeView(HUIShapeView nativeView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void MapShapeProperty(IViewHandler viewHandler, ShapeView virtualView)
|
||||
{
|
||||
var nativeView = (HUIShapeView) viewHandler.NativeView;
|
||||
nativeView.Shape = virtualView.Shape;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using AppKit;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
|
||||
namespace HotUI.Mac.Handlers
|
||||
{
|
||||
public class SliderHandler : AbstractControlHandler<Slider, NSSlider>
|
||||
{
|
||||
public static readonly PropertyMapper<Slider> Mapper = new PropertyMapper<Slider>(ViewHandler.Mapper)
|
||||
{
|
||||
[nameof(Slider.Value)] = MapValueProperty,
|
||||
[nameof(Slider.From)] = MapFromProperty,
|
||||
[nameof(Slider.Through)] = MapThroughProperty,
|
||||
};
|
||||
|
||||
public SliderHandler() : base(Mapper)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override NSSlider CreateView()
|
||||
{
|
||||
var slider = new NSSlider();
|
||||
slider.Continuous = true;
|
||||
slider.Activated += HandleValueChanged;
|
||||
return slider;
|
||||
}
|
||||
|
||||
protected override void DisposeView(NSSlider nativeView)
|
||||
{
|
||||
nativeView.Activated -= HandleValueChanged;
|
||||
}
|
||||
|
||||
private void HandleValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
VirtualView?.OnEditingChanged?.Invoke(TypedNativeView.FloatValue);
|
||||
}
|
||||
|
||||
public static void MapValueProperty(IViewHandler viewHandler, Slider virtualView)
|
||||
{
|
||||
var nativeView = (NSSlider) viewHandler.NativeView;
|
||||
nativeView.FloatValue = virtualView.Value;
|
||||
}
|
||||
|
||||
public static void MapFromProperty(IViewHandler viewHandler, Slider virtualView)
|
||||
{
|
||||
var nativeView = (NSSlider) viewHandler.NativeView;
|
||||
nativeView.MinValue = virtualView.From;
|
||||
}
|
||||
|
||||
public static void MapThroughProperty(IViewHandler viewHandler, Slider virtualView)
|
||||
{
|
||||
var nativeView = (NSSlider) viewHandler.NativeView;
|
||||
nativeView.MaxValue = virtualView.Through;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,8 +41,8 @@ namespace HotUI.Mac.Handlers
|
|||
public static void MapTextProperty(IViewHandler viewHandler, TextField virtualView)
|
||||
{
|
||||
var nativeView = (NSTextField) viewHandler.NativeView;
|
||||
nativeView.StringValue = virtualView.Text;
|
||||
nativeView.SizeToFit();
|
||||
nativeView.StringValue = virtualView.Text ?? "";
|
||||
virtualView.InvalidateMeasurement();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,15 +46,15 @@ namespace HotUI.Mac.Handlers
|
|||
{
|
||||
var nativeView = (NSTextField) viewHandler.NativeView;
|
||||
nativeView.StringValue = virtualView.Value;
|
||||
nativeView.SizeToFit();
|
||||
virtualView.InvalidateMeasurement();
|
||||
}
|
||||
|
||||
public static void MapFontProperty(IViewHandler viewHandler, Text virtualView)
|
||||
{
|
||||
var nativeView = (NSTextField) viewHandler.NativeView;
|
||||
var font = virtualView.GetFont(DefaultFont);
|
||||
nativeView.Font = font.ToUIFont();
|
||||
nativeView.SizeToFit();
|
||||
nativeView.Font = font.ToNSFont();
|
||||
virtualView.InvalidateMeasurement();
|
||||
}
|
||||
|
||||
public static void MapColorProperty(IViewHandler viewHandler, Text virtualView)
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using AppKit;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
namespace HotUI.Mac.Handlers
|
||||
{
|
||||
public class ToggleHandler : AbstractControlHandler<Toggle, NSButton>
|
||||
{
|
||||
public static readonly PropertyMapper<Toggle> Mapper = new PropertyMapper<Toggle> (ViewHandler.Mapper)
|
||||
{
|
||||
[nameof(Toggle.IsOn)] = MapIsOnProperty
|
||||
};
|
||||
|
||||
public ToggleHandler() : base(Mapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override NSButton CreateView()
|
||||
{
|
||||
var toggle = new NSButton();
|
||||
toggle.SetButtonType(NSButtonType.Switch);
|
||||
toggle.Activated += HandleValueChanged;
|
||||
return toggle;
|
||||
}
|
||||
|
||||
protected override void DisposeView(NSButton toggle)
|
||||
{
|
||||
toggle.Activated -= HandleValueChanged;
|
||||
}
|
||||
|
||||
void HandleValueChanged(object sender, EventArgs e) => VirtualView?.IsOnChanged?.Invoke(TypedNativeView.State == NSCellStateValue.On);
|
||||
|
||||
public static void MapIsOnProperty(IViewHandler viewHandler, Toggle virtualView)
|
||||
{
|
||||
var nativeView = (NSButton) viewHandler.NativeView;
|
||||
nativeView.State = virtualView.IsOn ? NSCellStateValue.On : NSCellStateValue.Off;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
using AppKit;
|
||||
using CoreGraphics;
|
||||
using HotUI.Layout;
|
||||
using CoreGraphics;
|
||||
|
||||
namespace HotUI.Mac.Handlers
|
||||
{
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
using CoreGraphics;
|
||||
|
||||
namespace HotUI.Mac.Handlers
|
||||
{
|
||||
public class ZStackHandler : AbstractLayoutHandler
|
||||
{
|
||||
public ZStackHandler(CGRect rect) : base(rect)
|
||||
{
|
||||
}
|
||||
|
||||
public ZStackHandler()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -94,6 +94,12 @@
|
|||
<Compile Include="UIViewRepresentable.cs" />
|
||||
<Compile Include="Handlers\ViewRepresentableHandler.cs" />
|
||||
<Compile Include="ViewChangedEventArgs.cs" />
|
||||
<Compile Include="Handlers\SliderHandler.cs" />
|
||||
<Compile Include="Handlers\ZStackHandler.cs" />
|
||||
<Compile Include="Handlers\SecureFieldHandler.cs" />
|
||||
<Compile Include="Handlers\ToggleHandler.cs" />
|
||||
<Compile Include="Handlers\ShapeViewHandler.cs" />
|
||||
<Compile Include="Controls\HUIShapeView.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HotUI\HotUI.csproj">
|
||||
|
|
|
@ -6,29 +6,40 @@ namespace HotUI.Mac
|
|||
{
|
||||
public static class UI
|
||||
{
|
||||
|
||||
static NSObject invoker = new NSObject ();
|
||||
static bool hasInit;
|
||||
static bool _hasInitialized;
|
||||
static NSObject _invoker = new NSObject ();
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if (hasInit)
|
||||
return;
|
||||
hasInit = true;
|
||||
if (_hasInitialized) return;
|
||||
_hasInitialized = true;
|
||||
|
||||
// Controls
|
||||
Registrar.Handlers.Register<Button, ButtonHandler>();
|
||||
Registrar.Handlers.Register<Image, ImageHandler>();
|
||||
Registrar.Handlers.Register<TextField, TextFieldHandler>();
|
||||
Registrar.Handlers.Register<Text, TextHandler>();
|
||||
Registrar.Handlers.Register<VStack, VStackHandler>();
|
||||
Registrar.Handlers.Register<HStack, HStackHandler>();
|
||||
Registrar.Handlers.Register<SecureField, SecureFieldHandler>();
|
||||
Registrar.Handlers.Register<Slider, SliderHandler>();
|
||||
Registrar.Handlers.Register<ShapeView, ShapeViewHandler>();
|
||||
Registrar.Handlers.Register<Toggle, ToggleHandler>();
|
||||
//Registrar.Handlers.Register<WebView, WebViewHandler> ();
|
||||
|
||||
// Containers
|
||||
Registrar.Handlers.Register<ScrollView, ScrollViewHandler>();
|
||||
Registrar.Handlers.Register<Image, ImageHandler> ();
|
||||
Registrar.Handlers.Register<View, ViewHandler> ();
|
||||
Registrar.Handlers.Register<ContentView, ContentViewHandler> ();
|
||||
Registrar.Handlers.Register<ListView, ListViewHandler>();
|
||||
Registrar.Handlers.Register<ViewRepresentable, ViewRepresentableHandler>();
|
||||
|
||||
Device.PerformInvokeOnMainThread = invoker.BeginInvokeOnMainThread;
|
||||
// Managed Layout
|
||||
Registrar.Handlers.Register<HStack, HStackHandler>();
|
||||
Registrar.Handlers.Register<VStack, VStackHandler>();
|
||||
Registrar.Handlers.Register<ZStack, ZStackHandler>();
|
||||
Registrar.Handlers.Register<Spacer, SpacerHandler>();
|
||||
|
||||
// Device Features
|
||||
Device.PerformInvokeOnMainThread = _invoker.BeginInvokeOnMainThread;
|
||||
Device.FontService = new MacFontService();
|
||||
Device.GraphicsService = new MacGraphicsService();
|
||||
}
|
||||
|
|
|
@ -49,14 +49,14 @@ namespace HotUI.iOS.Handlers
|
|||
{
|
||||
var nativeView = (UITextField) viewHandler.NativeView;
|
||||
nativeView.Text = virtualView.Text;
|
||||
nativeView.SizeToFit();
|
||||
virtualView.InvalidateMeasurement();
|
||||
}
|
||||
|
||||
|
||||
public static void MapPlaceholderProperty(IViewHandler viewHandler, SecureField virtualView)
|
||||
{
|
||||
var nativeView = (UITextField) viewHandler.NativeView;
|
||||
nativeView.Placeholder = virtualView.Placeholder;
|
||||
nativeView.SizeToFit();
|
||||
virtualView.InvalidateMeasurement();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,9 +42,8 @@ namespace HotUI.iOS.Handlers
|
|||
{
|
||||
var nativeView = (UISlider) viewHandler.NativeView;
|
||||
nativeView.Value = virtualView.Value;
|
||||
nativeView.SizeToFit();
|
||||
}
|
||||
|
||||
|
||||
public static void MapFromProperty(IViewHandler viewHandler, Slider virtualView)
|
||||
{
|
||||
var nativeView = (UISlider) viewHandler.NativeView;
|
||||
|
|
|
@ -13,11 +13,5 @@ namespace HotUI.iOS.Handlers
|
|||
public VStackHandler() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public override CGRect Frame
|
||||
{
|
||||
get => base.Frame;
|
||||
set => base.Frame = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using CoreGraphics;
|
||||
using HotUI.Layout;
|
||||
using UIKit;
|
||||
|
||||
namespace HotUI.iOS.Handlers
|
||||
{
|
||||
public class ZStackHandler : AbstractLayoutHandler
|
||||
{
|
||||
public ZStackHandler(CGRect rect) : base(rect)
|
||||
{
|
||||
}
|
||||
|
||||
public ZStackHandler() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,6 +83,7 @@
|
|||
<Compile Include="UIViewRepresentable.cs" />
|
||||
<Compile Include="Controls\HUINavigationController.cs" />
|
||||
<Compile Include="Controls\HUITableViewSource.cs" />
|
||||
<Compile Include="Handlers\ZStackHandler.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HotUI\HotUI.csproj">
|
||||
|
|
|
@ -6,38 +6,50 @@ using HotUI.iOS.Handlers;
|
|||
using HotUI.iOS.Services;
|
||||
using UIKit;
|
||||
|
||||
namespace HotUI.iOS {
|
||||
public static class UI {
|
||||
static bool hasInit;
|
||||
static NSObject invoker = new NSObject ();
|
||||
namespace HotUI.iOS
|
||||
{
|
||||
public static class UI
|
||||
{
|
||||
static bool _hasInitialized;
|
||||
static NSObject _invoker = new NSObject ();
|
||||
|
||||
public static void Init ()
|
||||
{
|
||||
if (hasInit)
|
||||
return;
|
||||
hasInit = true;
|
||||
Registrar.Handlers.Register<Button, ButtonHandler> ();
|
||||
Registrar.Handlers.Register<TextField, TextFieldHandler> ();
|
||||
Registrar.Handlers.Register<SecureField, SecureFieldHandler>();
|
||||
Registrar.Handlers.Register<Text, TextHandler> ();
|
||||
Registrar.Handlers.Register<Toggle, ToggleHandler>();
|
||||
Registrar.Handlers.Register<VStack, VStackHandler> ();
|
||||
Registrar.Handlers.Register<HStack, HStackHandler> ();
|
||||
//Registrar.Handlers.Register<WebView, WebViewHandler> ();
|
||||
Registrar.Handlers.Register<ScrollView, ScrollViewHandler> ();
|
||||
Registrar.Handlers.Register<Image, ImageHandler> ();
|
||||
Registrar.Handlers.Register<ListView, ListViewHandler> ();
|
||||
Registrar.Handlers.Register<View, ViewHandler> ();
|
||||
Registrar.Handlers.Register<ContentView, ContentViewHandler> ();
|
||||
Registrar.Handlers.Register<Spacer, SpacerHandler>();
|
||||
Registrar.Handlers.Register<ShapeView, ShapeViewHandler>();
|
||||
Registrar.Handlers.Register<ViewRepresentable, ViewRepresentableHandler>();
|
||||
Registrar.Handlers.Register<Slider, SliderHandler>();
|
||||
if (_hasInitialized) return;
|
||||
_hasInitialized = true;
|
||||
|
||||
// Controls
|
||||
Registrar.Handlers.Register<Button, ButtonHandler> ();
|
||||
Registrar.Handlers.Register<Image, ImageHandler>();
|
||||
Registrar.Handlers.Register<TextField, TextFieldHandler> ();
|
||||
Registrar.Handlers.Register<Text, TextHandler> ();
|
||||
Registrar.Handlers.Register<SecureField, SecureFieldHandler>();
|
||||
Registrar.Handlers.Register<Slider, SliderHandler>();
|
||||
Registrar.Handlers.Register<ShapeView, ShapeViewHandler>();
|
||||
Registrar.Handlers.Register<Toggle, ToggleHandler>();
|
||||
//Registrar.Handlers.Register<WebView, WebViewHandler> ();
|
||||
|
||||
// Containers
|
||||
Registrar.Handlers.Register<ContentView, ContentViewHandler>();
|
||||
Registrar.Handlers.Register<ListView, ListViewHandler>();
|
||||
Registrar.Handlers.Register<ScrollView, ScrollViewHandler> ();
|
||||
Registrar.Handlers.Register<View, ViewHandler> ();
|
||||
Registrar.Handlers.Register<ViewRepresentable, ViewRepresentableHandler>();
|
||||
|
||||
// Managed Layout
|
||||
Registrar.Handlers.Register<HStack, HStackHandler>();
|
||||
Registrar.Handlers.Register<VStack, VStackHandler>();
|
||||
Registrar.Handlers.Register<ZStack, ZStackHandler>();
|
||||
Registrar.Handlers.Register<Spacer, SpacerHandler>();
|
||||
|
||||
// Device Features
|
||||
ModalView.PerformPresent = (o) => {
|
||||
PresentingViewController.PresentViewController (o.ToViewController(), true,null);
|
||||
};
|
||||
ModalView.PerformDismiss = () => PresentingViewController.DismissModalViewController (true);
|
||||
Device.PerformInvokeOnMainThread = invoker.BeginInvokeOnMainThread;
|
||||
|
||||
// Device Features
|
||||
Device.PerformInvokeOnMainThread = _invoker.BeginInvokeOnMainThread;
|
||||
Device.FontService = new iOSFontService();
|
||||
Device.GraphicsService = new iOSGraphicsService();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче