1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00
Files
mobile/src/App/Pages/Vault/GroupingsPage/GroupingsPageListItem.cs
ifernandezdiaz 72e67bd6f2 [PM-2691] Adding AutomationIDs for Vault Page sections (#2580)
* Adding IDs for Vault Page sections

* Removing extra spaces

* Adding Matt's comments

* Fixing Filters Id bug

* Adding Fede's suggestions

* Fixing Settings Ids issues

* Fixing AutomationIds issues with RecyclerViews + implementing AutomationId helper class

* Adding Fede's suggestion

* Adding latest Fede's suggestions
2023-06-29 15:37:08 -03:00

154 lines
4.7 KiB
C#

using Bit.App.Resources;
using Bit.App.Utilities.Automation;
using Bit.Core;
using Bit.Core.Enums;
using Bit.Core.Models.View;
namespace Bit.App.Pages
{
public class GroupingsPageListItem : IGroupingsPageListItem
{
private string _icon;
private string _name;
public FolderView Folder { get; set; }
public CollectionView Collection { get; set; }
public CipherView Cipher { get; set; }
public CipherType? Type { get; set; }
public string ItemCount { get; set; }
public bool FuzzyAutofill { get; set; }
public bool IsTrash { get; set; }
public bool IsTotpCode { get; set; }
public string Name
{
get
{
if (_name != null)
{
return _name;
}
if (IsTrash)
{
_name = AppResources.Trash;
}
else if (Folder != null)
{
_name = Folder.Name;
}
else if (Collection != null)
{
_name = Collection.Name;
}
else if (IsTotpCode)
{
_name = AppResources.VerificationCodes;
}
else if (Type != null)
{
switch (Type.Value)
{
case CipherType.Login:
_name = AppResources.TypeLogin;
break;
case CipherType.SecureNote:
_name = AppResources.TypeSecureNote;
break;
case CipherType.Card:
_name = AppResources.TypeCard;
break;
case CipherType.Identity:
_name = AppResources.TypeIdentity;
break;
default:
break;
}
}
return _name;
}
}
public string Icon
{
get
{
if (_icon != null)
{
return _icon;
}
if (IsTrash)
{
_icon = BitwardenIcons.Trash;
}
else if (Folder != null)
{
_icon = BitwardenIcons.Folder;
}
else if (Collection != null)
{
_icon = BitwardenIcons.Collection;
}
else if (IsTotpCode)
{
_icon = BitwardenIcons.Clock;
}
else if (Type != null)
{
switch (Type.Value)
{
case CipherType.Login:
_icon = BitwardenIcons.Globe;
break;
case CipherType.SecureNote:
_icon = BitwardenIcons.StickyNote;
break;
case CipherType.Card:
_icon = BitwardenIcons.CreditCard;
break;
case CipherType.Identity:
_icon = BitwardenIcons.IdCard;
break;
default:
_icon = BitwardenIcons.Globe;
break;
}
}
return _icon;
}
}
public string AutomationId
{
get
{
if (Type != null)
{
return AutomationIdsHelper.AddSuffixFor(System.Enum.GetName(typeof(CipherType), Type.Value), SuffixType.Filter);
}
if (IsTrash)
{
return AutomationIdsHelper.AddSuffixFor("Trash", SuffixType.Filter);
}
if (Folder != null)
{
return AutomationIdsHelper.AddSuffixFor("Folder", SuffixType.Filter);
}
if (Collection != null)
{
return AutomationIdsHelper.AddSuffixFor("Collection", SuffixType.Filter);
}
if (IsTotpCode)
{
return AutomationIdsHelper.AddSuffixFor("TOTP", SuffixType.ListItem);
}
return null;
}
}
}
}