Awesome Open Source
Awesome Open Source

Prism.Plugin.PageDialogs

The Page Dialog plugin for Prims.Forms offers you the ability to quickly and easily add a Page Dialog Service that doesn't rely on the bland dialogs built into Xamarin for each platform. Instead you are able to provide a custom look and feel for each of your projects.

Build Status

Package Version
Prism.Plugin.PageDialogs 2

Platform Initialization

This plugin itself requires no platform initialization however you will need to initialize Rg.Plugin.Popup

In your Prism Application's RegisterTypes you need to do the following:

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
    containerRegistry.RegisterPopupDialogService();

    // If you're using Prism.Plugin.Popups you don't need to do anything else
    // otherwise you can simply add the following:
    containerRegistry.RegisterInstance<IPopupNavigation>(PopupNavigation.Instance);
}

Customized Look & Feel

The built in ActionSheetPage and AlertPage have static properties which you can set at App startup to control the look of the built in pages.

protected override void OnInitialized()
{
    AlertPage.DefaultTitleBarBackgroundColor = (Color)Resources["PrimaryColor"];
    AlertPage.DefaultTitleStyle = (Style)Resources["AlertTitleStyle"];
    AlertPage.DefaultMessageStyle = (Style)Resources["AlertMessageStyle"];
}

Adding a custom Factory

In the event that simply providing custom default styles isn't enough, you can implement a custom IPopupDialogFactory. To control which style Dialog you simply need to set the Style property in either the ActionSheetRequest or AlertDialogRequest. The default PopupDialogFactory ignores the style key. The intent is that you are able to create an Alert or Action Sheet Dialog based on a Style key using.

public class MyFactory : IPopupDialogFactory
{
    public ActionSheetPageBase GetActionSheet(ActionSheetRequest request)
    {
        switch(request.Style)
        {
            case "Foo":
                return new FooActionSheetPage(request);
            case "Bar":
                return new BarActionSheetPage(request);
            default:
                new ActionSheetPage(request);
        }
    }

    public AlertPageBase GetAlertPage(AlertDialogRequest request)
    {
        switch(request.Style)
        {
            case "Foo":
                return new FooAlertPage(request);
            case "Bar":
                return new BarAlertPage(request);
            default:
                return AlertPage(request);
        }
    }
}

When using a custom Factory you can easily register both your factory and the PopupDialogService

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
    containerRegistry.RegisterPopupDialogServiceWithFactory<MyFactory>();
}

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c-sharp (11,773
xamarin-forms (136
prism (20

Find Open Source By Browsing 7,000 Topics Across 59 Categories