1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

stub out more add/edit page stuff

This commit is contained in:
Kyle Spearrin
2019-05-07 12:29:02 -04:00
parent 13267ff83d
commit a236d7fbb1
3 changed files with 128 additions and 874 deletions

View File

@@ -1,51 +1,36 @@
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms;
namespace Bit.App.Pages
{
public partial class AddEditPage : BaseContentPage
{
private readonly IBroadcasterService _broadcasterService;
private AddEditPageViewModel _vm;
public AddEditPage(string cipherId)
public AddEditPage(
string cipherId = null,
string folderId = null,
string collectionId = null,
string organizationId = null)
{
InitializeComponent();
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
_vm = BindingContext as AddEditPageViewModel;
_vm.Page = this;
_vm.CipherId = cipherId;
_vm.FolderId = folderId;
_vm.OrganizationId = organizationId;
_vm.Init();
SetActivityIndicator();
}
protected override async void OnAppearing()
{
base.OnAppearing();
_broadcasterService.Subscribe(nameof(ViewPage), async (message) =>
{
if(message.Command == "syncCompleted")
{
var data = message.Data as Dictionary<string, object>;
if(data.ContainsKey("successfully"))
{
var success = data["successfully"] as bool?;
if(success.HasValue && success.Value)
{
await _vm.LoadAsync();
}
}
}
});
await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync());
}
protected override void OnDisappearing()
{
base.OnDisappearing();
_broadcasterService.Unsubscribe(nameof(ViewPage));
_vm.CleanUp();
}
private async void PasswordHistory_Tapped(object sender, System.EventArgs e)
@@ -55,5 +40,13 @@ namespace Bit.App.Pages
await Navigation.PushModalAsync(new NavigationPage(new PasswordHistoryPage(_vm.CipherId)));
}
}
private async void Save_Clicked(object sender, System.EventArgs e)
{
if(DoOnce())
{
await _vm.SubmitAsync();
}
}
}
}