diff --git a/src/iOS.Extension/MainInterface.storyboard b/src/iOS.Extension/MainInterface.storyboard
index d2d4bda10..cb206abc0 100644
--- a/src/iOS.Extension/MainInterface.storyboard
+++ b/src/iOS.Extension/MainInterface.storyboard
@@ -223,36 +223,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -270,9 +240,38 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -281,8 +280,8 @@
-
-
+
+
@@ -290,13 +289,11 @@
-
-
-
+
-
+
diff --git a/src/iOS.Extension/PasswordGeneratorViewController.cs b/src/iOS.Extension/PasswordGeneratorViewController.cs
index 0a123d03d..c0c2b51ca 100644
--- a/src/iOS.Extension/PasswordGeneratorViewController.cs
+++ b/src/iOS.Extension/PasswordGeneratorViewController.cs
@@ -13,16 +13,25 @@ using XLabs.Ioc;
using Bit.App;
using Plugin.Connectivity.Abstractions;
using Bit.iOS.Core.Utilities;
+using Plugin.Settings.Abstractions;
namespace Bit.iOS.Extension
{
public partial class PasswordGeneratorViewController : UIViewController
{
+ private IPasswordGenerationService _passwordGenerationService;
+ private ISettings _settings;
+
public PasswordGeneratorViewController(IntPtr handle) : base(handle)
{ }
public Context Context { get; set; }
public SiteAddViewController Parent { get; set; }
+ public UITableViewController OptionsTableViewController { get; set; }
+ public SwitchTableViewCell UppercaseCell { get; set; } = new SwitchTableViewCell("A-Z");
+ public SwitchTableViewCell LowercaseCell { get; set; } = new SwitchTableViewCell("a-z");
+ public SwitchTableViewCell NumbersCell { get; set; } = new SwitchTableViewCell("0-9");
+ public SwitchTableViewCell SpecialCell { get; set; } = new SwitchTableViewCell("!@#$%^&*");
public override void ViewWillAppear(bool animated)
{
@@ -33,8 +42,29 @@ namespace Bit.iOS.Extension
public override void ViewDidLoad()
{
+ _passwordGenerationService = Resolver.Resolve();
+ _settings = Resolver.Resolve();
+
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
+ PasswordLabel.Text = _passwordGenerationService.GeneratePassword();
+ PasswordLabel.Font = UIFont.FromName("Courier", 17);
+
+ var controller = ChildViewControllers.LastOrDefault();
+ if(controller != null)
+ {
+ OptionsTableViewController = controller as UITableViewController;
+ }
+
+ if(OptionsTableViewController != null)
+ {
+ OptionsTableViewController.TableView.RowHeight = UITableView.AutomaticDimension;
+ OptionsTableViewController.TableView.EstimatedRowHeight = 70;
+ OptionsTableViewController.TableView.Source = new TableSource(this);
+ OptionsTableViewController.TableView.AllowsSelection = true;
+ OptionsTableViewController.View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
+ }
+
base.ViewDidLoad();
}
@@ -59,6 +89,50 @@ namespace Bit.iOS.Extension
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
+ if(indexPath.Section == 0)
+ {
+ var cell = new UITableViewCell();
+ cell.TextLabel.TextColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f);
+ if(indexPath.Row == 0)
+ {
+ cell.TextLabel.Text = "Regenerate Password";
+ }
+ else if(indexPath.Row == 1)
+ {
+ cell.TextLabel.Text = "Copy Password";
+ }
+ return cell;
+ }
+
+ if(indexPath.Row == 0)
+ {
+ // TODO: Length slider
+ }
+ else if(indexPath.Row == 1)
+ {
+ return _controller.UppercaseCell;
+ }
+ else if(indexPath.Row == 2)
+ {
+ return _controller.LowercaseCell;
+ }
+ else if(indexPath.Row == 3)
+ {
+ return _controller.NumbersCell;
+ }
+ else if(indexPath.Row == 4)
+ {
+ return _controller.SpecialCell;
+ }
+ else if(indexPath.Row == 5)
+ {
+ // TODO: Min numbers stepper
+ }
+ else if(indexPath.Row == 6)
+ {
+ // TODO: Min special stepper
+ }
+
return new UITableViewCell();
}
@@ -69,23 +143,17 @@ namespace Bit.iOS.Extension
public override nint NumberOfSections(UITableView tableView)
{
- return 3;
+ return 2;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
if(section == 0)
- {
- return 5;
- }
- else if(section == 1)
{
return 2;
}
- else
- {
- return 1;
- }
+
+ return 7;
}
public override nfloat GetHeightForHeader(UITableView tableView, nint section)
@@ -95,11 +163,28 @@ namespace Bit.iOS.Extension
public override string TitleForHeader(UITableView tableView, nint section)
{
+ if(section == 1)
+ {
+ return "Options";
+ }
+
return null;
}
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
+ if(indexPath.Section == 0)
+ {
+ if(indexPath.Row == 0)
+ {
+ _controller.PasswordLabel.Text = _controller._passwordGenerationService.GeneratePassword();
+ }
+ else if(indexPath.Row == 1)
+ {
+ // TODO: copy to clipboard
+ }
+ }
+
tableView.DeselectRow(indexPath, true);
tableView.EndEditing(true);
}
diff --git a/src/iOS.Extension/PasswordGeneratorViewController.designer.cs b/src/iOS.Extension/PasswordGeneratorViewController.designer.cs
index dc7c24eba..badbc7a9e 100644
--- a/src/iOS.Extension/PasswordGeneratorViewController.designer.cs
+++ b/src/iOS.Extension/PasswordGeneratorViewController.designer.cs
@@ -22,6 +22,10 @@ namespace Bit.iOS.Extension
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UIBarButtonItem CancelBarButton { get; set; }
+ [Outlet]
+ [GeneratedCode ("iOS Designer", "1.0")]
+ UIKit.UIView OptionsContainer { get; set; }
+
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UILabel PasswordLabel { get; set; }
@@ -50,6 +54,11 @@ namespace Bit.iOS.Extension
CancelBarButton = null;
}
+ if (OptionsContainer != null) {
+ OptionsContainer.Dispose ();
+ OptionsContainer = null;
+ }
+
if (PasswordLabel != null) {
PasswordLabel.Dispose ();
PasswordLabel = null;
diff --git a/src/iOS.Extension/SiteAddViewController.cs b/src/iOS.Extension/SiteAddViewController.cs
index ee7f371e6..02c347d6f 100644
--- a/src/iOS.Extension/SiteAddViewController.cs
+++ b/src/iOS.Extension/SiteAddViewController.cs
@@ -159,6 +159,20 @@ namespace Bit.iOS.Extension
});
}
+ public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
+ {
+ var navController = segue.DestinationViewController as UINavigationController;
+ if(navController != null)
+ {
+ var passwordGeneratorController = navController.TopViewController as PasswordGeneratorViewController;
+ if(passwordGeneratorController != null)
+ {
+ passwordGeneratorController.Context = Context;
+ passwordGeneratorController.Parent = this;
+ }
+ }
+ }
+
public void DisplayAlert(string title, string message, string accept)
{
var alert = Dialogs.CreateAlert(title, message, accept);
@@ -275,7 +289,7 @@ namespace Bit.iOS.Extension
if(indexPath.Section == 0 && indexPath.Row == 4)
{
- // Generate password selected
+ _controller.PerformSegue("passwordGeneratorSegue", this);
}
var cell = tableView.CellAt(indexPath);