2016-11-26 01:11:28 +03:00
|
|
|
|
using Bit.App.Resources;
|
|
|
|
|
using System;
|
2016-05-13 07:11:32 +03:00
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Controls
|
|
|
|
|
{
|
|
|
|
|
public class DismissModalToolBarItem : ToolbarItem
|
|
|
|
|
{
|
|
|
|
|
private readonly ContentPage _page;
|
2016-07-23 22:32:11 +03:00
|
|
|
|
private readonly Action _cancelClickedAction;
|
2016-05-13 07:11:32 +03:00
|
|
|
|
|
2016-07-23 22:32:11 +03:00
|
|
|
|
public DismissModalToolBarItem(ContentPage page, string text = null, Action cancelClickedAction = null)
|
2016-05-13 07:11:32 +03:00
|
|
|
|
{
|
2016-07-23 22:32:11 +03:00
|
|
|
|
_cancelClickedAction = cancelClickedAction;
|
2016-05-13 07:11:32 +03:00
|
|
|
|
_page = page;
|
2016-11-26 01:11:28 +03:00
|
|
|
|
Text = text ?? AppResources.Close;
|
2016-05-13 07:11:32 +03:00
|
|
|
|
Clicked += ClickedItem;
|
|
|
|
|
Priority = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void ClickedItem(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-07-23 22:32:11 +03:00
|
|
|
|
_cancelClickedAction?.Invoke();
|
2016-05-13 07:11:32 +03:00
|
|
|
|
await _page.Navigation.PopModalAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|