AppDelegate.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Threading.Tasks;
  3. using Avalonia;
  4. using Avalonia.iOS;
  5. using Foundation;
  6. using InABox.Avalonia.Platform;
  7. using InABox.Avalonia.Platform.iOS;
  8. using UIKit;
  9. using Microsoft.Maui.ApplicationModel;
  10. namespace PRS.Avalonia.iOS;
  11. // The UIApplicationDelegate for the application. This class is responsible for launching the
  12. // User Interface of the application, as well as listening (and optionally responding) to
  13. // application events from iOS.
  14. [Register("AppDelegate")]
  15. #pragma warning disable CA1711 // Identifiers should not have incorrect suffix
  16. public partial class AppDelegate : AvaloniaAppDelegate<App>
  17. #pragma warning restore CA1711 // Identifiers should not have incorrect suffix
  18. {
  19. protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
  20. {
  21. // Set up a getter for the top-most view controller
  22. UIViewController GetTopController() => this.Window?.RootViewController!;
  23. // Initialize Essentials
  24. Platform.Init(GetTopController);
  25. PlatformTools.Register<IDeviceId, iOS_DeviceId>();
  26. PlatformTools.Register<IAppVersion,iOS_AppVersion>();
  27. PlatformTools.Register<IImageTools, iOS_ImageTools>();
  28. PlatformTools.Register<IPdfRenderer, iOS_PdfRenderer>();
  29. PlatformTools.Register<IGeolocation, iOS_Geolocation>();
  30. PlatformTools.Register<IPermissions, iOS_Permissions>();
  31. var result = base.CustomizeAppBuilder(builder);
  32. result = result.UseSkia();
  33. result = result.WithInterFont();
  34. //if (Runtime.Arch == Arch.SIMULATOR)
  35. result = result.With(new iOSPlatformOptions { RenderingMode = [iOSRenderingMode.OpenGl] });
  36. return result;
  37. }
  38. }