Skip to content

Navigation

Kirill edited this page Feb 13, 2018 · 3 revisions

The plugin supports some ways of navigation but I recommend to use Rg.Plugins.Popup.Services.PopupNavigation.Instance.

You must initialize the plugin before to use it.

PopupNavigation.Instance (IPopupNavigation)

You should use it in priority. It is flexible solution for dependency injection, unit tests and etc.

namespace Rg.Plugins.Popup.Contracts
{
    public interface IPopupNavigation
    {
        // List of PopupPages which are in the scree
        IReadOnlyList<PopupPage> PopupStack { get; }

        // Open a PopupPage
        Task PushAsync(PopupPage page, bool animate = true);

        // Close the last PopupPage int the PopupStack
        Task PopAsync(bool animate = true);

        // Close all PopupPages in the PopupStack
        Task PopAllAsync(bool animate = true);

        // Close an one PopupPage in the PopupStack even if the page is not the last
        Task RemovePageAsync(PopupPage page, bool animate = true);
    }
}

Xamarin.Forms.INavigation (NavigationExtension)

I don't recommend to use it but you can if you want. To apply it you should use Rg.Plugins.Popup.Extensions.NavigationExtension. It allows to use the popup navigation in your xamarin forms pages.

using Rg.Plugins.Popup.Pages;
using Xamarin.Forms;

using Rg.Plugins.Popup.Extensions;

namespace Demo.Pages
{
    public class MyContentPage : ContentPage
    {
        private async void ExampleMethod(PopupPage page)
        {
            // Open a PopupPage
            await Navigation.PushPopupAsync(page);

            // Close the last PopupPage int the PopupStack
            await Navigation.PopPopupAsync();

            // Close all PopupPages in the PopupStack
            await Navigation.PopAllPopupAsync();

            // Close an one PopupPage in the PopupStack even if the page is not the last
            await Navigation.RemovePopupPageAsync(page);
        }
    }
}

Clone this wiki locally