Call Page.Disappearing when session end
This commit is contained in:
parent
57b8aa15d2
commit
92e9b9bee4
|
@ -3,7 +3,7 @@ using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Ooui.Forms
|
namespace Ooui.Forms
|
||||||
{
|
{
|
||||||
public class PlatformRenderer : Ooui.Div
|
public class PlatformRenderer : Ooui.Div, IDisposable
|
||||||
{
|
{
|
||||||
readonly Platform platform;
|
readonly Platform platform;
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ namespace Ooui.Forms
|
||||||
|
|
||||||
protected override bool TriggerEventFromMessage (Message message)
|
protected override bool TriggerEventFromMessage (Message message)
|
||||||
{
|
{
|
||||||
|
if (disposedValue)
|
||||||
|
return false;
|
||||||
if (message.TargetId == "window" && message.Key == "resize" && message.Value is Newtonsoft.Json.Linq.JObject j) {
|
if (message.TargetId == "window" && message.Key == "resize" && message.Value is Newtonsoft.Json.Linq.JObject j) {
|
||||||
var width = (double)j["width"];
|
var width = (double)j["width"];
|
||||||
var height = (double)j["height"];
|
var height = (double)j["height"];
|
||||||
|
@ -29,5 +31,28 @@ namespace Ooui.Forms
|
||||||
return base.TriggerEventFromMessage (message);
|
return base.TriggerEventFromMessage (message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
#region IDisposable Support
|
||||||
|
private bool disposedValue = false;
|
||||||
|
|
||||||
|
protected virtual void Dispose (bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue) {
|
||||||
|
if (disposing) {
|
||||||
|
// Disconnect any events we started
|
||||||
|
// Inform the page it's leaving
|
||||||
|
if (Platform.Page is IPageController pc) {
|
||||||
|
pc.SendDisappearing ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose ()
|
||||||
|
{
|
||||||
|
Dispose (true);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,13 @@ namespace Samples
|
||||||
status.Text = "Page appeared";
|
status.Text = "Page appeared";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnDisappearing ()
|
||||||
|
{
|
||||||
|
base.OnDisappearing ();
|
||||||
|
|
||||||
|
Console.WriteLine ("Disappear was called");
|
||||||
|
}
|
||||||
|
|
||||||
public async void OnButtonClicked(object sender, EventArgs args)
|
public async void OnButtonClicked(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
activity.IsRunning = true;
|
activity.IsRunning = true;
|
||||||
|
|
Loading…
Reference in New Issue