summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-09-13 09:18:59 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 04:30:51 (GMT)
commit1cacb2a4bcb238e8eb534a26ce39b86cbaa75161 (patch)
tree4e14f93aa1a98d53f817f97aa06b51a0e54b4b11 /Xamarin.Forms.Platform.iOS
parent1aefef5d2f0c61b57ab4dbe0c109f559d762fef9 (diff)
downloadxamarin-forms-1cacb2a4bcb238e8eb534a26ce39b86cbaa75161.zip
xamarin-forms-1cacb2a4bcb238e8eb534a26ce39b86cbaa75161.tar.gz
xamarin-forms-1cacb2a4bcb238e8eb534a26ce39b86cbaa75161.tar.bz2
[C, iOS, Android] LayoutCompression (#1136)
* [C, iOS, Android] LayoutCompression * fix docs * minor fixups
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/RendererPool.cs12
-rw-r--r--Xamarin.Forms.Platform.iOS/VisualElementPackager.cs30
-rw-r--r--Xamarin.Forms.Platform.iOS/VisualElementTracker.cs4
3 files changed, 30 insertions, 16 deletions
diff --git a/Xamarin.Forms.Platform.iOS/RendererPool.cs b/Xamarin.Forms.Platform.iOS/RendererPool.cs
index 563201f..e95148d 100644
--- a/Xamarin.Forms.Platform.iOS/RendererPool.cs
+++ b/Xamarin.Forms.Platform.iOS/RendererPool.cs
@@ -108,10 +108,14 @@ namespace Xamarin.Forms.Platform.MacOS
var child = logicalChild as VisualElement;
if (child != null)
{
- var renderer = GetFreeRenderer(child) ?? Platform.CreateRenderer(child);
- Platform.SetRenderer(child, renderer);
-
- _parent.NativeView.AddSubview(renderer.NativeView);
+ if (CompressedLayout.GetIsHeadless(child)) {
+ child.IsPlatformEnabled = true;
+ FillChildrenWithRenderers(child);
+ } else {
+ var renderer = GetFreeRenderer(child) ?? Platform.CreateRenderer(child);
+ Platform.SetRenderer(child, renderer);
+ _parent.NativeView.AddSubview(renderer.NativeView);
+ }
}
}
}
diff --git a/Xamarin.Forms.Platform.iOS/VisualElementPackager.cs b/Xamarin.Forms.Platform.iOS/VisualElementPackager.cs
index fa91cf6..72ab654 100644
--- a/Xamarin.Forms.Platform.iOS/VisualElementPackager.cs
+++ b/Xamarin.Forms.Platform.iOS/VisualElementPackager.cs
@@ -13,16 +13,20 @@ namespace Xamarin.Forms.Platform.MacOS
bool _isDisposed;
- IElementController ElementController => Renderer.Element as IElementController;
+ IElementController ElementController => _element;
- public VisualElementPackager(IVisualElementRenderer renderer)
+ public VisualElementPackager(IVisualElementRenderer renderer) : this(renderer, null)
+ {
+ }
+
+ VisualElementPackager(IVisualElementRenderer renderer, VisualElement element)
{
if (renderer == null)
throw new ArgumentNullException(nameof(renderer));
Renderer = renderer;
renderer.ElementChanged += OnRendererElementChanged;
- SetElement(null, renderer.Element);
+ SetElement(null, element ?? renderer.Element);
}
protected IVisualElementRenderer Renderer { get; set; }
@@ -65,16 +69,22 @@ namespace Xamarin.Forms.Platform.MacOS
if (_isDisposed)
return;
- var viewRenderer = Platform.CreateRenderer(view);
- Platform.SetRenderer(view, viewRenderer);
+ if (CompressedLayout.GetIsHeadless(view)) {
+ var packager = new VisualElementPackager(Renderer, view);
+ view.IsPlatformEnabled = true;
+ packager.Load();
+ } else {
+ var viewRenderer = Platform.CreateRenderer(view);
+ Platform.SetRenderer(view, viewRenderer);
- var uiview = Renderer.NativeView;
- uiview.AddSubview(viewRenderer.NativeView);
+ var uiview = Renderer.NativeView;
+ uiview.AddSubview(viewRenderer.NativeView);
- if (Renderer.ViewController != null && viewRenderer.ViewController != null)
- Renderer.ViewController.AddChildViewController(viewRenderer.ViewController);
+ if (Renderer.ViewController != null && viewRenderer.ViewController != null)
+ Renderer.ViewController.AddChildViewController(viewRenderer.ViewController);
- EnsureChildrenOrder();
+ EnsureChildrenOrder();
+ }
}
protected virtual void OnChildRemoved(VisualElement view)
diff --git a/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs b/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs
index 5c84b99..68625a3 100644
--- a/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs
+++ b/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs
@@ -138,8 +138,8 @@ namespace Xamarin.Forms.Platform.MacOS
var scale = (float)view.Scale;
var width = (float)view.Width;
var height = (float)view.Height;
- var x = (float)view.X;
- var y = (float)view.Y;
+ var x = (float)view.X + (float)CompressedLayout.GetHeadlessOffset(view).X;
+ var y = (float)view.Y + (float)CompressedLayout.GetHeadlessOffset(view).Y;
var opacity = (float)view.Opacity;
var isVisible = view.IsVisible;