PM-3349 PM-3350 Changed AccountViewCell and its binding to be directly against the ViewModel
This commit is contained in:
parent
974a571455
commit
363da063fa
|
@ -36,13 +36,11 @@
|
|||
effects:ScrollViewContentInsetAdjustmentBehaviorEffect.ContentInsetAdjustmentBehavior="Never"
|
||||
AutomationId="AccountListView">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="view:AccountView">
|
||||
<DataTemplate x:DataType="controls:AccountViewCellViewModel">
|
||||
<controls:AccountViewCell
|
||||
Account="{Binding .}"
|
||||
SelectAccountCommand="{Binding SelectAccountCommand, Source={x:Reference _mainOverlay}}"
|
||||
LongPressAccountCommand="{Binding LongPressAccountCommand, Source={x:Reference _mainOverlay}}"
|
||||
AutomationId="AccountViewCell"
|
||||
/>
|
||||
AutomationId="AccountViewCell" />
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.Effects>
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Input;
|
||||
using Bit.App.Utilities;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui;
|
||||
using Bit.App.Utilities;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
|
@ -62,8 +58,11 @@ namespace Bit.App.Controls
|
|||
|
||||
public ICommand LongPressAccountCommand { get; }
|
||||
|
||||
public int AccountListRowHeight => // TODO Xamarin.Forms.Device.RuntimePlatform is no longer supported. Use Microsoft.Maui.Devices.DeviceInfo.Platform instead. For more details see https://learn.microsoft.com/en-us/dotnet/maui/migration/forms-projects#device-changes
|
||||
Device.RuntimePlatform == Device.Android ? 74 : 70;
|
||||
#if IOS
|
||||
public int AccountListRowHeight => 70;
|
||||
#else
|
||||
public int AccountListRowHeight => 74;
|
||||
#endif
|
||||
|
||||
public bool LongPressAccountEnabled { get; set; } = true;
|
||||
|
||||
|
@ -90,7 +89,7 @@ Device.RuntimePlatform == Device.Android ? 74 : 70;
|
|||
|
||||
await ViewModel.RefreshAccountViewsAsync();
|
||||
|
||||
await Device.InvokeOnMainThreadAsync(async () =>
|
||||
await MainThread.InvokeOnMainThreadAsync(async () =>
|
||||
{
|
||||
// start listView in default (off-screen) position
|
||||
await _accountListContainer.TranslateTo(0, _accountListContainer.Height * -1, 0);
|
||||
|
@ -106,11 +105,10 @@ Device.RuntimePlatform == Device.Android ? 74 : 70;
|
|||
IsVisible = true;
|
||||
this.FadeTo(1, 100);
|
||||
|
||||
if (Device.RuntimePlatform == Device.Android && MainFab != null)
|
||||
{
|
||||
// start fab fade-out
|
||||
MainFab.FadeTo(0, 200);
|
||||
}
|
||||
#if ANDROID
|
||||
// start fab fade-out
|
||||
MainFab?.FadeTo(0, 200);
|
||||
#endif
|
||||
|
||||
// slide account list into view
|
||||
await _accountListContainer.TranslateTo(0, 0, 200, Easing.SinOut);
|
||||
|
@ -125,16 +123,15 @@ Device.RuntimePlatform == Device.Android ? 74 : 70;
|
|||
return;
|
||||
}
|
||||
// Not all animations are awaited. This is intentional to allow multiple simultaneous animations.
|
||||
await Device.InvokeOnMainThreadAsync(async () =>
|
||||
await MainThread.InvokeOnMainThreadAsync(async () =>
|
||||
{
|
||||
// start overlay fade-out
|
||||
this.FadeTo(0, 200);
|
||||
|
||||
if (Device.RuntimePlatform == Device.Android && MainFab != null)
|
||||
{
|
||||
// start fab fade-in
|
||||
MainFab.FadeTo(1, 200);
|
||||
}
|
||||
#if ANDROID
|
||||
// start fab fade-in
|
||||
MainFab?.FadeTo(1, 200);
|
||||
#endif
|
||||
|
||||
// slide account list out of view
|
||||
await _accountListContainer.TranslateTo(0, _accountListContainer.Height * -1, 200, Easing.SinIn);
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Input;
|
||||
using Bit.App.Utilities;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
|
@ -35,7 +29,9 @@ namespace Bit.App.Controls
|
|||
// this needs to be a new list every time for the binding to get updated,
|
||||
// XF doesn't currentlyl provide a direct way to update on same instance
|
||||
// https://github.com/xamarin/Xamarin.Forms/issues/1950
|
||||
public List<AccountView> AccountViews => _stateService?.AccountViews is null ? null : new List<AccountView>(_stateService.AccountViews);
|
||||
public List<AccountViewCellViewModel> AccountViews => _stateService?.AccountViews is null
|
||||
? null
|
||||
: new List<AccountViewCellViewModel>(_stateService.AccountViews.Select(a => new AccountViewCellViewModel(a)).ToList());
|
||||
|
||||
public bool AllowActiveAccountSelection { get; set; }
|
||||
|
||||
|
@ -83,7 +79,7 @@ namespace Bit.App.Controls
|
|||
{
|
||||
await _stateService.RefreshAccountViewsAsync(AllowAddAccountRow);
|
||||
|
||||
Device.BeginInvokeOnMainThread(() => TriggerPropertyChanged(nameof(AccountViews)));
|
||||
MainThread.BeginInvokeOnMainThread(() => TriggerPropertyChanged(nameof(AccountViews)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
using System.Windows.Input;
|
||||
using Bit.Core.Models.View;
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
public partial class AccountViewCell : ViewCell
|
||||
{
|
||||
public static readonly BindableProperty AccountProperty = BindableProperty.Create(
|
||||
nameof(Account), typeof(AccountView), typeof(AccountViewCell));
|
||||
|
||||
public static readonly BindableProperty SelectAccountCommandProperty = BindableProperty.Create(
|
||||
nameof(SelectAccountCommand), typeof(ICommand), typeof(AccountViewCell));
|
||||
|
||||
|
@ -21,12 +15,6 @@ namespace Bit.App.Controls
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
public AccountView Account
|
||||
{
|
||||
get => GetValue(AccountProperty) as AccountView;
|
||||
set => SetValue(AccountProperty, value);
|
||||
}
|
||||
|
||||
public ICommand SelectAccountCommand
|
||||
{
|
||||
get => GetValue(SelectAccountCommandProperty) as ICommand;
|
||||
|
@ -38,18 +26,5 @@ namespace Bit.App.Controls
|
|||
get => GetValue(LongPressAccountCommandProperty) as ICommand;
|
||||
set => SetValue(LongPressAccountCommandProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
base.OnPropertyChanged(propertyName);
|
||||
if (propertyName == AccountProperty.PropertyName)
|
||||
{
|
||||
if (Account == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BindingContext = new AccountViewCellViewModel(Account);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bit.Core;
|
||||
using System.Globalization;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
|
|
Loading…
Reference in New Issue