bitwarden-android/src/App/Controls/VaultListViewCell.cs

53 lines
1.9 KiB
C#
Raw Normal View History

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