diff --git a/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml b/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml index 926fc876e..b95be2cb4 100644 --- a/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml +++ b/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml @@ -36,13 +36,11 @@ effects:ScrollViewContentInsetAdjustmentBehaviorEffect.ContentInsetAdjustmentBehavior="Never" AutomationId="AccountListView"> - + + AutomationId="AccountViewCell" /> diff --git a/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml.cs b/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml.cs index 17616b97a..90e121d68 100644 --- a/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml.cs +++ b/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml.cs @@ -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); diff --git a/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayViewModel.cs b/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayViewModel.cs index 272201818..fde0cdea0 100644 --- a/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayViewModel.cs +++ b/src/Core/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayViewModel.cs @@ -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 AccountViews => _stateService?.AccountViews is null ? null : new List(_stateService.AccountViews); + public List AccountViews => _stateService?.AccountViews is null + ? null + : new List(_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))); } } } diff --git a/src/Core/Controls/AccountViewCell/AccountViewCell.xaml.cs b/src/Core/Controls/AccountViewCell/AccountViewCell.xaml.cs index 65c1b9008..003ae21d3 100644 --- a/src/Core/Controls/AccountViewCell/AccountViewCell.xaml.cs +++ b/src/Core/Controls/AccountViewCell/AccountViewCell.xaml.cs @@ -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); - } - } } } diff --git a/src/Core/Controls/AccountViewCell/AccountViewCellViewModel.cs b/src/Core/Controls/AccountViewCell/AccountViewCellViewModel.cs index 2cc33d54a..5bc6e942e 100644 --- a/src/Core/Controls/AccountViewCell/AccountViewCellViewModel.cs +++ b/src/Core/Controls/AccountViewCell/AccountViewCellViewModel.cs @@ -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;