diff --git a/src/App/Pages/Vault/AddEditPage.xaml b/src/App/Pages/Vault/AddEditPage.xaml
index b522c2fec..cb6e000c2 100644
--- a/src/App/Pages/Vault/AddEditPage.xaml
+++ b/src/App/Pages/Vault/AddEditPage.xaml
@@ -33,6 +33,17 @@
+
+
+
+
@@ -136,7 +148,8 @@
StyleClass="box-label" />
@@ -185,7 +198,8 @@
StyleClass="box-label" />
diff --git a/src/App/Pages/Vault/AddEditPage.xaml.cs b/src/App/Pages/Vault/AddEditPage.xaml.cs
index d503cc43d..c83d3813a 100644
--- a/src/App/Pages/Vault/AddEditPage.xaml.cs
+++ b/src/App/Pages/Vault/AddEditPage.xaml.cs
@@ -24,6 +24,7 @@ namespace Bit.App.Pages
_vm.Init();
SetActivityIndicator();
+ _typePicker.ItemDisplayBinding = new Binding("Key");
_cardBrandPicker.ItemDisplayBinding = new Binding("Key");
_cardExpMonthPicker.ItemDisplayBinding = new Binding("Key");
_identityTitlePicker.ItemDisplayBinding = new Binding("Key");
diff --git a/src/App/Pages/Vault/AddEditPageViewModel.cs b/src/App/Pages/Vault/AddEditPageViewModel.cs
index fdb8d7dd9..443a3df31 100644
--- a/src/App/Pages/Vault/AddEditPageViewModel.cs
+++ b/src/App/Pages/Vault/AddEditPageViewModel.cs
@@ -24,6 +24,20 @@ namespace Bit.App.Pages
private List _fields;
private bool _showPassword;
private bool _showCardCode;
+ private int _typeSelectedIndex;
+ private int _cardBrandSelectedIndex;
+ private int _cardExpMonthSelectedIndex;
+ private int _identityTitleSelectedIndex;
+ private string[] _additionalCipherProperties = new string[]
+ {
+ nameof(IsLogin),
+ nameof(IsIdentity),
+ nameof(IsCard),
+ nameof(IsSecureNote),
+ nameof(ShowUris),
+ nameof(ShowAttachments),
+ nameof(ShowIdentityAddress),
+ };
public AddEditPageViewModel()
{
@@ -38,6 +52,13 @@ namespace Bit.App.Pages
ToggleCardCodeCommand = new Command(ToggleCardCode);
CheckPasswordCommand = new Command(CheckPasswordAsync);
+ TypeOptions = new List>
+ {
+ new KeyValuePair(AppResources.TypeLogin, CipherType.Login),
+ new KeyValuePair(AppResources.TypeCard, CipherType.Card),
+ new KeyValuePair(AppResources.TypeIdentity, CipherType.Identity),
+ new KeyValuePair(AppResources.TypeSecureNote, CipherType.SecureNote),
+ };
CardBrandOptions = new List>
{
new KeyValuePair($"-- {AppResources.Select} --", null),
@@ -86,23 +107,50 @@ namespace Bit.App.Pages
public string FolderId { get; set; }
public CipherType? Type { get; set; }
public List CollectionIds { get; set; }
+ public List> TypeOptions { get; set; }
public List> CardBrandOptions { get; set; }
public List> CardExpMonthOptions { get; set; }
public List> IdentityTitleOptions { get; set; }
+ public int TypeSelectedIndex
+ {
+ get => _typeSelectedIndex;
+ set
+ {
+ SetProperty(ref _typeSelectedIndex, value);
+ TypeChanged();
+ }
+ }
+ public int CardBrandSelectedIndex
+ {
+ get => _cardBrandSelectedIndex;
+ set
+ {
+ SetProperty(ref _cardBrandSelectedIndex, value);
+ CardBrandChanged();
+ }
+ }
+ public int CardExpMonthSelectedIndex
+ {
+ get => _cardExpMonthSelectedIndex;
+ set
+ {
+ SetProperty(ref _cardExpMonthSelectedIndex, value);
+ CardExpMonthChanged();
+ }
+ }
+ public int IdentityTitleSelectedIndex
+ {
+ get => _identityTitleSelectedIndex;
+ set
+ {
+ SetProperty(ref _identityTitleSelectedIndex, value);
+ IdentityTitleChanged();
+ }
+ }
public CipherView Cipher
{
get => _cipher;
- set => SetProperty(ref _cipher, value,
- additionalPropertyNames: new string[]
- {
- nameof(IsLogin),
- nameof(IsIdentity),
- nameof(IsCard),
- nameof(IsSecureNote),
- nameof(ShowUris),
- nameof(ShowAttachments),
- nameof(ShowIdentityAddress),
- });
+ set => SetProperty(ref _cipher, value, additionalPropertyNames: _additionalCipherProperties);
}
public List Fields
{
@@ -155,6 +203,19 @@ namespace Bit.App.Pages
var cipher = await _cipherService.GetAsync(CipherId);
Cipher = await cipher.DecryptAsync();
Fields = Cipher.Fields?.Select(f => new AddEditPageFieldViewModel(f)).ToList();
+
+ if(Cipher.Card != null)
+ {
+ CardBrandSelectedIndex = string.IsNullOrWhiteSpace(Cipher.Card.Brand) ? 0 :
+ CardBrandOptions.FindIndex(k => k.Value == Cipher.Card.Brand);
+ CardExpMonthSelectedIndex = string.IsNullOrWhiteSpace(Cipher.Card.ExpMonth) ? 0 :
+ CardExpMonthOptions.FindIndex(k => k.Value == Cipher.Card.ExpMonth);
+ }
+ if(Cipher.Identity != null)
+ {
+ IdentityTitleSelectedIndex = string.IsNullOrWhiteSpace(Cipher.Identity.Title) ? 0 :
+ IdentityTitleOptions.FindIndex(k => k.Value == Cipher.Identity.Title);
+ }
}
else
{
@@ -171,6 +232,10 @@ namespace Bit.App.Pages
Cipher.Login.Uris = new List();
Cipher.SecureNote.Type = SecureNoteType.Generic;
+ TypeSelectedIndex = TypeOptions.FindIndex(k => k.Value == Cipher.Type);
+ CardBrandSelectedIndex = 0;
+ CardExpMonthSelectedIndex = 0;
+ IdentityTitleSelectedIndex = 0;
// TODO: org/collection stuff
}
}
@@ -257,6 +322,44 @@ namespace Bit.App.Pages
ShowCardCode = !ShowCardCode;
}
+ private void TypeChanged()
+ {
+ if(Cipher != null && TypeSelectedIndex > -1)
+ {
+ Cipher.Type = TypeOptions[TypeSelectedIndex].Value;
+ TriggerCipherChanged();
+ }
+ }
+
+ private void CardBrandChanged()
+ {
+ if(Cipher?.Card != null && CardBrandSelectedIndex > -1)
+ {
+ Cipher.Card.Brand = CardBrandOptions[CardBrandSelectedIndex].Value;
+ }
+ }
+
+ private void CardExpMonthChanged()
+ {
+ if(Cipher?.Card != null && CardExpMonthSelectedIndex > -1)
+ {
+ Cipher.Card.ExpMonth = CardExpMonthOptions[CardExpMonthSelectedIndex].Value;
+ }
+ }
+
+ private void IdentityTitleChanged()
+ {
+ if(Cipher?.Identity != null && IdentityTitleSelectedIndex > -1)
+ {
+ Cipher.Identity.Title = IdentityTitleOptions[IdentityTitleSelectedIndex].Value;
+ }
+ }
+
+ private void TriggerCipherChanged()
+ {
+ TriggerPropertyChanged(nameof(Cipher), _additionalCipherProperties);
+ }
+
private async void CheckPasswordAsync()
{
if(!(Page as BaseContentPage).DoOnce())
diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs
index 76c59bb6b..abb497116 100644
--- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs
+++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs
@@ -124,37 +124,7 @@ namespace Bit.App.Pages
private async void AddButton_Clicked(object sender, System.EventArgs e)
{
- var type = await DisplayActionSheet(AppResources.SelectTypeAdd, AppResources.Cancel, null,
- AppResources.TypeLogin, AppResources.TypeCard, AppResources.TypeIdentity,
- AppResources.TypeSecureNote);
-
- var selectedType = CipherType.SecureNote;
- if(type == null || type == AppResources.Cancel)
- {
- return;
- }
- else if(type == AppResources.TypeLogin)
- {
- selectedType = CipherType.Login;
- }
- else if(type == AppResources.TypeCard)
- {
- selectedType = CipherType.Card;
- }
- else if(type == AppResources.TypeIdentity)
- {
- selectedType = CipherType.Identity;
- }
- else if(type == AppResources.TypeSecureNote)
- {
- selectedType = CipherType.SecureNote;
- }
- else
- {
- return;
- }
-
- var page = new AddEditPage(null, selectedType);
+ var page = new AddEditPage(null, _vm.Type, _vm.FolderId, _vm.CollectionId);
await Navigation.PushModalAsync(new NavigationPage(page));
}
}
diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs
index a61e1bac9..27305fecd 100644
--- a/src/App/Resources/AppResources.Designer.cs
+++ b/src/App/Resources/AppResources.Designer.cs
@@ -3237,6 +3237,15 @@ namespace Bit.App.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Type.
+ ///
+ public static string Type {
+ get {
+ return ResourceManager.GetString("Type", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Card.
///
diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx
index 85bb52199..be7a43a00 100644
--- a/src/App/Resources/AppResources.resx
+++ b/src/App/Resources/AppResources.resx
@@ -1408,4 +1408,7 @@
Search type
+
+ Type
+
\ No newline at end of file
diff --git a/src/Core/Utilities/ExtendedViewModel.cs b/src/Core/Utilities/ExtendedViewModel.cs
index 1e8708477..123d502da 100644
--- a/src/Core/Utilities/ExtendedViewModel.cs
+++ b/src/Core/Utilities/ExtendedViewModel.cs
@@ -18,6 +18,13 @@ namespace Bit.Core.Utilities
}
backingStore = value;
+ TriggerPropertyChanged(propertyName, additionalPropertyNames);
+ onChanged?.Invoke();
+ return true;
+ }
+
+ protected void TriggerPropertyChanged(string propertyName, string[] additionalPropertyNames = null)
+ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
if(PropertyChanged != null && additionalPropertyNames != null)
{
@@ -26,8 +33,6 @@ namespace Bit.Core.Utilities
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(prop));
}
}
- onChanged?.Invoke();
- return true;
}
}
}