diff --git a/src/Core/Controls/SendViewCell/SendViewCell.xaml.cs b/src/Core/Controls/SendViewCell/SendViewCell.xaml.cs index b9ac7cb6a..bda29f2ce 100644 --- a/src/Core/Controls/SendViewCell/SendViewCell.xaml.cs +++ b/src/Core/Controls/SendViewCell/SendViewCell.xaml.cs @@ -1,62 +1,28 @@ -using System; -using Bit.App.Abstractions; +using Bit.App.Abstractions; using Bit.Core.Models.View; using Bit.Core.Utilities; -using Microsoft.Maui.Controls; -using Microsoft.Maui; namespace Bit.App.Controls { public partial class SendViewCell : ExtendedGrid { - public static readonly BindableProperty SendProperty = BindableProperty.Create( - nameof(Send), typeof(SendView), typeof(SendViewCell), default(SendView), BindingMode.OneWay); - public static readonly BindableProperty ButtonCommandProperty = BindableProperty.Create( nameof(ButtonCommand), typeof(Command), typeof(SendViewCell)); - public static readonly BindableProperty ShowOptionsProperty = BindableProperty.Create( - nameof(ShowOptions), typeof(bool), typeof(SendViewCell), true, BindingMode.OneWay); - public SendViewCell() { InitializeComponent(); - var deviceActionService = ServiceContainer.Resolve("deviceActionService"); + var deviceActionService = ServiceContainer.Resolve(); _iconColumn.Width = new GridLength(40 * deviceActionService.GetSystemFontSizeScale(), GridUnitType.Absolute); } - public SendView Send - { - get => GetValue(SendProperty) as SendView; - set => SetValue(SendProperty, value); - } - public Command ButtonCommand { get => GetValue(ButtonCommandProperty) as Command; set => SetValue(ButtonCommandProperty, value); } - public bool ShowOptions - { - get => (bool)GetValue(ShowOptionsProperty); - set => SetValue(ShowOptionsProperty, value); - } - - protected override void OnPropertyChanged(string propertyName = null) - { - base.OnPropertyChanged(propertyName); - if (propertyName == SendProperty.PropertyName) - { - if (Send == null) - { - return; - } - BindingContext = new SendViewCellViewModel(Send, ShowOptions); - } - } - private void MoreButton_Clicked(object sender, EventArgs e) { var send = ((sender as MiButton)?.BindingContext as SendViewCellViewModel)?.Send; diff --git a/src/Core/Controls/SendViewCell/SendViewCellViewModel.cs b/src/Core/Controls/SendViewCell/SendViewCellViewModel.cs index 63f6f3704..e0df63491 100644 --- a/src/Core/Controls/SendViewCell/SendViewCellViewModel.cs +++ b/src/Core/Controls/SendViewCell/SendViewCellViewModel.cs @@ -1,4 +1,5 @@ -using Bit.Core.Models.View; +using System.Globalization; +using Bit.Core.Models.View; using Bit.Core.Utilities; namespace Bit.App.Controls diff --git a/src/Core/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml b/src/Core/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml index 84b32bd04..2f7a66790 100644 --- a/src/Core/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml +++ b/src/Core/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml @@ -37,12 +37,13 @@ SemanticProperties.Description="{u:I18n AddItem}" /> - + x:DataType="pages:SendGroupingsPageListItem"> + + + new SendGroupingsPageListItem - { - Send = s, - ShowOptions = SendEnabled - }).ToList(); + var sendsListItems = Sends.Select(s => new SendGroupingsPageListItem(s, SendEnabled)).ToList(); groupedSends.Add(new SendGroupingsPageListGroup(sendsListItems, MainPage ? AppResources.AllSends : AppResources.Sends, sendsListItems.Count, uppercaseGroupNames, !MainPage)); } - // TODO: refactor this - // 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 - if (Device.RuntimePlatform == Device.Android + if (DeviceInfo.Platform == DevicePlatform.Android || GroupedSends.Any()) { diff --git a/src/Core/Pages/Send/SendsPage.xaml b/src/Core/Pages/Send/SendsPage.xaml index 4b65b072b..07f19cdae 100644 --- a/src/Core/Pages/Send/SendsPage.xaml +++ b/src/Core/Pages/Send/SendsPage.xaml @@ -71,11 +71,9 @@ ExtraDataForLogging="Sends Page" AutomationId="SendCellList"> - + diff --git a/src/Core/Pages/Send/SendsPage.xaml.cs b/src/Core/Pages/Send/SendsPage.xaml.cs index 1eded74c1..ecbb84d28 100644 --- a/src/Core/Pages/Send/SendsPage.xaml.cs +++ b/src/Core/Pages/Send/SendsPage.xaml.cs @@ -108,9 +108,9 @@ namespace Bit.App.Pages return; } - if (e.CurrentSelection?.FirstOrDefault() is SendView send) + if (e.CurrentSelection?.FirstOrDefault() is SendViewCellViewModel sendVM) { - await _vm.SelectSendAsync(send); + await _vm.SelectSendAsync(sendVM.Send); } } diff --git a/src/Core/Pages/Send/SendsPageViewModel.cs b/src/Core/Pages/Send/SendsPageViewModel.cs index 25a13040f..af35388c6 100644 --- a/src/Core/Pages/Send/SendsPageViewModel.cs +++ b/src/Core/Pages/Send/SendsPageViewModel.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; +using Bit.App.Controls; 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.Pages { @@ -22,13 +17,13 @@ namespace Bit.App.Pages public SendsPageViewModel() { - _searchService = ServiceContainer.Resolve("searchService"); - Sends = new ExtendedObservableCollection(); + _searchService = ServiceContainer.Resolve(); + Sends = new ExtendedObservableCollection(); SendOptionsCommand = new Command(SendOptionsAsync); } public Command SendOptionsCommand { get; set; } - public ExtendedObservableCollection Sends { get; set; } + public ExtendedObservableCollection Sends { get; set; } public Func Filter { get; set; } public bool SendEnabled @@ -102,9 +97,9 @@ namespace Bit.App.Pages { sends = new List(); } - Device.BeginInvokeOnMainThread(() => + MainThread.BeginInvokeOnMainThread(() => { - Sends.ResetWithRange(sends); + Sends.ResetWithRange(sends.Select(s => new SendViewCellViewModel(s, SendEnabled)).ToList()); ShowNoData = searchable && Sends.Count == 0; ShowList = searchable && !ShowNoData; });