Skip to content

Instantly share code, notes, and snippets.

@JoeM-RP
Created August 15, 2018 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoeM-RP/b5b8481d8232ada2fd3a73923b3a4cdc to your computer and use it in GitHub Desktop.
Save JoeM-RP/b5b8481d8232ada2fd3a73923b3a4cdc to your computer and use it in GitHub Desktop.
using System;
using System.Reactive.Disposables;
using RxUIForms.Models;
using Xamarin.Forms;
namespace RxUIForms.Helpers
{
public static class ActionHandler
{
/// <summary>
/// Registers the action handler to show an Action Sheet user interaction
/// </summary>
/// <param name="page">Page.</param>
/// <param name="disposable">Disposable.</param>
public static void RegisterActionHandler(Page page, CompositeDisposable disposable)
{
Interactions.Actions.RegisterHandler(async (interaction) =>
{
var sheet = interaction.Input;
var result = await page.DisplayActionSheet(sheet.Title, sheet.Cancel, null, sheet.Options);
interaction.SetOutput(result);
}).DisposeWith(disposable);
}
/// <summary>
/// Registers the action handler to show an Action Sheet user interaction with Destroy option
/// </summary>
/// <param name="page">Page.</param>
/// <param name="destroy">Destroy.</param>
/// <param name="disposable">Disposable.</param>
public static void RegisterActionHandlerWithDestroy(Page page, string destroy, CompositeDisposable disposable)
{
Interactions.Actions.RegisterHandler(async (interaction) =>
{
var sheet = interaction.Input;
var result = await page.DisplayActionSheet(sheet.Title, sheet.Cancel, destroy, sheet.Options);
interaction.SetOutput(result);
}).DisposeWith(disposable);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment