mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 23:31:52 +03:00
added cell options to password generation page
This commit is contained in:
parent
5b339c63f4
commit
e0b9261a28
4 changed files with 153 additions and 48 deletions
|
@ -223,36 +223,6 @@
|
|||
<viewControllerLayoutGuide type="top" id="4571"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="4572"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="4581">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" minimumFontSize="10" id="4811" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="15" y="79" width="570" height="20.5"/>
|
||||
<color key="backgroundColor" colorSpace="calibratedRGB" red="0" green="0" blue="0" alpha="0"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<containerView contentMode="scaleToFill" id="4900" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="0.0" y="109.5" width="600" height="490.5"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
<segue id="5421" destination="4912" kind="embed"/>
|
||||
</connections>
|
||||
</containerView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint id="4853" firstItem="4811" firstAttribute="leading" secondItem="4581" secondAttribute="leading" constant="15"/>
|
||||
<constraint id="4864" firstItem="4581" firstAttribute="trailing" secondItem="4811" secondAttribute="trailing" constant="15"/>
|
||||
<constraint id="4875" firstItem="4811" firstAttribute="top" secondItem="4571" secondAttribute="bottom" constant="15"/>
|
||||
<constraint id="4907" firstItem="4900" firstAttribute="leading" secondItem="4581" secondAttribute="leading"/>
|
||||
<constraint id="4908" firstItem="4581" firstAttribute="trailing" secondItem="4900" secondAttribute="trailing"/>
|
||||
<constraint id="4909" firstItem="4900" firstAttribute="top" secondItem="4811" secondAttribute="bottom" constant="10"/>
|
||||
<constraint id="4910" firstItem="4572" firstAttribute="top" secondItem="4900" secondAttribute="bottom"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Generate Password" id="4580">
|
||||
<barButtonItem key="leftBarButtonItem" title="Cancel" id="4807">
|
||||
<color key="tintColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
||||
|
@ -270,9 +240,38 @@
|
|||
<connections>
|
||||
<outlet property="CancelBarButton" destination="4807" id="name-outlet-4807"/>
|
||||
<outlet property="SelectBarButton" destination="4808" id="name-outlet-4808"/>
|
||||
<outlet property="BaseView" destination="4581" id="name-outlet-4581"/>
|
||||
<outlet property="PasswordLabel" destination="4811" id="name-outlet-4811"/>
|
||||
<outlet property="BaseView" destination="4930" id="name-outlet-4930"/>
|
||||
<outlet property="OptionsContainer" destination="4933" id="name-outlet-4933"/>
|
||||
<outlet property="PasswordLabel" destination="4940" id="name-outlet-4940"/>
|
||||
</connections>
|
||||
<view contentMode="scaleToFill" id="4930" key="view">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<subviews>
|
||||
<containerView contentMode="scaleToFill" id="4933" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="0.0" y="119.5" width="600" height="480.5"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
<segue id="6480" destination="4912" kind="embed"/>
|
||||
</connections>
|
||||
</containerView>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" minimumFontSize="10" id="4940" translatesAutoresizingMaskIntoConstraints="NO" textAlignment="center">
|
||||
<rect key="frame" x="15" y="99" width="570" height="20.5"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint id="6484" firstItem="4930" firstAttribute="trailing" secondItem="4933" secondAttribute="trailing"/>
|
||||
<constraint id="6485" firstItem="4933" firstAttribute="top" secondItem="4940" secondAttribute="bottom"/>
|
||||
<constraint id="6486" firstItem="4933" firstAttribute="leading" secondItem="4930" secondAttribute="leading"/>
|
||||
<constraint id="6487" firstItem="4940" firstAttribute="leading" secondItem="4930" secondAttribute="leading" constant="15"/>
|
||||
<constraint id="6488" firstItem="4940" firstAttribute="top" secondItem="4571" secondAttribute="bottom" constant="35"/>
|
||||
<constraint id="6489" firstItem="4930" firstAttribute="trailing" secondItem="4940" secondAttribute="trailing" constant="15"/>
|
||||
<constraint id="6490" firstItem="4572" firstAttribute="top" secondItem="4933" secondAttribute="bottom"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4582" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
|
@ -281,8 +280,8 @@
|
|||
<scene sceneID="4911">
|
||||
<objects>
|
||||
<tableViewController id="4912" sceneMemberID="viewController">
|
||||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="4913">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="490.5"/>
|
||||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="4913">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="480.5"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
|
@ -290,13 +289,11 @@
|
|||
<outlet property="delegate" destination="4912" id="4915"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<connections>
|
||||
<outlet property="Table" destination="4913" id="name-outlet-4913"/>
|
||||
</connections>
|
||||
<connections/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4918" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="4678" y="661"/>
|
||||
<point key="canvasLocation" x="4676" y="618"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
|
|
|
@ -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<IPasswordGenerationService>();
|
||||
_settings = Resolver.Resolve<ISettings>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue