2017-12-04 17:30:43 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2019-04-15 19:55:56 +03:00
|
|
|
using System.Runtime.CompilerServices;
|
2017-12-04 17:30:43 +03:00
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
2018-06-22 14:16:22 +03:00
|
|
|
using System.ComponentModel;
|
2017-12-04 17:30:43 +03:00
|
|
|
using Xamarin.Forms.Internals;
|
2018-06-22 14:16:22 +03:00
|
|
|
using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
|
2017-12-04 17:30:43 +03:00
|
|
|
using ElmSharp;
|
2018-01-08 22:19:19 +03:00
|
|
|
using EProgressBar = ElmSharp.ProgressBar;
|
|
|
|
using EButton = ElmSharp.Button;
|
|
|
|
using EColor = ElmSharp.Color;
|
2017-12-04 17:30:43 +03:00
|
|
|
|
2019-04-15 19:55:56 +03:00
|
|
|
[assembly: InternalsVisibleTo("Xamarin.Forms.Material")]
|
|
|
|
|
2017-12-04 17:30:43 +03:00
|
|
|
namespace Xamarin.Forms.Platform.Tizen
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
public static class Platform
|
2017-12-04 17:30:43 +03:00
|
|
|
{
|
|
|
|
internal static readonly BindableProperty RendererProperty = BindableProperty.CreateAttached("Renderer", typeof(IVisualElementRenderer), typeof(Platform), default(IVisualElementRenderer),
|
|
|
|
propertyChanged: (bindable, oldvalue, newvalue) =>
|
|
|
|
{
|
|
|
|
var ve = bindable as VisualElement;
|
|
|
|
if (ve != null && newvalue == null)
|
|
|
|
ve.IsPlatformEnabled = false;
|
|
|
|
});
|
|
|
|
|
2018-02-07 13:33:14 +03:00
|
|
|
public static IVisualElementRenderer GetRenderer(BindableObject bindable)
|
|
|
|
{
|
|
|
|
return (IVisualElementRenderer)bindable.GetValue(Platform.RendererProperty);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void SetRenderer(BindableObject bindable, IVisualElementRenderer value)
|
|
|
|
{
|
|
|
|
bindable.SetValue(Platform.RendererProperty, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the renderer associated with the <c>view</c>. If it doesn't exist, creates a new one.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Renderer associated with the <c>view</c>.</returns>
|
2018-06-09 00:21:41 +03:00
|
|
|
/// <param name="element">VisualElement for which the renderer is going to be returned.</param>
|
|
|
|
public static IVisualElementRenderer GetOrCreateRenderer(VisualElement element)
|
2018-02-07 13:33:14 +03:00
|
|
|
{
|
2018-06-09 00:21:41 +03:00
|
|
|
return GetRenderer(element) ?? CreateRenderer(element);
|
2018-02-07 13:33:14 +03:00
|
|
|
}
|
|
|
|
|
2018-06-09 00:21:41 +03:00
|
|
|
internal static IVisualElementRenderer CreateRenderer(VisualElement element)
|
2018-02-07 13:33:14 +03:00
|
|
|
{
|
2018-06-09 00:21:41 +03:00
|
|
|
IVisualElementRenderer renderer = Registrar.Registered.GetHandlerForObject<IVisualElementRenderer>(element) ?? new DefaultRenderer();
|
|
|
|
renderer.SetElement(element);
|
|
|
|
return renderer;
|
2018-02-07 13:33:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
internal static ITizenPlatform CreatePlatform(EvasObject parent)
|
|
|
|
{
|
|
|
|
ITizenPlatform platform;
|
|
|
|
if (Forms.Flags.Contains(Flags.LightweightPlatformExperimental))
|
|
|
|
{
|
|
|
|
platform = new LightweightPlatform(parent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
platform = new DefaultPlatform(parent);
|
|
|
|
}
|
|
|
|
return platform;
|
|
|
|
}
|
2018-11-01 00:12:22 +03:00
|
|
|
|
|
|
|
public static SizeRequest GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint)
|
|
|
|
{
|
|
|
|
widthConstraint = widthConstraint <= -1 ? double.PositiveInfinity : widthConstraint;
|
|
|
|
heightConstraint = heightConstraint <= -1 ? double.PositiveInfinity : heightConstraint;
|
|
|
|
|
|
|
|
double width = !double.IsPositiveInfinity(widthConstraint) ? widthConstraint : Int32.MaxValue;
|
|
|
|
double height = !double.IsPositiveInfinity(heightConstraint) ? heightConstraint : Int32.MaxValue;
|
|
|
|
|
|
|
|
return Platform.GetRenderer(view).GetDesiredSize(width, height);
|
|
|
|
}
|
2018-02-07 13:33:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2018-11-01 00:12:22 +03:00
|
|
|
public interface ITizenPlatform : IDisposable
|
2019-02-12 23:27:00 +03:00
|
|
|
#pragma warning disable CS0618 // Type or member is obsolete
|
|
|
|
, IPlatform
|
|
|
|
#pragma warning restore CS0618 // Type or member is obsolete
|
2018-02-07 13:33:14 +03:00
|
|
|
{
|
|
|
|
void SetPage(Page page);
|
|
|
|
bool SendBackButtonPressed();
|
|
|
|
EvasObject GetRootNativeView();
|
|
|
|
bool HasAlpha { get; set; }
|
|
|
|
event EventHandler<RootNativeViewChangedEventArgs> RootNativeViewChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
public class RootNativeViewChangedEventArgs : EventArgs
|
|
|
|
{
|
|
|
|
public RootNativeViewChangedEventArgs(EvasObject view) => RootNativeView = view;
|
|
|
|
public EvasObject RootNativeView { get; private set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public class DefaultPlatform : BindableObject, ITizenPlatform, INavigation
|
|
|
|
{
|
2017-12-04 17:30:43 +03:00
|
|
|
NavigationModel _navModel = new NavigationModel();
|
|
|
|
bool _disposed;
|
2018-01-08 22:19:19 +03:00
|
|
|
Native.Dialog _pageBusyDialog;
|
|
|
|
int _pageBusyCount;
|
2018-10-15 18:42:54 +03:00
|
|
|
readonly Naviframe _internalNaviframe;
|
2018-02-07 13:33:14 +03:00
|
|
|
|
2018-10-15 18:42:54 +03:00
|
|
|
readonly HashSet<EvasObject> _alerts = new HashSet<EvasObject>();
|
2018-04-09 05:15:23 +03:00
|
|
|
|
2019-03-27 21:38:38 +03:00
|
|
|
#pragma warning disable 0067
|
2018-02-07 13:33:14 +03:00
|
|
|
public event EventHandler<RootNativeViewChangedEventArgs> RootNativeViewChanged;
|
2019-03-27 21:38:38 +03:00
|
|
|
#pragma warning restore 0067
|
2017-12-04 17:30:43 +03:00
|
|
|
|
2018-02-07 13:33:14 +03:00
|
|
|
internal DefaultPlatform(EvasObject parent)
|
2017-12-04 17:30:43 +03:00
|
|
|
{
|
2018-01-08 22:19:19 +03:00
|
|
|
Forms.NativeParent = parent;
|
|
|
|
_pageBusyCount = 0;
|
|
|
|
MessagingCenter.Subscribe<Page, bool>(this, Page.BusySetSignalName, BusySetSignalNameHandler);
|
|
|
|
MessagingCenter.Subscribe<Page, AlertArguments>(this, Page.AlertSignalName, AlertSignalNameHandler);
|
|
|
|
MessagingCenter.Subscribe<Page, ActionSheetArguments>(this, Page.ActionSheetSignalName, ActionSheetSignalNameHandler);
|
|
|
|
|
2018-02-07 13:33:14 +03:00
|
|
|
_internalNaviframe = new Naviframe(Forms.NativeParent)
|
2017-12-04 17:30:43 +03:00
|
|
|
{
|
|
|
|
PreserveContentOnPop = true,
|
|
|
|
DefaultBackButtonEnabled = false,
|
|
|
|
};
|
2018-02-07 13:33:14 +03:00
|
|
|
_internalNaviframe.SetAlignment(-1, -1);
|
|
|
|
_internalNaviframe.SetWeight(1.0, 1.0);
|
|
|
|
_internalNaviframe.Show();
|
|
|
|
_internalNaviframe.AnimationFinished += NaviAnimationFinished;
|
2017-12-04 17:30:43 +03:00
|
|
|
}
|
|
|
|
|
2018-02-07 13:33:14 +03:00
|
|
|
~DefaultPlatform()
|
2017-12-04 17:30:43 +03:00
|
|
|
{
|
|
|
|
Dispose(false);
|
|
|
|
}
|
|
|
|
|
2018-01-08 22:19:19 +03:00
|
|
|
public Page Page { get; private set; }
|
|
|
|
|
|
|
|
public bool HasAlpha { get; set; }
|
|
|
|
|
2017-12-04 17:30:43 +03:00
|
|
|
Task CurrentModalNavigationTask { get; set; }
|
|
|
|
TaskCompletionSource<bool> CurrentTaskCompletionSource { get; set; }
|
|
|
|
IPageController CurrentPageController => _navModel.CurrentPage as IPageController;
|
|
|
|
IReadOnlyList<Page> INavigation.ModalStack => _navModel.Modals.ToList();
|
|
|
|
IReadOnlyList<Page> INavigation.NavigationStack => new List<Page>();
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Dispose(true);
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetPage(Page newRoot)
|
|
|
|
{
|
|
|
|
if (Page != null)
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
var copyOfStack = new List<NaviItem>(_internalNaviframe.NavigationStack);
|
2017-12-04 17:30:43 +03:00
|
|
|
for (var i = 0; i < copyOfStack.Count; i++)
|
|
|
|
{
|
|
|
|
copyOfStack[i].Delete();
|
|
|
|
}
|
|
|
|
foreach (Page page in _navModel.Roots)
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
var renderer = Platform.GetRenderer(page);
|
2017-12-04 17:30:43 +03:00
|
|
|
renderer?.Dispose();
|
|
|
|
}
|
|
|
|
_navModel = new NavigationModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newRoot == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_navModel.Push(newRoot, null);
|
|
|
|
|
|
|
|
Page = newRoot;
|
|
|
|
|
2019-02-12 23:27:00 +03:00
|
|
|
#pragma warning disable CS0618 // Type or member is obsolete
|
|
|
|
// The Platform property is no longer necessary, but we have to set it because some third-party
|
|
|
|
// library might still be retrieving it and using it
|
|
|
|
Page.Platform = this;
|
|
|
|
#pragma warning restore CS0618 // Type or member is obsolete
|
|
|
|
|
2018-06-09 00:21:41 +03:00
|
|
|
IVisualElementRenderer pageRenderer = Platform.CreateRenderer(Page);
|
2018-02-07 13:33:14 +03:00
|
|
|
var naviItem = _internalNaviframe.Push(pageRenderer.NativeView);
|
2017-12-04 17:30:43 +03:00
|
|
|
naviItem.TitleBarVisible = false;
|
|
|
|
|
2018-01-08 22:19:19 +03:00
|
|
|
// Make naviitem transparent if parent window is transparent.
|
2017-12-04 17:30:43 +03:00
|
|
|
// Make sure that this is only for _navModel._naviTree. (not for _navModel._modalStack)
|
|
|
|
// In addtion, the style of naviItem is only decided before the naviItem pushed into Naviframe. (not on-demand).
|
2018-01-08 22:19:19 +03:00
|
|
|
if (HasAlpha)
|
2017-12-04 17:30:43 +03:00
|
|
|
{
|
|
|
|
naviItem.Style = "default/transparent";
|
|
|
|
}
|
|
|
|
|
|
|
|
((Application)Page.RealParent).NavigationProxy.Inner = this;
|
|
|
|
|
|
|
|
Device.StartTimer(TimeSpan.Zero, () =>
|
|
|
|
{
|
|
|
|
CurrentPageController?.SendAppearing();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-01-08 22:19:19 +03:00
|
|
|
public bool SendBackButtonPressed()
|
|
|
|
{
|
|
|
|
bool handled = false;
|
|
|
|
if (_navModel.CurrentPage != null)
|
|
|
|
{
|
|
|
|
if (CurrentModalNavigationTask != null && !CurrentModalNavigationTask.IsCompleted)
|
|
|
|
{
|
|
|
|
handled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
handled = _navModel.CurrentPage.SendBackButtonPressed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
2018-02-07 13:33:14 +03:00
|
|
|
public EvasObject GetRootNativeView()
|
|
|
|
{
|
|
|
|
return _internalNaviframe as EvasObject;
|
|
|
|
}
|
|
|
|
|
2017-12-04 17:30:43 +03:00
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
{
|
|
|
|
if (_disposed) return;
|
|
|
|
if (disposing)
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
MessagingCenter.Unsubscribe<Page, AlertArguments>(this, "Xamarin.SendAlert");
|
|
|
|
MessagingCenter.Unsubscribe<Page, bool>(this, "Xamarin.BusySet");
|
|
|
|
MessagingCenter.Unsubscribe<Page, ActionSheetArguments>(this, "Xamarin.ShowActionSheet");
|
2017-12-04 17:30:43 +03:00
|
|
|
SetPage(null);
|
2018-02-07 13:33:14 +03:00
|
|
|
_internalNaviframe.Unrealize();
|
2017-12-04 17:30:43 +03:00
|
|
|
}
|
|
|
|
_disposed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnBindingContextChanged()
|
|
|
|
{
|
|
|
|
BindableObject.SetInheritedBindingContext(Page, base.BindingContext);
|
|
|
|
base.OnBindingContextChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void INavigation.InsertPageBefore(Page page, Page before)
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("InsertPageBefore is not supported globally on Tizen, please use a NavigationPage.");
|
|
|
|
}
|
|
|
|
|
|
|
|
Task<Page> INavigation.PopAsync()
|
|
|
|
{
|
|
|
|
return ((INavigation)this).PopAsync(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Task<Page> INavigation.PopAsync(bool animated)
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("PopAsync is not supported globally on Tizen, please use a NavigationPage.");
|
|
|
|
}
|
|
|
|
|
|
|
|
Task INavigation.PopToRootAsync()
|
|
|
|
{
|
|
|
|
return ((INavigation)this).PopToRootAsync(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Task INavigation.PopToRootAsync(bool animated)
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("PopToRootAsync is not supported globally on Tizen, please use a NavigationPage.");
|
|
|
|
}
|
|
|
|
|
|
|
|
Task INavigation.PushAsync(Page root)
|
|
|
|
{
|
|
|
|
return ((INavigation)this).PushAsync(root, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Task INavigation.PushAsync(Page root, bool animated)
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("PushAsync is not supported globally on Tizen, please use a NavigationPage.");
|
|
|
|
}
|
|
|
|
|
|
|
|
void INavigation.RemovePage(Page page)
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("RemovePage is not supported globally on Tizen, please use a NavigationPage.");
|
|
|
|
}
|
|
|
|
|
|
|
|
Task INavigation.PushModalAsync(Page modal)
|
|
|
|
{
|
|
|
|
return ((INavigation)this).PushModalAsync(modal, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
async Task INavigation.PushModalAsync(Page modal, bool animated)
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
var previousPage = CurrentPageController;
|
2018-06-09 00:21:41 +03:00
|
|
|
Device.BeginInvokeOnMainThread(() => previousPage?.SendDisappearing());
|
2017-12-04 17:30:43 +03:00
|
|
|
|
|
|
|
_navModel.PushModal(modal);
|
|
|
|
|
|
|
|
await PushModalInternal(modal, animated);
|
|
|
|
|
|
|
|
// Verify that the modal is still on the stack
|
|
|
|
if (_navModel.CurrentPage == modal)
|
|
|
|
CurrentPageController.SendAppearing();
|
|
|
|
}
|
|
|
|
|
|
|
|
Task<Page> INavigation.PopModalAsync()
|
|
|
|
{
|
|
|
|
return ((INavigation)this).PopModalAsync(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
async Task<Page> INavigation.PopModalAsync(bool animated)
|
|
|
|
{
|
|
|
|
Page modal = _navModel.PopModal();
|
|
|
|
|
2018-02-07 13:33:14 +03:00
|
|
|
IVisualElementRenderer modalRenderer = Platform.GetRenderer(modal);
|
2017-12-04 17:30:43 +03:00
|
|
|
if (modalRenderer != null)
|
|
|
|
{
|
|
|
|
await PopModalInternal(animated);
|
2018-02-07 13:33:14 +03:00
|
|
|
modalRenderer.Dispose();
|
2017-12-04 17:30:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CurrentPageController?.SendAppearing();
|
|
|
|
return modal;
|
|
|
|
}
|
|
|
|
|
|
|
|
async Task PushModalInternal(Page modal, bool animated)
|
|
|
|
{
|
|
|
|
TaskCompletionSource<bool> tcs = null;
|
|
|
|
if (CurrentModalNavigationTask != null && !CurrentModalNavigationTask.IsCompleted)
|
|
|
|
{
|
|
|
|
var previousTask = CurrentModalNavigationTask;
|
|
|
|
tcs = new TaskCompletionSource<bool>();
|
|
|
|
CurrentModalNavigationTask = tcs.Task;
|
|
|
|
await previousTask;
|
|
|
|
}
|
|
|
|
|
2018-02-07 13:33:14 +03:00
|
|
|
var after = _internalNaviframe.NavigationStack.LastOrDefault();
|
2017-12-04 17:30:43 +03:00
|
|
|
NaviItem pushed = null;
|
|
|
|
if (animated || after == null)
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
pushed = _internalNaviframe.Push(Platform.GetOrCreateRenderer(modal).NativeView, modal.Title);
|
2017-12-04 17:30:43 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
pushed = _internalNaviframe.InsertAfter(after, Platform.GetOrCreateRenderer(modal).NativeView, modal.Title);
|
2017-12-04 17:30:43 +03:00
|
|
|
}
|
|
|
|
pushed.TitleBarVisible = false;
|
|
|
|
|
|
|
|
bool shouldWait = animated && after != null;
|
|
|
|
await WaitForCompletion(shouldWait, tcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
async Task PopModalInternal(bool animated)
|
|
|
|
{
|
|
|
|
TaskCompletionSource<bool> tcs = null;
|
|
|
|
if (CurrentModalNavigationTask != null && !CurrentModalNavigationTask.IsCompleted)
|
|
|
|
{
|
|
|
|
var previousTask = CurrentModalNavigationTask;
|
|
|
|
tcs = new TaskCompletionSource<bool>();
|
|
|
|
CurrentModalNavigationTask = tcs.Task;
|
|
|
|
await previousTask;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animated)
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
_internalNaviframe.Pop();
|
2017-12-04 17:30:43 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
_internalNaviframe.NavigationStack.LastOrDefault()?.Delete();
|
2017-12-04 17:30:43 +03:00
|
|
|
}
|
|
|
|
|
2018-02-07 13:33:14 +03:00
|
|
|
bool shouldWait = animated && (_internalNaviframe.NavigationStack.Count != 0);
|
2017-12-04 17:30:43 +03:00
|
|
|
await WaitForCompletion(shouldWait, tcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
async Task WaitForCompletion(bool shouldWait, TaskCompletionSource<bool> tcs)
|
|
|
|
{
|
|
|
|
if (shouldWait)
|
|
|
|
{
|
|
|
|
tcs = tcs ?? new TaskCompletionSource<bool>();
|
|
|
|
CurrentTaskCompletionSource = tcs;
|
|
|
|
if (CurrentModalNavigationTask == null || CurrentModalNavigationTask.IsCompleted)
|
|
|
|
{
|
|
|
|
CurrentModalNavigationTask = CurrentTaskCompletionSource.Task;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tcs?.SetResult(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tcs != null)
|
|
|
|
await tcs.Task;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NaviAnimationFinished(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
var tcs = CurrentTaskCompletionSource;
|
|
|
|
CurrentTaskCompletionSource = null;
|
|
|
|
tcs?.SetResult(true);
|
|
|
|
}
|
2018-01-08 22:19:19 +03:00
|
|
|
|
|
|
|
void BusySetSignalNameHandler(Page sender, bool enabled)
|
|
|
|
{
|
|
|
|
// Verify that the page making the request is child of this platform
|
|
|
|
if (!PageIsChildOfPlatform(sender))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (null == _pageBusyDialog)
|
|
|
|
{
|
|
|
|
_pageBusyDialog = new Native.Dialog(Forms.NativeParent)
|
|
|
|
{
|
2018-07-30 19:11:56 +03:00
|
|
|
Orientation = PopupOrientation.Center,
|
|
|
|
BackgroundColor = EColor.Transparent
|
2018-01-08 22:19:19 +03:00
|
|
|
};
|
|
|
|
|
2018-07-30 19:11:56 +03:00
|
|
|
if (Device.Idiom == TargetIdiom.Phone)
|
|
|
|
{
|
|
|
|
_pageBusyDialog.SetPartColor("bg_title", EColor.Transparent);
|
|
|
|
_pageBusyDialog.SetPartColor("bg_content", EColor.Transparent);
|
|
|
|
}
|
|
|
|
else if (Device.Idiom == TargetIdiom.Watch)
|
2018-06-07 20:54:46 +03:00
|
|
|
{
|
|
|
|
_pageBusyDialog.Style = "circle";
|
|
|
|
}
|
|
|
|
|
2018-01-08 22:19:19 +03:00
|
|
|
var activity = new EProgressBar(_pageBusyDialog)
|
|
|
|
{
|
|
|
|
Style = "process_large",
|
|
|
|
IsPulseMode = true,
|
|
|
|
};
|
|
|
|
activity.PlayPulse();
|
|
|
|
activity.Show();
|
|
|
|
|
|
|
|
_pageBusyDialog.Content = activity;
|
|
|
|
|
|
|
|
}
|
|
|
|
_pageBusyCount = Math.Max(0, enabled ? _pageBusyCount + 1 : _pageBusyCount - 1);
|
|
|
|
if (_pageBusyCount > 0)
|
|
|
|
{
|
|
|
|
_pageBusyDialog.Show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_pageBusyDialog.Dismiss();
|
|
|
|
_pageBusyDialog = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AlertSignalNameHandler(Page sender, AlertArguments arguments)
|
|
|
|
{
|
2018-02-07 13:33:14 +03:00
|
|
|
// Verify that the page making the request is child of this platform
|
2018-01-08 22:19:19 +03:00
|
|
|
if (!PageIsChildOfPlatform(sender))
|
|
|
|
return;
|
|
|
|
|
2018-06-22 14:16:22 +03:00
|
|
|
Native.Dialog alert = Native.Dialog.CreateDialog(Forms.NativeParent, (arguments.Accept != null));
|
|
|
|
|
2018-01-08 22:19:19 +03:00
|
|
|
alert.Title = arguments.Title;
|
|
|
|
var message = arguments.Message.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace(Environment.NewLine, "<br>");
|
2018-06-22 14:16:22 +03:00
|
|
|
alert.Message = message;
|
2018-01-08 22:19:19 +03:00
|
|
|
|
|
|
|
EButton cancel = new EButton(alert) { Text = arguments.Cancel };
|
|
|
|
alert.NegativeButton = cancel;
|
|
|
|
cancel.Clicked += (s, evt) =>
|
|
|
|
{
|
|
|
|
arguments.SetResult(false);
|
|
|
|
alert.Dismiss();
|
|
|
|
};
|
|
|
|
|
|
|
|
if (arguments.Accept != null)
|
|
|
|
{
|
|
|
|
EButton ok = new EButton(alert) { Text = arguments.Accept };
|
|
|
|
alert.NeutralButton = ok;
|
|
|
|
ok.Clicked += (s, evt) =>
|
|
|
|
{
|
|
|
|
arguments.SetResult(true);
|
|
|
|
alert.Dismiss();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
alert.BackButtonPressed += (s, evt) =>
|
|
|
|
{
|
|
|
|
arguments.SetResult(false);
|
|
|
|
alert.Dismiss();
|
|
|
|
};
|
|
|
|
|
|
|
|
alert.Show();
|
2018-04-09 05:15:23 +03:00
|
|
|
_alerts.Add(alert);
|
|
|
|
alert.Dismissed += (s, e) => _alerts.Remove(alert);
|
2018-01-08 22:19:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionSheetSignalNameHandler(Page sender, ActionSheetArguments arguments)
|
|
|
|
{
|
|
|
|
// Verify that the page making the request is child of this platform
|
|
|
|
if (!PageIsChildOfPlatform(sender))
|
|
|
|
return;
|
|
|
|
|
2018-06-22 14:16:22 +03:00
|
|
|
Native.Dialog alert = Native.Dialog.CreateDialog(Forms.NativeParent);
|
2018-01-08 22:19:19 +03:00
|
|
|
|
|
|
|
alert.Title = arguments.Title;
|
|
|
|
Box box = new Box(alert);
|
|
|
|
|
|
|
|
if (null != arguments.Destruction)
|
|
|
|
{
|
|
|
|
Native.Button destruction = new Native.Button(alert)
|
|
|
|
{
|
|
|
|
Text = arguments.Destruction,
|
2018-06-22 14:16:22 +03:00
|
|
|
Style = ButtonStyle.Text,
|
2018-01-08 22:19:19 +03:00
|
|
|
TextColor = EColor.Red,
|
|
|
|
AlignmentX = -1
|
|
|
|
};
|
|
|
|
destruction.Clicked += (s, evt) =>
|
|
|
|
{
|
|
|
|
arguments.SetResult(arguments.Destruction);
|
|
|
|
alert.Dismiss();
|
|
|
|
};
|
|
|
|
destruction.Show();
|
|
|
|
box.PackEnd(destruction);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (string buttonName in arguments.Buttons)
|
|
|
|
{
|
|
|
|
Native.Button button = new Native.Button(alert)
|
|
|
|
{
|
|
|
|
Text = buttonName,
|
2018-06-22 14:16:22 +03:00
|
|
|
Style = ButtonStyle.Text,
|
2018-01-08 22:19:19 +03:00
|
|
|
AlignmentX = -1
|
|
|
|
};
|
|
|
|
button.Clicked += (s, evt) =>
|
|
|
|
{
|
|
|
|
arguments.SetResult(buttonName);
|
|
|
|
alert.Dismiss();
|
|
|
|
};
|
|
|
|
button.Show();
|
|
|
|
box.PackEnd(button);
|
|
|
|
}
|
|
|
|
|
|
|
|
box.Show();
|
|
|
|
alert.Content = box;
|
|
|
|
|
|
|
|
if (null != arguments.Cancel)
|
|
|
|
{
|
|
|
|
EButton cancel = new EButton(Forms.NativeParent) { Text = arguments.Cancel };
|
|
|
|
alert.NegativeButton = cancel;
|
|
|
|
cancel.Clicked += (s, evt) =>
|
|
|
|
{
|
|
|
|
alert.Dismiss();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
alert.BackButtonPressed += (s, evt) =>
|
|
|
|
{
|
|
|
|
alert.Dismiss();
|
|
|
|
};
|
|
|
|
|
|
|
|
alert.Show();
|
2018-04-09 05:15:23 +03:00
|
|
|
|
|
|
|
_alerts.Add(alert);
|
|
|
|
alert.Dismissed += (s, e) => _alerts.Remove(alert);
|
2018-01-08 22:19:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PageIsChildOfPlatform(Page page)
|
|
|
|
{
|
2019-03-21 13:03:50 +03:00
|
|
|
var parent = page.AncestorToRoot();
|
|
|
|
return Page == parent || _navModel.Roots.Contains(parent);
|
2018-01-08 22:19:19 +03:00
|
|
|
}
|
2019-02-12 23:27:00 +03:00
|
|
|
|
|
|
|
SizeRequest IPlatform.GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint)
|
|
|
|
{
|
|
|
|
return Platform.GetNativeSize(view, widthConstraint, heightConstraint);
|
|
|
|
}
|
2017-12-04 17:30:43 +03:00
|
|
|
}
|
|
|
|
}
|