mirror of
https://github.com/bitwarden/android.git
synced 2025-03-29 00:59:19 +03:00
cleanup login view of custom fields.
This commit is contained in:
parent
e126cbf644
commit
78cda03d61
2 changed files with 60 additions and 22 deletions
|
@ -278,6 +278,7 @@ namespace Bit.App.Models.Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public FieldType Type { get; set; }
|
public FieldType Type { get; set; }
|
||||||
|
public bool Revealed { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,39 +267,21 @@ namespace Bit.App.Pages
|
||||||
FieldsSection = new TableSection(AppResources.CustomFields);
|
FieldsSection = new TableSection(AppResources.CustomFields);
|
||||||
foreach(var field in Model.Fields)
|
foreach(var field in Model.Fields)
|
||||||
{
|
{
|
||||||
LabeledValueCell fieldCell;
|
FieldViewCell fieldCell;
|
||||||
ExtendedButton copyButton = null;
|
|
||||||
switch(field.Type)
|
switch(field.Type)
|
||||||
{
|
{
|
||||||
case FieldType.Text:
|
case FieldType.Text:
|
||||||
fieldCell = new LabeledValueCell(field.Name, field.Value, AppResources.Copy);
|
fieldCell = new FieldViewCell(this, field, null);
|
||||||
copyButton = fieldCell.Button1;
|
|
||||||
break;
|
break;
|
||||||
case FieldType.Hidden:
|
case FieldType.Hidden:
|
||||||
fieldCell = new LabeledValueCell(field.Name, field.MaskedValue, string.Empty, AppResources.Copy);
|
fieldCell = new FieldViewCell(this, field, null, null);
|
||||||
copyButton = fieldCell.Button2;
|
|
||||||
fieldCell.Value.FontFamily =
|
|
||||||
Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier");
|
|
||||||
if(Device.RuntimePlatform == Device.iOS)
|
|
||||||
{
|
|
||||||
fieldCell.Button1.Margin = new Thickness(10, 0);
|
|
||||||
}
|
|
||||||
// TODO: show/hide image toggle
|
|
||||||
break;
|
break;
|
||||||
case FieldType.Boolean:
|
case FieldType.Boolean:
|
||||||
fieldCell = new LabeledValueCell(field.Name, field.Value == "true" ? "✓" : "-");
|
fieldCell = new FieldViewCell(this, field);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldCell.Value.LineBreakMode = LineBreakMode.WordWrap;
|
|
||||||
if(copyButton != null)
|
|
||||||
{
|
|
||||||
copyButton.Command = new Command(() => Copy(field.Value, field.Name));
|
|
||||||
copyButton.WidthRequest = 59;
|
|
||||||
}
|
|
||||||
|
|
||||||
FieldsSection.Add(fieldCell);
|
FieldsSection.Add(fieldCell);
|
||||||
}
|
}
|
||||||
Table.Root.Add(FieldsSection);
|
Table.Root.Add(FieldsSection);
|
||||||
|
@ -437,5 +419,60 @@ namespace Bit.App.Pages
|
||||||
_tapped?.Invoke();
|
_tapped?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FieldViewCell : LabeledValueCell
|
||||||
|
{
|
||||||
|
public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field)
|
||||||
|
: base(field.Name, field.Value == "true" ? "✓" : "-")
|
||||||
|
{
|
||||||
|
Init(page, field, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, bool? a)
|
||||||
|
: base(field.Name, field.Value, AppResources.Copy)
|
||||||
|
{
|
||||||
|
Init(page, field, Button1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, bool? a, bool? b)
|
||||||
|
: base(field.Name, field.MaskedValue, string.Empty, AppResources.Copy)
|
||||||
|
{
|
||||||
|
Value.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular",
|
||||||
|
Android: "monospace", WinPhone: "Courier");
|
||||||
|
if(Device.RuntimePlatform == Device.iOS)
|
||||||
|
{
|
||||||
|
Button1.Margin = new Thickness(10, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Button1.WidthRequest = 40;
|
||||||
|
Button1.Image = "eye";
|
||||||
|
Button1.Command = new Command(() =>
|
||||||
|
{
|
||||||
|
field.Revealed = !field.Revealed;
|
||||||
|
if(field.Revealed)
|
||||||
|
{
|
||||||
|
Button1.Image = "eye_slash";
|
||||||
|
Value.Text = field.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Button1.Image = "eye";
|
||||||
|
Value.Text = field.MaskedValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Init(page, field, Button2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Init(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, ExtendedButton copyButton)
|
||||||
|
{
|
||||||
|
Value.LineBreakMode = LineBreakMode.WordWrap;
|
||||||
|
if(copyButton != null)
|
||||||
|
{
|
||||||
|
copyButton.Command = new Command(() => page.Copy(field.Value, field.Name));
|
||||||
|
copyButton.WidthRequest = 59;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue