1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-20 02:03:49 +00:00

[Linked fields] Add Linked Field as a custom field type (#1563)

* Add linked fields support

* Fix style, don't show linked field if Secure Note

* Finish basic linked fields for Login

* Use Field.LinkedId to store linked field info

* Reset Linked Custom Fields if cipherType changes

* Refactor to use ItemView class

* Use enum for LinkedId

* Detect if no linkedFieldOptions
This commit is contained in:
Thomas Rittson
2021-11-09 07:34:16 +10:00
committed by GitHub
parent 3cb8adeeff
commit 90b62d61ae
20 changed files with 263 additions and 30 deletions

View File

@@ -704,6 +704,7 @@ namespace Bit.App.Pages
public class ViewPageFieldViewModel : ExtendedViewModel
{
private II18nService _i18nService;
private ViewPageViewModel _vm;
private FieldView _field;
private CipherView _cipher;
@@ -711,6 +712,7 @@ namespace Bit.App.Pages
public ViewPageFieldViewModel(ViewPageViewModel vm, CipherView cipher, FieldView field)
{
_i18nService = ServiceContainer.Resolve<II18nService>("i18nService");
_vm = vm;
_cipher = cipher;
Field = field;
@@ -741,16 +743,38 @@ namespace Bit.App.Pages
});
}
public string ValueText
{
get
{
if (IsBooleanType)
{
return _field.Value == "true" ? "" : "";
}
else if (IsLinkedType)
{
var i18nKey = _cipher.LinkedFieldI18nKey(Field.LinkedId.GetValueOrDefault());
return " " + _i18nService.T(i18nKey);
}
else
{
return _field.Value;
}
}
}
public Command ToggleHiddenValueCommand { get; set; }
public string ValueText => IsBooleanType ? (_field.Value == "true" ? "" : "") : _field.Value;
public string ShowHiddenValueIcon => _showHiddenValue ? "" : "";
public bool IsTextType => _field.Type == Core.Enums.FieldType.Text;
public bool IsBooleanType => _field.Type == Core.Enums.FieldType.Boolean;
public bool IsHiddenType => _field.Type == Core.Enums.FieldType.Hidden;
public bool IsLinkedType => _field.Type == Core.Enums.FieldType.Linked;
public bool ShowViewHidden => IsHiddenType && _cipher.ViewPassword;
public bool ShowCopyButton => _field.Type != Core.Enums.FieldType.Boolean &&
!string.IsNullOrWhiteSpace(_field.Value) && !(IsHiddenType && !_cipher.ViewPassword);
!string.IsNullOrWhiteSpace(_field.Value) &&
!(IsHiddenType && !_cipher.ViewPassword) &&
_field.Type != FieldType.Linked;
public async void ToggleHiddenValue()
{