1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-29 12:45:20 +01:00

Added length slider to password generation page

This commit is contained in:
Kyle Spearrin 2016-07-14 19:44:04 -04:00
parent afd22b6462
commit 83359b2d43
3 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,38 @@
using System;
using UIKit;
namespace Bit.iOS.Core.Views
{
public class SliderTableViewCell : UITableViewCell
{
private string _detailRightSpace = "\t";
public SliderTableViewCell(string labelName, float value, float min, float max)
: 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);
Slider = new UISlider
{
MinValue = min,
MaxValue = max,
Value = value,
TintColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f),
Frame = new CoreGraphics.CGRect(0, 0, 180, 20)
};
Slider.ValueChanged += Slider_ValueChanged;
AccessoryView = Slider;
}
private void Slider_ValueChanged(object sender, EventArgs e)
{
Slider.Value = Convert.ToInt32(Math.Round(Slider.Value, 0));
DetailTextLabel.Text = string.Concat(Slider.Value.ToString(), _detailRightSpace);
}
public UISlider Slider { get; set; }
}
}

View File

@ -71,6 +71,7 @@
<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\StepperTableViewCell.cs" />
<Compile Include="Views\SliderTableViewCell.cs" />
<Compile Include="Views\SwitchTableViewCell.cs" /> <Compile Include="Views\SwitchTableViewCell.cs" />
<Compile Include="Views\FormEntryTableViewCell.cs" /> <Compile Include="Views\FormEntryTableViewCell.cs" />
</ItemGroup> </ItemGroup>

View File

@ -35,6 +35,7 @@ namespace Bit.iOS.Extension
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 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 StepperTableViewCell MinSpecialCell { get; set; } = new StepperTableViewCell("Minimum Special", 1, 0, 5, 1);
public SliderTableViewCell LengthCell { get; set; } = new SliderTableViewCell("Length", 10, 5, 64);
public override void ViewWillAppear(bool animated) public override void ViewWillAppear(bool animated)
{ {
@ -113,7 +114,7 @@ namespace Bit.iOS.Extension
if(indexPath.Row == 0) if(indexPath.Row == 0)
{ {
// TODO: Length slider return _controller.LengthCell;
} }
else if(indexPath.Row == 1) else if(indexPath.Row == 1)
{ {