1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-24 16:38:22 +01:00

add reveal button to password reprompt on iOS (#1607)

* add reveal button to password reprompt on iOS

* format special chars as unicode
This commit is contained in:
Jake Fink 2021-10-26 17:46:11 -04:00 committed by GitHub
parent b8c1107c94
commit 0e9cbe4539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 7 deletions

View File

@ -43,7 +43,7 @@ namespace Bit.iOS.Core.Controllers
public abstract Action Cancel { get; }
public FormEntryTableViewCell MasterPasswordCell { get; set; } = new FormEntryTableViewCell(
AppResources.MasterPassword);
AppResources.MasterPassword, useButton: true);
public string BiometricIntegrityKey { get; set; }
@ -95,6 +95,12 @@ namespace Bit.iOS.Core.Controllers
{
MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad;
}
MasterPasswordCell.Button.TitleLabel.Font = UIFont.FromName("FontAwesome", 28f);
MasterPasswordCell.Button.SetTitle("\uf06e", UIControlState.Normal);
MasterPasswordCell.Button.TouchUpInside += (sender, e) => {
MasterPasswordCell.TextField.SecureTextEntry = !MasterPasswordCell.TextField.SecureTextEntry;
MasterPasswordCell.Button.SetTitle(MasterPasswordCell.TextField.SecureTextEntry ? "\uf06e" : "\uf070", UIControlState.Normal);
};
TableView.RowHeight = UITableView.AutomaticDimension;
TableView.EstimatedRowHeight = 70;

View File

@ -1,16 +1,25 @@
using Bit.iOS.Core.Controllers;
using Bit.iOS.Core.Utilities;
using System;
using System.Drawing;
using UIKit;
namespace Bit.iOS.Core.Views
{
public class FormEntryTableViewCell : ExtendedUITableViewCell, ISelectable
{
public UILabel Label { get; set; }
public UITextField TextField { get; set; }
public UITextView TextView { get; set; }
public UIButton Button { get; set; }
public event EventHandler ValueChanged;
public FormEntryTableViewCell(
string labelName = null,
bool useTextView = false,
nfloat? height = null,
bool useButton = false,
bool useLabelAsPlaceholder = false,
float leadingConstant = 15f)
: base(UITableViewCellStyle.Default, nameof(FormEntryTableViewCell))
@ -103,7 +112,7 @@ namespace Bit.iOS.Core.Views
ContentView.Add(TextField);
ContentView.AddConstraints(new NSLayoutConstraint[] {
NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, leadingConstant),
NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Trailing, 1f, 15f),
NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Trailing, 1f, useButton ? 55f : 15f),
NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Bottom, 1f, 10f)
});
@ -138,12 +147,21 @@ namespace Bit.iOS.Core.Views
NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Trailing, 1f, 15f)
});
}
}
public UILabel Label { get; set; }
public UITextField TextField { get; set; }
public UITextView TextView { get; set; }
public event EventHandler ValueChanged;
if (useButton)
{
Button = new UIButton(UIButtonType.System);
Button.Frame = ContentView.Bounds;
Button.TranslatesAutoresizingMaskIntoConstraints = false;
Button.SetTitleColor(ThemeHelpers.PrimaryColor, UIControlState.Normal);
ContentView.Add(Button);
ContentView.BottomAnchor.ConstraintEqualTo(Button.BottomAnchor, 10f).Active = true;
ContentView.TrailingAnchor.ConstraintEqualTo(Button.TrailingAnchor, 10f).Active = true;
Button.LeadingAnchor.ConstraintEqualTo(TextField.TrailingAnchor, 10f).Active = true;
}
}
public void Select()
{