1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-16 08:13:20 +00:00

[Linked fields] Add Linked Field as a custom field type (#1563)

* Add linked fields support

* Fix style, don't show linked field if Secure Note

* Finish basic linked fields for Login

* Use Field.LinkedId to store linked field info

* Reset Linked Custom Fields if cipherType changes

* Refactor to use ItemView class

* Use enum for LinkedId

* Detect if no linkedFieldOptions
This commit is contained in:
Thomas Rittson
2021-11-09 07:34:16 +10:00
committed by GitHub
parent 3cb8adeeff
commit 90b62d61ae
20 changed files with 263 additions and 30 deletions

View File

@@ -1,9 +1,11 @@
using Bit.Core.Models.Domain;
using Bit.Core.Enums;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Bit.Core.Models.View
{
public class CardView : View
public class CardView : ItemView
{
private string _brand;
private string _number;
@@ -40,7 +42,7 @@ namespace Bit.Core.Models.View
}
}
public string SubTitle
public override string SubTitle
{
get
{
@@ -82,6 +84,19 @@ namespace Bit.Core.Models.View
}
}
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions
{
get => new List<KeyValuePair<string, LinkedIdType>>()
{
new KeyValuePair<string, LinkedIdType>("CardholderName", LinkedIdType.Card_CardholderName),
new KeyValuePair<string, LinkedIdType>("ExpirationMonth", LinkedIdType.Card_ExpMonth),
new KeyValuePair<string, LinkedIdType>("ExpirationYear", LinkedIdType.Card_ExpYear),
new KeyValuePair<string, LinkedIdType>("SecurityCode", LinkedIdType.Card_Code),
new KeyValuePair<string, LinkedIdType>("Brand", LinkedIdType.Card_Brand),
new KeyValuePair<string, LinkedIdType>("Number", LinkedIdType.Card_Number),
};
}
private string FormatYear(string year)
{
return year.Length == 2 ? string.Concat("20", year) : year;