Created
August 15, 2018 03:49
-
-
Save JoeM-RP/b5b8481d8232ada2fd3a73923b3a4cdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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