1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-16 08:13:20 +00:00

Generate password cell added to add/edit site pages. Delete callback from generate password page.

This commit is contained in:
Kyle Spearrin
2016-07-07 00:27:29 -04:00
parent b7869ed763
commit 6b996e3a98
3 changed files with 74 additions and 29 deletions

View File

@@ -16,13 +16,15 @@ namespace Bit.App.Pages
private readonly IPasswordGenerationService _passwordGenerationService;
private readonly ISettings _settings;
private readonly IClipboardService _clipboardService;
private readonly Action<string> _passwordValueAction;
public ToolsPasswordGeneratorPage()
public ToolsPasswordGeneratorPage(Action<string> passwordValueAction = null)
{
_userDialogs = Resolver.Resolve<IUserDialogs>();
_passwordGenerationService = Resolver.Resolve<IPasswordGenerationService>();
_settings = Resolver.Resolve<ISettings>();
_clipboardService = Resolver.Resolve<IClipboardService>();
_passwordValueAction = passwordValueAction;
Init();
}
@@ -57,8 +59,6 @@ namespace Bit.App.Pages
regenerateCell.Tapped += RegenerateCell_Tapped; ;
var copyCell = new ExtendedTextCell { Text = "Copy Password", TextColor = buttonColor };
copyCell.Tapped += CopyCell_Tapped;
var saveCell = new ExtendedTextCell { Text = "Save Password", TextColor = buttonColor };
saveCell.Tapped += SaveCell_Tapped;
var table = new ExtendedTableView
{
@@ -78,10 +78,6 @@ namespace Bit.App.Pages
{
regenerateCell,
copyCell
},
new TableSection
{
saveCell
}
}
};
@@ -90,7 +86,7 @@ namespace Bit.App.Pages
{
table.RowHeight = -1;
table.EstimatedRowHeight = 44;
ToolbarItems.Add(new DismissModalToolBarItem(this, "Close"));
ToolbarItems.Add(new DismissModalToolBarItem(this, _passwordValueAction == null ? "Close" : "Cancel"));
}
var stackLayout = new StackLayout
@@ -108,6 +104,15 @@ namespace Bit.App.Pages
VerticalOptions = LayoutOptions.FillAndExpand
};
var selectToolBarItem = new ToolbarItem("Select", null, async () =>
{
_passwordValueAction(Password.Text);
await Navigation.PopModalAsync();
}, ToolbarItemOrder.Default, 0);
ToolbarItems.Add(selectToolBarItem);
Title = "Generate Password";
Content = scrollView;
BindingContext = Model;
@@ -130,11 +135,6 @@ namespace Bit.App.Pages
Model.Password = _passwordGenerationService.GeneratePassword();
}
private void SaveCell_Tapped(object sender, EventArgs e)
{
}
private void CopyCell_Tapped(object sender, EventArgs e)
{
CopyPassword();