mirror of
https://github.com/bitwarden/android.git
synced 2024-12-20 08:12:26 +03:00
Stepper table view cell. Min numbers/special to password generator.
This commit is contained in:
parent
49cb984373
commit
afd22b6462
5 changed files with 86 additions and 13 deletions
39
src/iOS.Core/Views/StepperTableViewCell.cs
Normal file
39
src/iOS.Core/Views/StepperTableViewCell.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using UIKit;
|
||||||
|
|
||||||
|
namespace Bit.iOS.Core.Views
|
||||||
|
{
|
||||||
|
public class StepperTableViewCell : UITableViewCell
|
||||||
|
{
|
||||||
|
// Give some space to the right of the detail in between the spacer.
|
||||||
|
// This is a bit of a hack, but I did not see a way to specify a margin on the
|
||||||
|
// detaul DetailTextLabel or AccessoryView
|
||||||
|
private string _detailRightSpace = "\t";
|
||||||
|
|
||||||
|
public StepperTableViewCell(string labelName, double value, double min, double max, double increment)
|
||||||
|
: base(UITableViewCellStyle.Value1, nameof(SwitchTableViewCell))
|
||||||
|
{
|
||||||
|
TextLabel.Text = labelName;
|
||||||
|
DetailTextLabel.Text = string.Concat(value.ToString(), _detailRightSpace);
|
||||||
|
DetailTextLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);
|
||||||
|
|
||||||
|
Stepper = new UIStepper
|
||||||
|
{
|
||||||
|
TintColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f),
|
||||||
|
Value = value,
|
||||||
|
MinimumValue = min,
|
||||||
|
MaximumValue = max
|
||||||
|
};
|
||||||
|
Stepper.ValueChanged += Stepper_ValueChanged;
|
||||||
|
|
||||||
|
AccessoryView = Stepper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Stepper_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DetailTextLabel.Text = string.Concat(Stepper.Value.ToString(), _detailRightSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UIStepper Stepper { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -70,6 +70,7 @@
|
||||||
<Compile Include="Utilities\Dialogs.cs" />
|
<Compile Include="Utilities\Dialogs.cs" />
|
||||||
<Compile Include="Views\ISelectable.cs" />
|
<Compile Include="Views\ISelectable.cs" />
|
||||||
<Compile Include="Views\PickerTableViewCell.cs" />
|
<Compile Include="Views\PickerTableViewCell.cs" />
|
||||||
|
<Compile Include="Views\StepperTableViewCell.cs" />
|
||||||
<Compile Include="Views\SwitchTableViewCell.cs" />
|
<Compile Include="Views\SwitchTableViewCell.cs" />
|
||||||
<Compile Include="Views\FormEntryTableViewCell.cs" />
|
<Compile Include="Views\FormEntryTableViewCell.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<objects>
|
<objects>
|
||||||
<navigationController definesPresentationContext="YES" id="64" sceneMemberID="viewController">
|
<navigationController definesPresentationContext="YES" id="64" sceneMemberID="viewController">
|
||||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="67" translucent="NO" hidden="YES">
|
<navigationBar key="navigationBar" contentMode="scaleToFill" id="67" translucent="NO" hidden="YES">
|
||||||
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
|
<rect key="frame" x="0.0" y="20" width="880" height="44"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||||
</navigationBar>
|
</navigationBar>
|
||||||
<connections>
|
<connections>
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="oCZ-GQ-aOK" sceneMemberID="viewController">
|
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="oCZ-GQ-aOK" sceneMemberID="viewController">
|
||||||
<toolbarItems/>
|
<toolbarItems/>
|
||||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="8A5-AR-QHS" translucent="NO">
|
<navigationBar key="navigationBar" contentMode="scaleToFill" id="8A5-AR-QHS" translucent="NO">
|
||||||
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
|
<rect key="frame" x="0.0" y="20" width="880" height="44"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<textAttributes key="titleTextAttributes">
|
<textAttributes key="titleTextAttributes">
|
||||||
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
<navigationController definesPresentationContext="YES" id="1845" sceneMemberID="viewController">
|
<navigationController definesPresentationContext="YES" id="1845" sceneMemberID="viewController">
|
||||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="1848" translucent="NO">
|
<navigationBar key="navigationBar" contentMode="scaleToFill" id="1848" translucent="NO">
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||||
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
|
<rect key="frame" x="0.0" y="20" width="880" height="44"/>
|
||||||
<textAttributes key="titleTextAttributes">
|
<textAttributes key="titleTextAttributes">
|
||||||
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
||||||
</textAttributes>
|
</textAttributes>
|
||||||
|
@ -200,7 +200,7 @@
|
||||||
<navigationController definesPresentationContext="YES" id="4574" sceneMemberID="viewController">
|
<navigationController definesPresentationContext="YES" id="4574" sceneMemberID="viewController">
|
||||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="4577" translucent="NO">
|
<navigationBar key="navigationBar" contentMode="scaleToFill" id="4577" translucent="NO">
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||||
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
|
<rect key="frame" x="0.0" y="20" width="880" height="44"/>
|
||||||
<color key="barTintColor" colorSpace="calibratedRGB" red="0.23529411764705882" green="0.55294117647058827" blue="0.73725490196078436" alpha="1"/>
|
<color key="barTintColor" colorSpace="calibratedRGB" red="0.23529411764705882" green="0.55294117647058827" blue="0.73725490196078436" alpha="1"/>
|
||||||
<textAttributes key="titleTextAttributes">
|
<textAttributes key="titleTextAttributes">
|
||||||
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
||||||
|
@ -246,7 +246,7 @@
|
||||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<containerView contentMode="scaleToFill" id="4933" translatesAutoresizingMaskIntoConstraints="NO">
|
<containerView contentMode="scaleToFill" id="4933" translatesAutoresizingMaskIntoConstraints="NO">
|
||||||
<rect key="frame" x="0.0" y="119.5" width="600" height="480.5"/>
|
<rect key="frame" x="0.0" y="154.5" width="600" height="445.5"/>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||||
<connections>
|
<connections>
|
||||||
<segue id="6480" destination="4912" kind="embed"/>
|
<segue id="6480" destination="4912" kind="embed"/>
|
||||||
|
@ -262,7 +262,7 @@
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint id="6484" firstItem="4930" firstAttribute="trailing" secondItem="4933" secondAttribute="trailing"/>
|
<constraint id="6484" firstItem="4930" firstAttribute="trailing" secondItem="4933" secondAttribute="trailing"/>
|
||||||
<constraint id="6485" firstItem="4933" firstAttribute="top" secondItem="4940" secondAttribute="bottom"/>
|
<constraint id="6485" firstItem="4933" firstAttribute="top" secondItem="4940" secondAttribute="bottom" constant="35"/>
|
||||||
<constraint id="6486" firstItem="4933" firstAttribute="leading" secondItem="4930" secondAttribute="leading"/>
|
<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="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="6488" firstItem="4940" firstAttribute="top" secondItem="4571" secondAttribute="bottom" constant="35"/>
|
||||||
|
@ -279,7 +279,7 @@
|
||||||
<objects>
|
<objects>
|
||||||
<tableViewController id="4912" sceneMemberID="viewController">
|
<tableViewController id="4912" sceneMemberID="viewController">
|
||||||
<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">
|
<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"/>
|
<rect key="frame" x="0.0" y="0.0" width="600" height="445.5"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|
|
@ -14,6 +14,7 @@ using Bit.App;
|
||||||
using Plugin.Connectivity.Abstractions;
|
using Plugin.Connectivity.Abstractions;
|
||||||
using Bit.iOS.Core.Utilities;
|
using Bit.iOS.Core.Utilities;
|
||||||
using Plugin.Settings.Abstractions;
|
using Plugin.Settings.Abstractions;
|
||||||
|
using CoreGraphics;
|
||||||
|
|
||||||
namespace Bit.iOS.Extension
|
namespace Bit.iOS.Extension
|
||||||
{
|
{
|
||||||
|
@ -32,6 +33,8 @@ namespace Bit.iOS.Extension
|
||||||
public SwitchTableViewCell LowercaseCell { 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 NumbersCell { get; set; } = new SwitchTableViewCell("0-9");
|
||||||
public SwitchTableViewCell SpecialCell { get; set; } = new SwitchTableViewCell("!@#$%^&*");
|
public SwitchTableViewCell SpecialCell { get; set; } = new SwitchTableViewCell("!@#$%^&*");
|
||||||
|
public StepperTableViewCell MinNumbersCell { get; set; } = new StepperTableViewCell("Minimum Numbers", 1, 0, 5, 1);
|
||||||
|
public StepperTableViewCell MinSpecialCell { get; set; } = new StepperTableViewCell("Minimum Special", 1, 0, 5, 1);
|
||||||
|
|
||||||
public override void ViewWillAppear(bool animated)
|
public override void ViewWillAppear(bool animated)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +51,11 @@ namespace Bit.iOS.Extension
|
||||||
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
|
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
|
||||||
|
|
||||||
PasswordLabel.Text = _passwordGenerationService.GeneratePassword();
|
PasswordLabel.Text = _passwordGenerationService.GeneratePassword();
|
||||||
PasswordLabel.Font = UIFont.FromName("Courier", 17);
|
var descriptor = UIFontDescriptor.PreferredBody;
|
||||||
|
PasswordLabel.Font = UIFont.FromName("Courier", descriptor.PointSize * 1.3f);
|
||||||
|
PasswordLabel.LineBreakMode = UILineBreakMode.TailTruncation;
|
||||||
|
PasswordLabel.Lines = 1;
|
||||||
|
PasswordLabel.AdjustsFontSizeToFitWidth = false;
|
||||||
|
|
||||||
var controller = ChildViewControllers.LastOrDefault();
|
var controller = ChildViewControllers.LastOrDefault();
|
||||||
if(controller != null)
|
if(controller != null)
|
||||||
|
@ -126,11 +133,11 @@ namespace Bit.iOS.Extension
|
||||||
}
|
}
|
||||||
else if(indexPath.Row == 5)
|
else if(indexPath.Row == 5)
|
||||||
{
|
{
|
||||||
// TODO: Min numbers stepper
|
return _controller.MinNumbersCell;
|
||||||
}
|
}
|
||||||
else if(indexPath.Row == 6)
|
else if(indexPath.Row == 6)
|
||||||
{
|
{
|
||||||
// TODO: Min special stepper
|
return _controller.MinSpecialCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new UITableViewCell();
|
return new UITableViewCell();
|
||||||
|
@ -158,9 +165,27 @@ namespace Bit.iOS.Extension
|
||||||
|
|
||||||
public override nfloat GetHeightForHeader(UITableView tableView, nint section)
|
public override nfloat GetHeightForHeader(UITableView tableView, nint section)
|
||||||
{
|
{
|
||||||
|
if(section == 0)
|
||||||
|
{
|
||||||
|
return 0.00001f;
|
||||||
|
}
|
||||||
|
|
||||||
return UITableView.AutomaticDimension;
|
return UITableView.AutomaticDimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override UIView GetViewForHeader(UITableView tableView, nint section)
|
||||||
|
{
|
||||||
|
if(section == 0)
|
||||||
|
{
|
||||||
|
return new UIView(CGRect.Empty)
|
||||||
|
{
|
||||||
|
Hidden = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public override string TitleForHeader(UITableView tableView, nint section)
|
public override string TitleForHeader(UITableView tableView, nint section)
|
||||||
{
|
{
|
||||||
if(section == 1)
|
if(section == 1)
|
||||||
|
|
|
@ -108,18 +108,26 @@ namespace Bit.iOS.Extension
|
||||||
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
|
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
|
||||||
{
|
{
|
||||||
var cell = tableView.DequeueReusableCell(CellIdentifier);
|
var cell = tableView.DequeueReusableCell(CellIdentifier);
|
||||||
var item = _tableItems.ElementAt(indexPath.Row);
|
|
||||||
|
|
||||||
// if there are no cells to reuse, create a new one
|
// if there are no cells to reuse, create a new one
|
||||||
if(cell == null)
|
if(cell == null)
|
||||||
{
|
{
|
||||||
cell = new UITableViewCell(UITableViewCellStyle.Subtitle, CellIdentifier);
|
cell = new UITableViewCell(UITableViewCellStyle.Subtitle, CellIdentifier);
|
||||||
}
|
}
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WillDisplay( UITableView tableView, UITableViewCell cell, NSIndexPath indexPath )
|
||||||
|
{
|
||||||
|
if(cell == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var item = _tableItems.ElementAt( indexPath.Row );
|
||||||
cell.TextLabel.Text = item.Name;
|
cell.TextLabel.Text = item.Name;
|
||||||
cell.DetailTextLabel.Text = item.Username;
|
cell.DetailTextLabel.Text = item.Username;
|
||||||
cell.DetailTextLabel.TextColor = cell.DetailTextLabel.TintColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);
|
cell.DetailTextLabel.TextColor = cell.DetailTextLabel.TintColor = new UIColor( red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f );
|
||||||
return cell;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
|
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
|
||||||
|
|
Loading…
Reference in a new issue