2017-01-31 01:26:39 +01:00
|
|
|
|
using Bit.App.Models.Page;
|
|
|
|
|
using System;
|
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Controls
|
|
|
|
|
{
|
|
|
|
|
public class VaultListViewCell : LabeledDetailCell
|
|
|
|
|
{
|
2017-10-21 05:08:39 +02:00
|
|
|
|
public static readonly BindableProperty CipherParameterProperty = BindableProperty.Create(nameof(CipherParameter),
|
2017-10-19 03:35:33 +02:00
|
|
|
|
typeof(VaultListPageModel.Cipher), typeof(VaultListViewCell), null);
|
2017-12-20 05:59:12 +01:00
|
|
|
|
public static readonly BindableProperty GroupingOrCipherParameterProperty =
|
|
|
|
|
BindableProperty.Create(nameof(GroupingOrCipherParameter), typeof(VaultListPageModel.GroupingOrCipher),
|
|
|
|
|
typeof(VaultListViewCell), null);
|
2017-01-31 01:26:39 +01:00
|
|
|
|
|
2017-12-20 05:59:12 +01:00
|
|
|
|
public VaultListViewCell(Action<VaultListPageModel.Cipher> moreClickedAction, bool groupingOrCipherBinding = false)
|
2017-01-31 01:26:39 +01:00
|
|
|
|
{
|
2017-12-20 05:59:12 +01:00
|
|
|
|
string bindingPrefix = null;
|
|
|
|
|
if(groupingOrCipherBinding)
|
|
|
|
|
{
|
|
|
|
|
SetBinding(GroupingOrCipherParameterProperty, new Binding("."));
|
|
|
|
|
bindingPrefix = string.Concat(nameof(VaultListPageModel.GroupingOrCipher.Cipher), ".");
|
|
|
|
|
Button.Command = new Command(() => moreClickedAction?.Invoke(GroupingOrCipherParameter?.Cipher));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetBinding(CipherParameterProperty, new Binding("."));
|
|
|
|
|
Button.Command = new Command(() => moreClickedAction?.Invoke(CipherParameter));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Label.SetBinding(Label.TextProperty, bindingPrefix + nameof(VaultListPageModel.Cipher.Name));
|
|
|
|
|
Detail.SetBinding(Label.TextProperty, bindingPrefix + nameof(VaultListPageModel.Cipher.Subtitle));
|
|
|
|
|
LabelIcon.SetBinding(VisualElement.IsVisibleProperty,
|
|
|
|
|
bindingPrefix + nameof(VaultListPageModel.Cipher.Shared));
|
|
|
|
|
LabelIcon2.SetBinding(VisualElement.IsVisibleProperty,
|
|
|
|
|
bindingPrefix + nameof(VaultListPageModel.Cipher.HasAttachments));
|
2017-01-31 01:26:39 +01:00
|
|
|
|
|
2017-10-20 19:03:04 +02:00
|
|
|
|
Button.Image = "more.png";
|
2017-01-31 01:26:39 +01:00
|
|
|
|
Button.BackgroundColor = Color.Transparent;
|
|
|
|
|
|
2017-10-20 19:03:04 +02:00
|
|
|
|
LabelIcon.Source = "share.png";
|
|
|
|
|
LabelIcon2.Source = "paperclip.png";
|
2017-04-24 21:00:55 +02:00
|
|
|
|
|
2017-01-31 01:26:39 +01:00
|
|
|
|
BackgroundColor = Color.White;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-21 05:08:39 +02:00
|
|
|
|
public VaultListPageModel.Cipher CipherParameter
|
2017-01-31 01:26:39 +01:00
|
|
|
|
{
|
2017-10-21 05:08:39 +02:00
|
|
|
|
get { return GetValue(CipherParameterProperty) as VaultListPageModel.Cipher; }
|
|
|
|
|
set { SetValue(CipherParameterProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 05:59:12 +01:00
|
|
|
|
public VaultListPageModel.GroupingOrCipher GroupingOrCipherParameter
|
|
|
|
|
{
|
|
|
|
|
get { return GetValue(GroupingOrCipherParameterProperty) as VaultListPageModel.GroupingOrCipher; }
|
|
|
|
|
set { SetValue(GroupingOrCipherParameterProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-21 05:08:39 +02:00
|
|
|
|
protected override void OnBindingContextChanged()
|
|
|
|
|
{
|
|
|
|
|
Icon.Source = null;
|
2017-12-20 05:59:12 +01:00
|
|
|
|
|
|
|
|
|
VaultListPageModel.Cipher cipher = null;
|
2017-10-21 05:08:39 +02:00
|
|
|
|
if(BindingContext is VaultListPageModel.Cipher item)
|
|
|
|
|
{
|
2017-12-20 05:59:12 +01:00
|
|
|
|
cipher = item;
|
|
|
|
|
}
|
|
|
|
|
else if(BindingContext is VaultListPageModel.GroupingOrCipher groupingOrCipherItem)
|
|
|
|
|
{
|
|
|
|
|
cipher = groupingOrCipherItem.Cipher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cipher != null)
|
|
|
|
|
{
|
|
|
|
|
if(cipher.Type == Enums.CipherType.Login)
|
2017-10-21 05:08:39 +02:00
|
|
|
|
{
|
|
|
|
|
Icon.LoadingPlaceholder = "login.png";
|
|
|
|
|
}
|
2017-12-20 05:59:12 +01:00
|
|
|
|
Icon.Source = cipher.Icon;
|
2017-10-21 05:08:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.OnBindingContextChanged();
|
2017-01-31 01:26:39 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|