1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-27 03:52:57 +02:00

[PM-7369] Show passkey icon on android when the item has a Fido2 credential (#3148)

* PM-7369 Show passkey icon on android when the item has a Fido2 credential

* PM-7369 alternative way to show passkey icon only in scenarios where we are trying to create a passkey

* PM-7369 moved logic to show passkey icon to CipherItemViewModel

* Update src/Core/Utilities/IconGlyphConverter.cs

Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>

---------

Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
This commit is contained in:
Dinis Vieira 2024-04-11 13:14:45 +01:00 committed by GitHub
parent ab5e72ef83
commit 08f371b0db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 7 deletions

View File

@ -50,7 +50,7 @@
HorizontalOptions="Center"
VerticalOptions="Center"
StyleClass="list-icon, list-icon-platform"
Text="{Binding Cipher, Converter={StaticResource iconGlyphConverter}}"
Text="{Binding ., Converter={StaticResource iconGlyphConverter}}"
ShouldUpdateFontSizeDynamicallyForAccesibility="True"
AutomationProperties.IsInAccessibleTree="False"
AutomationId="CipherTypeIcon" />

View File

@ -51,7 +51,7 @@ namespace Bit.Core.Models.View
public DateTime? DeletedDate { get; set; }
public CipherRepromptType Reprompt { get; set; }
public CipherKey Key { get; set; }
public ItemView Item
{
get

View File

@ -52,7 +52,11 @@ namespace Bit.App.Pages
var groupedItems = new List<GroupingsPageListGroup>();
var ciphers = await _cipherService.GetAllDecryptedByUrlAsync(Uri, null);
var matching = ciphers.Item1?.Select(c => new CipherItemViewModel(c, WebsiteIconsEnabled)).ToList();
var matching = ciphers.Item1?.Select(c => new CipherItemViewModel(c, WebsiteIconsEnabled)
{
UsePasskeyIconAsPlaceholderFallback = _isAndroidFido2CredentialCreation
}).ToList();
var hasMatching = matching?.Any() ?? false;
if (matching?.Any() ?? false)
{

View File

@ -44,5 +44,7 @@ namespace Bit.App.Pages
/// This is useful to check when the cell is being reused.
/// </summary>
public bool IconImageSuccesfullyLoaded { get; set; }
public bool UsePasskeyIconAsPlaceholderFallback { get; set; }
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Globalization;
using Bit.App.Pages;
using Bit.Core.Models.View;
using Microsoft.Maui.Controls;
using Microsoft.Maui;
@ -10,6 +11,11 @@ namespace Bit.App.Utilities
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CipherItemViewModel cipherItemViewModel)
{
return cipherItemViewModel.Cipher?.GetIcon(cipherItemViewModel.UsePasskeyIconAsPlaceholderFallback);
}
if (value is CipherView cipher)
{
return cipher.GetIcon();

View File

@ -6,12 +6,12 @@ namespace Bit.App.Utilities
{
public static class IconGlyphExtensions
{
public static string GetIcon(this CipherView cipher)
public static string GetIcon(this CipherView cipher, bool usePasskeyIconAsPlaceholderFallback = false)
{
switch (cipher.Type)
{
case CipherType.Login:
return GetLoginIconGlyph(cipher);
return GetLoginIconGlyph(cipher, usePasskeyIconAsPlaceholderFallback);
case CipherType.SecureNote:
return BitwardenIcons.StickyNote;
case CipherType.Card:
@ -22,9 +22,9 @@ namespace Bit.App.Utilities
return null;
}
static string GetLoginIconGlyph(CipherView cipher)
static string GetLoginIconGlyph(CipherView cipher, bool usePasskeyIconAsPlaceholderFallback = false)
{
var icon = BitwardenIcons.Globe;
var icon = cipher.HasFido2Credential && usePasskeyIconAsPlaceholderFallback ? BitwardenIcons.Passkey : BitwardenIcons.Globe;
if (cipher.Login.Uri != null)
{
var hostnameUri = cipher.Login.Uri;