1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-10 13:23:39 +00:00
Files
mobile/src/Core/Pages/Vault/CipherItemViewModel.cs
Dinis Vieira 583fd6ba1e Removed FFImageLoading dependencies and replaced the CachedImage with the MAUI Image Control
Added UriImageSource for MAUI Image to support Cached icons for 90 days
Removed Stubs used to avoid issues with Unit Tests and FFImageLoading
2024-03-27 21:10:33 +00:00

57 lines
1.8 KiB
C#

using Bit.App.Utilities;
using Bit.Core.Models.View;
using Bit.Core.Utilities;
namespace Bit.App.Pages
{
public class CipherItemViewModel : ExtendedViewModel, IGroupingsPageListItem
{
private readonly bool _websiteIconsEnabled;
private UriImageSource _iconImageSource = null;
public CipherItemViewModel(CipherView cipherView, bool websiteIconsEnabled, bool fuzzyAutofill = false)
{
Cipher = cipherView;
_websiteIconsEnabled = websiteIconsEnabled;
FuzzyAutofill = fuzzyAutofill;
}
public CipherView Cipher { get; }
public bool FuzzyAutofill { get; }
public bool ShowIconImage
{
get => _websiteIconsEnabled
&& !string.IsNullOrWhiteSpace(Cipher.LaunchUri)
&& IconImageSource != null;
}
public UriImageSource IconImageSource
{
get
{
if (_iconImageSource == null) // default value since icon source can return null
{
var iconImageStr = IconImageHelper.GetIconImage(Cipher);
if (string.IsNullOrWhiteSpace(iconImageStr)) { return null; }
_iconImageSource = new UriImageSource
{
Uri = new Uri(iconImageStr),
CacheValidity = TimeSpan.FromDays(90)
};
}
return _iconImageSource;
}
}
/// <summary>
/// Flag that indicates if FFImageLoading has successfully finished loading the image.
/// This is useful to check when the cell is being reused.
/// </summary>
public bool IconImageSuccesfullyLoaded { get; set; }
}
}