summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/ViewRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/ViewRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.iOS/ViewRenderer.cs109
1 files changed, 8 insertions, 101 deletions
diff --git a/Xamarin.Forms.Platform.iOS/ViewRenderer.cs b/Xamarin.Forms.Platform.iOS/ViewRenderer.cs
index 2cf9f754..6ecc307b 100644
--- a/Xamarin.Forms.Platform.iOS/ViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/ViewRenderer.cs
@@ -1,39 +1,21 @@
using System;
using System.ComponentModel;
-
+using UIKit;
using RectangleF = CoreGraphics.CGRect;
using SizeF = CoreGraphics.CGSize;
-#if __MOBILE__
-using UIKit;
-using NativeView = UIKit.UIView;
-using NativeColor = UIKit.UIColor;
-using NativeControl = UIKit.UIControl;
-
namespace Xamarin.Forms.Platform.iOS
-#else
-using NativeView = AppKit.NSView;
-using NativeColor = CoreGraphics.CGColor;
-using NativeControl = AppKit.NSControl;
-
-namespace Xamarin.Forms.Platform.MacOS
-#endif
{
- public abstract class ViewRenderer : ViewRenderer<View, NativeView>
+ public abstract class ViewRenderer : ViewRenderer<View, UIView>
{
}
- public abstract class ViewRenderer<TView, TNativeView> : VisualElementRenderer<TView> where TView : View where TNativeView : NativeView
+ public abstract class ViewRenderer<TView, TNativeView> : VisualElementRenderer<TView> where TView : View where TNativeView : UIView
{
-#if __MOBILE__
- string _defaultAccessibilityLabel;
- string _defaultAccessibilityHint;
- bool? _defaultIsAccessibilityElement;
-#endif
- NativeColor _defaultColor;
+ UIColor _defaultColor;
public TNativeView Control { get; private set; }
-#if __MOBILE__
+
public override void LayoutSubviews()
{
base.LayoutSubviews();
@@ -48,19 +30,6 @@ namespace Xamarin.Forms.Platform.MacOS
return Control.SizeThatFits(size);
}
-#else
- public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
- {
- return (Control ?? NativeView).GetSizeRequest(widthConstraint, heightConstraint);
- }
-
- public override void Layout()
- {
- if (Control != null)
- Control.Frame = new RectangleF(0, 0, (nfloat)Element.Width, (nfloat)Element.Height);
- base.Layout();
- }
-#endif
/// <summary>
/// Determines whether the native control is disposed of when this renderer is disposed
@@ -115,59 +84,7 @@ namespace Xamarin.Forms.Platform.MacOS
base.OnRegisterEffect(effect);
effect.Control = Control;
}
-#if __MOBILE__
- protected override void SetAccessibilityHint()
- {
- if (Control == null)
- {
- base.SetAccessibilityHint();
- return;
- }
-
- if (Element == null)
- return;
-
- if (_defaultAccessibilityHint == null)
- _defaultAccessibilityHint = Control.AccessibilityHint;
-
- Control.AccessibilityHint = (string)Element.GetValue(Accessibility.HintProperty) ?? _defaultAccessibilityHint;
-
- }
-
- protected override void SetAccessibilityLabel()
- {
- if (Control == null)
- {
- base.SetAccessibilityLabel();
- return;
- }
-
- if (Element == null)
- return;
-
- if (_defaultAccessibilityLabel == null)
- _defaultAccessibilityLabel = Control.AccessibilityLabel;
-
- Control.AccessibilityLabel = (string)Element.GetValue(Accessibility.NameProperty) ?? _defaultAccessibilityLabel;
- }
- protected override void SetIsAccessibilityElement()
- {
- if (Control == null)
- {
- base.SetIsAccessibilityElement();
- return;
- }
-
- if (Element == null)
- return;
-
- if (!_defaultIsAccessibilityElement.HasValue)
- _defaultIsAccessibilityElement = Control.IsAccessibilityElement;
-
- Control.IsAccessibilityElement = (bool)((bool?)Element.GetValue(Accessibility.IsInAccessibleTreeProperty) ?? _defaultIsAccessibilityElement);
- }
-#endif
protected override void SetAutomationId(string id)
{
if (Control == null)
@@ -183,24 +100,16 @@ namespace Xamarin.Forms.Platform.MacOS
{
if (Control == null)
return;
-#if __MOBILE__
+
if (color == Color.Default)
Control.BackgroundColor = _defaultColor;
else
Control.BackgroundColor = color.ToUIColor();
-#else
- Control.Layer.BackgroundColor = color == Color.Default ? _defaultColor : color.ToCGColor();
-#endif
}
protected void SetNativeControl(TNativeView uiview)
{
-#if __MOBILE__
_defaultColor = uiview.BackgroundColor;
-#else
- uiview.WantsLayer = true;
- _defaultColor = uiview.Layer.BackgroundColor;
-#endif
Control = uiview;
if (Element.BackgroundColor != Color.Default)
@@ -211,19 +120,17 @@ namespace Xamarin.Forms.Platform.MacOS
AddSubview(uiview);
}
-#if __MOBILE__
- internal override void SendVisualElementInitialized(VisualElement element, NativeView nativeView)
+ internal override void SendVisualElementInitialized(VisualElement element, UIView nativeView)
{
base.SendVisualElementInitialized(element, Control);
}
-#endif
void UpdateIsEnabled()
{
if (Element == null || Control == null)
return;
- var uiControl = Control as NativeControl;
+ var uiControl = Control as UIControl;
if (uiControl == null)
return;
uiControl.Enabled = Element.IsEnabled;