2022-09-09 20:58:11 +02:00
|
|
|
|
using Bit.Core;
|
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
using Bit.Core.Models.View;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Utilities
|
|
|
|
|
{
|
|
|
|
|
public static class IconGlyphExtensions
|
|
|
|
|
{
|
2024-04-11 14:14:45 +02:00
|
|
|
|
public static string GetIcon(this CipherView cipher, bool usePasskeyIconAsPlaceholderFallback = false)
|
2022-09-09 20:58:11 +02:00
|
|
|
|
{
|
|
|
|
|
switch (cipher.Type)
|
|
|
|
|
{
|
|
|
|
|
case CipherType.Login:
|
2024-04-11 14:14:45 +02:00
|
|
|
|
return GetLoginIconGlyph(cipher, usePasskeyIconAsPlaceholderFallback);
|
2022-09-09 20:58:11 +02:00
|
|
|
|
case CipherType.SecureNote:
|
2023-07-26 22:59:49 +02:00
|
|
|
|
return BitwardenIcons.StickyNote;
|
2022-09-09 20:58:11 +02:00
|
|
|
|
case CipherType.Card:
|
2023-07-26 22:59:49 +02:00
|
|
|
|
return BitwardenIcons.CreditCard;
|
2022-09-09 20:58:11 +02:00
|
|
|
|
case CipherType.Identity:
|
2023-07-26 22:59:49 +02:00
|
|
|
|
return BitwardenIcons.IdCard;
|
2022-09-09 20:58:11 +02:00
|
|
|
|
}
|
2023-07-26 22:59:49 +02:00
|
|
|
|
return null;
|
2022-09-09 20:58:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-11 14:14:45 +02:00
|
|
|
|
static string GetLoginIconGlyph(CipherView cipher, bool usePasskeyIconAsPlaceholderFallback = false)
|
2022-09-09 20:58:11 +02:00
|
|
|
|
{
|
2024-04-11 14:14:45 +02:00
|
|
|
|
var icon = cipher.HasFido2Credential && usePasskeyIconAsPlaceholderFallback ? BitwardenIcons.Passkey : BitwardenIcons.Globe;
|
2022-09-09 20:58:11 +02:00
|
|
|
|
if (cipher.Login.Uri != null)
|
|
|
|
|
{
|
|
|
|
|
var hostnameUri = cipher.Login.Uri;
|
|
|
|
|
if (hostnameUri.StartsWith(Constants.AndroidAppProtocol))
|
|
|
|
|
{
|
|
|
|
|
icon = BitwardenIcons.Android;
|
|
|
|
|
}
|
|
|
|
|
else if (hostnameUri.StartsWith(Constants.iOSAppProtocol))
|
|
|
|
|
{
|
|
|
|
|
icon = BitwardenIcons.Apple;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetBooleanIconGlyph(bool value, BooleanGlyphType type)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case BooleanGlyphType.Checkbox:
|
|
|
|
|
return value ? BitwardenIcons.CheckSquare : BitwardenIcons.Square;
|
|
|
|
|
case BooleanGlyphType.Eye:
|
2023-01-26 14:53:48 +01:00
|
|
|
|
return value ? BitwardenIcons.EyeSlash : BitwardenIcons.Eye;
|
2022-09-09 20:58:11 +02:00
|
|
|
|
default:
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum BooleanGlyphType
|
|
|
|
|
{
|
|
|
|
|
Checkbox,
|
|
|
|
|
Eye
|
|
|
|
|
}
|
|
|
|
|
}
|