From 7c56f1a77328c56dd72afaea37060e5210f46f65 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 20 Oct 2017 23:08:39 -0400 Subject: [PATCH] bind to image with OnBindingContextChanged --- src/Android/Android.csproj | 8 ++++---- src/Android/packages.config | 4 ++-- src/App/App.csproj | 6 +++--- src/App/Controls/VaultListViewCell.cs | 29 +++++++++++++++++++-------- src/App/packages.config | 4 ++-- src/UWP/UWP.csproj | 2 +- src/iOS/iOS.csproj | 12 +++++------ src/iOS/packages.config | 6 +++--- 8 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 80a87797c..17703c278 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -92,16 +92,16 @@ True - ..\..\packages\Xamarin.FFImageLoading.2.2.9\lib\MonoAndroid10\FFImageLoading.dll + ..\..\packages\Xamarin.FFImageLoading.2.2.20\lib\MonoAndroid10\FFImageLoading.dll - ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.9\lib\MonoAndroid10\FFImageLoading.Forms.dll + ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.20\lib\MonoAndroid10\FFImageLoading.Forms.dll - ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.9\lib\MonoAndroid10\FFImageLoading.Forms.Droid.dll + ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.20\lib\MonoAndroid10\FFImageLoading.Forms.Droid.dll - ..\..\packages\Xamarin.FFImageLoading.2.2.9\lib\MonoAndroid10\FFImageLoading.Platform.dll + ..\..\packages\Xamarin.FFImageLoading.2.2.20\lib\MonoAndroid10\FFImageLoading.Platform.dll ..\..\packages\Xamarin.Forms.2.3.4.267\lib\MonoAndroid10\FormsViewGroup.dll diff --git a/src/Android/packages.config b/src/Android/packages.config index cb6f0d272..15dd6f3af 100644 --- a/src/Android/packages.config +++ b/src/Android/packages.config @@ -78,8 +78,8 @@ - - + + diff --git a/src/App/App.csproj b/src/App/App.csproj index 4494cf95d..7b81d2e2a 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -484,13 +484,13 @@ ..\..\packages\Acr.UserDialogs.6.3.10\lib\portable-win+net45+wp8+win8+wpa81\Acr.UserDialogs.Interface.dll - ..\..\packages\Xamarin.FFImageLoading.2.2.9\lib\portable-net45+win8+wpa81+wp8\FFImageLoading.dll + ..\..\packages\Xamarin.FFImageLoading.2.2.20\lib\portable-net45+win8+wpa81+wp8\FFImageLoading.dll - ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.9\lib\portable-net45+win8+wpa81+wp8\FFImageLoading.Forms.dll + ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.20\lib\portable-net45+win8+wpa81+wp8+netstandard1.0\FFImageLoading.Forms.dll - ..\..\packages\Xamarin.FFImageLoading.2.2.9\lib\portable-net45+win8+wpa81+wp8\FFImageLoading.Platform.dll + ..\..\packages\Xamarin.FFImageLoading.2.2.20\lib\portable-net45+win8+wpa81+wp8\FFImageLoading.Platform.dll ..\..\packages\HockeySDK.Xamarin.4.1.5\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\HockeySDK.dll diff --git a/src/App/Controls/VaultListViewCell.cs b/src/App/Controls/VaultListViewCell.cs index 2776344fc..5b4e7b01e 100644 --- a/src/App/Controls/VaultListViewCell.cs +++ b/src/App/Controls/VaultListViewCell.cs @@ -7,21 +7,19 @@ namespace Bit.App.Controls { public class VaultListViewCell : LabeledDetailCell { - public static readonly BindableProperty LoginParameterProperty = BindableProperty.Create(nameof(LoginParameter), + public static readonly BindableProperty CipherParameterProperty = BindableProperty.Create(nameof(CipherParameter), typeof(VaultListPageModel.Cipher), typeof(VaultListViewCell), null); public VaultListViewCell(Action moreClickedAction) { - SetBinding(LoginParameterProperty, new Binding(".")); - Icon.SetBinding(CachedImage.SourceProperty, nameof(VaultListPageModel.Cipher.Icon)); - Icon.SetBinding(CachedImage.LoadingPlaceholderProperty, nameof(VaultListPageModel.Cipher.Icon)); + 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)); Button.Image = "more.png"; - Button.Command = new Command(() => moreClickedAction?.Invoke(LoginParameter)); + Button.Command = new Command(() => moreClickedAction?.Invoke(CipherParameter)); Button.BackgroundColor = Color.Transparent; LabelIcon.Source = "share.png"; @@ -30,10 +28,25 @@ namespace Bit.App.Controls BackgroundColor = Color.White; } - public VaultListPageModel.Cipher LoginParameter + public VaultListPageModel.Cipher CipherParameter { - get { return GetValue(LoginParameterProperty) as VaultListPageModel.Cipher; } - set { SetValue(LoginParameterProperty, value); } + 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(); } } } diff --git a/src/App/packages.config b/src/App/packages.config index 816268646..fa0be42e0 100644 --- a/src/App/packages.config +++ b/src/App/packages.config @@ -17,8 +17,8 @@ - - + + diff --git a/src/UWP/UWP.csproj b/src/UWP/UWP.csproj index 863c0f8eb..5b68a7f5c 100644 --- a/src/UWP/UWP.csproj +++ b/src/UWP/UWP.csproj @@ -175,7 +175,7 @@ 3.0.1 - 2.2.9 + 2.2.20 2.3.4.267 diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 44ca1880c..96f6cb0c1 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -267,16 +267,16 @@ True - ..\..\packages\Xamarin.FFImageLoading.2.2.9\lib\Xamarin.iOS10\FFImageLoading.dll + ..\..\packages\Xamarin.FFImageLoading.2.2.20\lib\Xamarin.iOS10\FFImageLoading.dll - ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.9\lib\Xamarin.iOS10\FFImageLoading.Forms.dll + ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.20\lib\Xamarin.iOS10\FFImageLoading.Forms.dll - ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.9\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll + ..\..\packages\Xamarin.FFImageLoading.Forms.2.2.20\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll - ..\..\packages\Xamarin.FFImageLoading.2.2.9\lib\Xamarin.iOS10\FFImageLoading.Platform.dll + ..\..\packages\Xamarin.FFImageLoading.2.2.20\lib\Xamarin.iOS10\FFImageLoading.Platform.dll ..\..\packages\Xamarin.Google.iOS.Analytics.3.17.0.1\lib\Xamarin.iOS10\Google.Analytics.dll @@ -351,8 +351,8 @@ ..\..\packages\Validation.2.3.7\lib\dotnet\Validation.dll True - - ..\..\packages\WebP.Touch.1.0.3\lib\Xamarin.iOS10\WebP.Touch.dll + + ..\..\packages\WebP.Touch.1.0.4\lib\Xamarin.iOS10\WebP.Touch.dll ..\..\packages\Xamarin.Forms.2.3.4.267\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll diff --git a/src/iOS/packages.config b/src/iOS/packages.config index 53d57503a..aca45c98e 100644 --- a/src/iOS/packages.config +++ b/src/iOS/packages.config @@ -65,12 +65,12 @@ - + - - + +