mirror of
https://github.com/bitwarden/mobile
synced 2025-12-29 06:33:53 +00:00
* Refactored CustomFields to stop using RepeaterView and use BindableLayout and divided the different types on different files and added a factory to create them * Fix formatting
50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using System.Windows.Input;
|
|
using Bit.Core.Models.View;
|
|
using Bit.Core.Utilities;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Bit.App.Lists.ItemViewModels.CustomFields
|
|
{
|
|
public abstract class BaseCustomFieldItemViewModel : ExtendedViewModel, ICustomFieldItemViewModel
|
|
{
|
|
protected FieldView _field;
|
|
protected bool _isEditing;
|
|
private string[] _additionalFieldProperties = new string[]
|
|
{
|
|
nameof(ValueText),
|
|
nameof(ShowCopyButton)
|
|
};
|
|
|
|
public BaseCustomFieldItemViewModel(FieldView field, bool isEditing, ICommand fieldOptionsCommand)
|
|
{
|
|
_field = field;
|
|
_isEditing = isEditing;
|
|
FieldOptionsCommand = new Command(() => fieldOptionsCommand?.Execute(this));
|
|
}
|
|
|
|
public FieldView Field
|
|
{
|
|
get => _field;
|
|
set => SetProperty(ref _field, value,
|
|
additionalPropertyNames: new string[]
|
|
{
|
|
nameof(ValueText),
|
|
nameof(ShowCopyButton),
|
|
});
|
|
}
|
|
|
|
public bool IsEditing => _isEditing;
|
|
|
|
public virtual bool ShowCopyButton => false;
|
|
|
|
public virtual string ValueText => _field.Value;
|
|
|
|
public ICommand FieldOptionsCommand { get; }
|
|
|
|
public void TriggerFieldChanged()
|
|
{
|
|
TriggerPropertyChanged(nameof(Field), _additionalFieldProperties);
|
|
}
|
|
}
|
|
}
|