summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.MacOS/Extensions/NSViewControllerExtensions.cs
blob: f5562322cfd7271bf2e46772765ef41c7e134bce (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
´╗┐using System;
using System.Threading.Tasks;
using AppKit;

namespace Xamarin.Forms.Platform.MacOS
{
	internal static class NSViewControllerExtensions
	{
		public static Task<T> HandleAsyncAnimation<T>(this NSViewController container, NSViewController fromViewController,
			NSViewController toViewController, NSViewControllerTransitionOptions transitonOption,
			Action animationFinishedCallback, T result)
		{
			var tcs = new TaskCompletionSource<T>();

			container.TransitionFromViewController(fromViewController, toViewController, transitonOption, () =>
			{
				tcs.SetResult(result);
				animationFinishedCallback?.Invoke();
			});

			return tcs.Task;
		}
	}
}