2017-11-09 06:21:05 +00:00
|
|
|
|
using System;
|
2017-11-09 07:57:04 +00:00
|
|
|
|
using Xamarin.Forms;
|
2017-11-09 07:12:59 +00:00
|
|
|
|
|
2017-11-09 07:57:04 +00:00
|
|
|
|
namespace Xamarin.Forms
|
2017-11-09 06:21:05 +00:00
|
|
|
|
{
|
|
|
|
|
public static class PageExtensions
|
|
|
|
|
{
|
2017-11-09 07:12:59 +00:00
|
|
|
|
public static void Publish (this Xamarin.Forms.Page page, string path)
|
|
|
|
|
{
|
2017-11-09 07:57:04 +00:00
|
|
|
|
Ooui.UI.Publish (path, () => page.CreateElement ());
|
2017-11-09 07:12:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void PublishShared (this Xamarin.Forms.Page page, string path)
|
|
|
|
|
{
|
2017-11-09 07:57:04 +00:00
|
|
|
|
var lazyPage = new Lazy<Ooui.Element> ((() => page.CreateElement ()), true);
|
|
|
|
|
Ooui.UI.Publish (path, () => lazyPage.Value);
|
2017-11-09 07:12:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-09 07:57:04 +00:00
|
|
|
|
public static Ooui.Element CreateElement (this Xamarin.Forms.Page page)
|
2017-11-09 06:21:05 +00:00
|
|
|
|
{
|
2017-11-09 07:12:59 +00:00
|
|
|
|
if (!Xamarin.Forms.Forms.IsInitialized)
|
|
|
|
|
throw new InvalidOperationException ("call Forms.Init() before this");
|
|
|
|
|
|
2017-11-09 07:57:04 +00:00
|
|
|
|
if (!(page.RealParent is Application)) {
|
|
|
|
|
var app = new DefaultApplication ();
|
|
|
|
|
app.MainPage = page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = new Ooui.Forms.Platform ();
|
|
|
|
|
result.SetPage (page);
|
|
|
|
|
return result.Element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DefaultApplication : Application
|
|
|
|
|
{
|
2017-11-09 06:21:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|