bitwarden-android/src/App/Pages/Vault/AutofillCiphersPage.xaml.cs

67 lines
2 KiB
C#
Raw Normal View History

2019-05-17 13:14:26 -04:00
using Bit.App.Models;
2019-05-17 14:46:31 -04:00
using Bit.Core.Enums;
2019-05-17 13:14:26 -04:00
using Xamarin.Forms;
namespace Bit.App.Pages
{
public partial class AutofillCiphersPage : BaseContentPage
{
private AutofillCiphersPageViewModel _vm;
private readonly AppOptions _appOptions;
public AutofillCiphersPage(AppOptions appOptions)
{
_appOptions = appOptions;
InitializeComponent();
_vm = BindingContext as AutofillCiphersPageViewModel;
_vm.Page = this;
2019-05-17 14:58:42 -04:00
_fab.Clicked = AddButton_Clicked;
2019-05-17 13:14:26 -04:00
_vm.Init(appOptions);
}
protected async override void OnAppearing()
{
base.OnAppearing();
await LoadOnAppearedAsync(_mainLayout, false, async () =>
{
await _vm.LoadAsync();
}, _mainContent);
}
private async void RowSelected(object sender, SelectedItemChangedEventArgs e)
{
((ListView)sender).SelectedItem = null;
if(!DoOnce())
{
return;
}
if(e.SelectedItem is GroupingsPageListItem item && item.Cipher != null)
{
2019-05-17 14:46:31 -04:00
await _vm.SelectCipherAsync(item.Cipher, item.FuzzyAutofill);
2019-05-17 13:14:26 -04:00
}
}
2019-05-17 14:46:31 -04:00
private async void AddButton_Clicked(object sender, System.EventArgs e)
2019-05-17 13:14:26 -04:00
{
2019-05-17 14:46:31 -04:00
if(!DoOnce())
{
return;
}
if(_appOptions.FillType.HasValue && _appOptions.FillType != CipherType.Login)
{
2019-05-17 15:24:15 -04:00
var pageForOther = new AddEditPage(type: _appOptions.FillType, fromAutofill: true);
2019-05-17 14:46:31 -04:00
await Navigation.PushModalAsync(new NavigationPage(pageForOther));
return;
}
2019-05-17 15:24:15 -04:00
var pageForLogin = new AddEditPage(null, CipherType.Login, uri: _vm.Uri, name: _vm.Name,
fromAutofill: true);
2019-05-17 14:46:31 -04:00
await Navigation.PushModalAsync(new NavigationPage(pageForLogin));
2019-05-17 13:14:26 -04:00
}
private void Search_Clicked(object sender, System.EventArgs e)
{
}
}
}