2021-10-12 17:00:33 +02:00
|
|
|
|
using Bit.App.Utilities;
|
|
|
|
|
using Bit.Core.Models.View;
|
2019-03-29 21:52:57 +01:00
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Controls
|
|
|
|
|
{
|
|
|
|
|
public class CipherViewCellViewModel : ExtendedViewModel
|
|
|
|
|
{
|
|
|
|
|
private CipherView _cipher;
|
2021-05-13 20:36:20 +02:00
|
|
|
|
private bool _websiteIconsEnabled;
|
2021-10-12 17:00:33 +02:00
|
|
|
|
private string _iconImageSource = string.Empty;
|
2021-05-13 20:36:20 +02:00
|
|
|
|
|
|
|
|
|
public CipherViewCellViewModel(CipherView cipherView, bool websiteIconsEnabled)
|
|
|
|
|
{
|
|
|
|
|
Cipher = cipherView;
|
|
|
|
|
WebsiteIconsEnabled = websiteIconsEnabled;
|
|
|
|
|
}
|
2019-03-29 21:52:57 +01:00
|
|
|
|
|
|
|
|
|
public CipherView Cipher
|
|
|
|
|
{
|
|
|
|
|
get => _cipher;
|
|
|
|
|
set => SetProperty(ref _cipher, value);
|
|
|
|
|
}
|
2021-05-13 20:36:20 +02:00
|
|
|
|
|
|
|
|
|
public bool WebsiteIconsEnabled
|
|
|
|
|
{
|
|
|
|
|
get => _websiteIconsEnabled;
|
|
|
|
|
set => SetProperty(ref _websiteIconsEnabled, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ShowIconImage
|
|
|
|
|
{
|
2021-10-12 17:00:33 +02:00
|
|
|
|
get => WebsiteIconsEnabled
|
|
|
|
|
&& !string.IsNullOrWhiteSpace(Cipher.Login?.Uri)
|
|
|
|
|
&& IconImageSource != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string IconImageSource
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_iconImageSource == string.Empty) // default value since icon source can return null
|
|
|
|
|
{
|
|
|
|
|
_iconImageSource = IconImageHelper.GetLoginIconImage(Cipher);
|
|
|
|
|
}
|
|
|
|
|
return _iconImageSource;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-13 20:36:20 +02:00
|
|
|
|
}
|
2019-03-29 21:52:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|