1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-23 19:53:50 +00:00

[EC-528] Refactor Custom Fields into separate components (#1662)

* 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
This commit is contained in:
Federico Maccaroni
2022-09-09 15:58:11 -03:00
committed by GitHub
parent 2016eadb0d
commit b7048de2a1
30 changed files with 913 additions and 450 deletions

View File

@@ -0,0 +1,69 @@
using Bit.Core;
using Bit.Core.Enums;
using Bit.Core.Models.View;
namespace Bit.App.Utilities
{
public static class IconGlyphExtensions
{
public static string GetIcon(this CipherView cipher)
{
string icon = null;
switch (cipher.Type)
{
case CipherType.Login:
icon = GetLoginIconGlyph(cipher);
break;
case CipherType.SecureNote:
icon = BitwardenIcons.StickyNote;
break;
case CipherType.Card:
icon = BitwardenIcons.CreditCard;
break;
case CipherType.Identity:
icon = BitwardenIcons.IdCard;
break;
default:
break;
}
return icon;
}
static string GetLoginIconGlyph(CipherView cipher)
{
var icon = BitwardenIcons.Globe;
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:
return value ? BitwardenIcons.Eye : BitwardenIcons.EyeSlash;
default:
return "";
}
}
}
public enum BooleanGlyphType
{
Checkbox,
Eye
}
}