summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/Forms.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Forms.cs')
-rw-r--r--Xamarin.Forms.Platform.iOS/Forms.cs60
1 files changed, 14 insertions, 46 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Forms.cs b/Xamarin.Forms.Platform.iOS/Forms.cs
index d51e1495..2c8fc6f7 100644
--- a/Xamarin.Forms.Platform.iOS/Forms.cs
+++ b/Xamarin.Forms.Platform.iOS/Forms.cs
@@ -11,18 +11,11 @@ using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Xamarin.Forms.Internals;
+using CoreFoundation;
using Foundation;
-#if __MOBILE__
using UIKit;
+using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.iOS;
-using TNativeView = UIKit.UIView;
-#else
-using AppKit;
-using Xamarin.Forms.Platform.MacOS;
-using TNativeView = AppKit.NSView;
-
-#endif
namespace Xamarin.Forms
{
@@ -31,11 +24,7 @@ namespace Xamarin.Forms
//Preserve GetCallingAssembly
static readonly bool nevertrue = false;
- public static bool IsInitialized { get; private set; }
-
-#if __MOBILE__
static bool? s_isiOS9OrNewer;
-#endif
static Forms()
{
@@ -43,7 +32,8 @@ namespace Xamarin.Forms
Assembly.GetCallingAssembly();
}
-#if __MOBILE__
+ public static bool IsInitialized { get; private set; }
+
internal static bool IsiOS9OrNewer
{
get
@@ -53,7 +43,6 @@ namespace Xamarin.Forms
return s_isiOS9OrNewer.Value;
}
}
-#endif
public static void Init()
{
@@ -64,22 +53,19 @@ namespace Xamarin.Forms
Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c)));
-#if __MOBILE__
- Device.Idiom = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone;
-#else
- Device.Idiom = TargetIdiom.Desktop;
-#endif
Device.PlatformServices = new IOSPlatformServices();
Device.Info = new IOSDeviceInfo();
- Registrar.RegisterAll(new[]
- { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) });
+ Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) });
+
+ Device.Idiom = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone;
+
ExpressionSearch.Default = new iOSExpressionSearch();
}
public static event EventHandler<ViewInitializedEventArgs> ViewInitialized;
- internal static void SendViewInitialized(this VisualElement self, TNativeView nativeView)
+ internal static void SendViewInitialized(this VisualElement self, UIView nativeView)
{
ViewInitialized?.Invoke(self, new ViewInitializedEventArgs { View = self, NativeView = nativeView });
}
@@ -113,22 +99,16 @@ namespace Xamarin.Forms
internal class IOSDeviceInfo : DeviceInfo
{
-#if __MOBILE__
readonly NSObject _notification;
-#endif
readonly Size _scaledScreenSize;
readonly double _scalingFactor;
public IOSDeviceInfo()
{
-#if __MOBILE__
_notification = UIDevice.Notifications.ObserveOrientationDidChange((sender, args) => CurrentOrientation = UIDevice.CurrentDevice.Orientation.ToDeviceOrientation());
+
_scalingFactor = UIScreen.MainScreen.Scale;
_scaledScreenSize = new Size(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);
-#else
- _scalingFactor = NSScreen.MainScreen.BackingScaleFactor;
- _scaledScreenSize = new Size(NSScreen.MainScreen.Frame.Width, NSScreen.MainScreen.Frame.Height);
-#endif
PixelScreenSize = new Size(_scaledScreenSize.Width * _scalingFactor, _scaledScreenSize.Height * _scalingFactor);
}
@@ -140,9 +120,7 @@ namespace Xamarin.Forms
protected override void Dispose(bool disposing)
{
-#if __MOBILE__
_notification.Dispose();
-#endif
base.Dispose(disposing);
}
}
@@ -220,20 +198,11 @@ namespace Xamarin.Forms
public bool IsInvokeRequired => !NSThread.IsMain;
-#if __MOBILE__
public string RuntimePlatform => Device.iOS;
-#else
- public string RuntimePlatform => Device.macOS;
-#endif
public void OpenUriAction(Uri uri)
{
- var url = NSUrl.FromString(uri.ToString()) ?? new NSUrl(uri.Scheme, uri.Host, uri.LocalPath);
-#if __MOBILE__
- UIApplication.SharedApplication.OpenUrl(url);
-#else
- NSWorkspace.SharedWorkspace.OpenUrl(url);
-#endif
+ UIApplication.SharedApplication.OpenUrl(new NSUrl(uri.AbsoluteUri));
}
public void StartTimer(TimeSpan interval, Func<bool> callback)
@@ -248,11 +217,11 @@ namespace Xamarin.Forms
HttpClient GetHttpClient()
{
- var proxy = CoreFoundation.CFNetwork.GetSystemProxySettings();
+ var proxy = CFNetwork.GetSystemProxySettings();
var handler = new HttpClientHandler();
if (!string.IsNullOrEmpty(proxy.HTTPProxy))
{
- handler.Proxy = CoreFoundation.CFNetwork.GetDefaultProxy();
+ handler.Proxy = CFNetwork.GetDefaultProxy();
handler.UseProxy = true;
}
return new HttpClient(handler);
@@ -303,8 +272,7 @@ namespace Xamarin.Forms
public Task<Stream> OpenFileAsync(string path, FileMode mode, FileAccess access, FileShare share)
{
- Stream stream = _isolatedStorageFile.OpenFile(path, (System.IO.FileMode)mode, (System.IO.FileAccess)access,
- (System.IO.FileShare)share);
+ Stream stream = _isolatedStorageFile.OpenFile(path, (System.IO.FileMode)mode, (System.IO.FileAccess)access, (System.IO.FileShare)share);
return Task.FromResult(stream);
}
}