mirror of
https://github.com/bitwarden/mobile
synced 2025-12-20 02:03:49 +00:00
Stepper table view cell. Min numbers/special to password generator.
This commit is contained in:
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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user