summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.MacOS/PlatformRenderer.cs
blob: c0fcae35e24a7b634641b74d3f70d33abd8df71d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
´╗┐using AppKit;

namespace Xamarin.Forms.Platform.MacOS
{
	internal class PlatformRenderer : NSViewController
	{
		PlatformNavigation _platformNavigation;
		bool _disposed;

		internal PlatformRenderer(Platform platform)
		{
			Platform = platform;
			View = new NSView(NSApplication.SharedApplication.Windows[0].Frame);
			_platformNavigation = new PlatformNavigation(this);
		}

		public Platform Platform { get; set; }

		public PlatformNavigation Navigation => _platformNavigation;

		public override void ViewDidAppear()
		{
			Platform.DidAppear();
			base.ViewDidAppear();
		}

		public override void ViewDidLayout()
		{
			base.ViewDidLayout();
			Platform.LayoutSubviews();
		}

		public override void ViewWillAppear()
		{
			Platform.WillAppear();
			base.ViewWillAppear();
		}

		protected override void Dispose(bool disposing)
		{
			if (!_disposed)
			{
				_platformNavigation.Dispose();
				_platformNavigation = null;
			}
			_disposed = true;
			base.Dispose(disposing);
		}
	}
}