mirror of
https://github.com/bitwarden/android.git
synced 2024-12-27 11:28:28 +03:00
PM-3349 PM-3350 Added workaround for More Options to work on Search and Groupings Page
Updated some code to MAUI Style also
This commit is contained in:
parent
bfa2a51608
commit
d168a7b750
6 changed files with 28 additions and 40 deletions
|
@ -1,5 +1,6 @@
|
|||
using System.Windows.Input;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Pages;
|
||||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
|
@ -59,10 +60,21 @@ namespace Bit.App.Controls
|
|||
|
||||
private void MoreButton_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
var cipher = ((sender as MiButton)?.BindingContext as CipherViewCellViewModel)?.Cipher;
|
||||
if (cipher != null)
|
||||
// WORKAROUND: Added a temporary workaround so that the MoreButton still works in all pages even if it uses GroupingsPageListItem instead of CipherViewCellViewModel.
|
||||
// Ideally this should be fixed so that even Groupings Page uses CipherViewCellViewModel
|
||||
CipherView cipherView = null;
|
||||
if (BindingContext is CipherViewCellViewModel cipherViewCellViewModel)
|
||||
{
|
||||
ButtonCommand?.Execute(cipher);
|
||||
cipherView = cipherViewCellViewModel.Cipher;
|
||||
}
|
||||
else if (BindingContext is GroupingsPageListItem groupingsPageListItem)
|
||||
{
|
||||
cipherView = groupingsPageListItem.Cipher;
|
||||
}
|
||||
|
||||
if (cipherView != null)
|
||||
{
|
||||
ButtonCommand?.Execute(cipherView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ namespace Bit.App.Controls
|
|||
// TODO: [TouchEffect] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*")
|
||||
var touchBehavior = new TouchBehavior()
|
||||
{
|
||||
NativeAnimation = true
|
||||
NativeAnimation = true,
|
||||
ShouldMakeChildrenInputTransparent = false
|
||||
};
|
||||
Behaviors.Add(touchBehavior);
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,8 @@ namespace Bit.App.Controls
|
|||
// TODO: [TouchEffect] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*")
|
||||
var touchBehavior = new TouchBehavior()
|
||||
{
|
||||
NativeAnimation = true
|
||||
NativeAnimation = true,
|
||||
ShouldMakeChildrenInputTransparent = false
|
||||
};
|
||||
Behaviors.Add(touchBehavior);
|
||||
#endif
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Input;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Controls;
|
||||
using Bit.App.Models;
|
||||
using Bit.Core.Resources.Localization;
|
||||
using Bit.App.Utilities;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public abstract class CipherSelectionPageViewModel : BaseViewModel
|
||||
|
@ -108,10 +99,7 @@ namespace Bit.App.Pages
|
|||
var groupedItems = await LoadGroupedItemsAsync();
|
||||
|
||||
// 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
|
||||
||
|
||||
GroupedItems.Any())
|
||||
if (DeviceInfo.Platform == DevicePlatform.Android || GroupedItems.Any())
|
||||
{
|
||||
var items = new List<IGroupingsPageListItem>();
|
||||
foreach (var itemGroup in groupedItems)
|
||||
|
@ -140,7 +128,7 @@ namespace Bit.App.Pages
|
|||
items.AddRange(itemGroup);
|
||||
}
|
||||
|
||||
await Device.InvokeOnMainThreadAsync(() =>
|
||||
await MainThread.InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
if (groupedItems.Any())
|
||||
{
|
||||
|
@ -153,7 +141,7 @@ namespace Bit.App.Pages
|
|||
}
|
||||
});
|
||||
}
|
||||
await Device.InvokeOnMainThreadAsync(() =>
|
||||
await MainThread.InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
ShowList = groupedItems.Any();
|
||||
ShowNoData = !ShowList;
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Bit.App.Controls;
|
||||
using Bit.App.Controls;
|
||||
using Bit.App.Models;
|
||||
using Bit.Core.Resources.Localization;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
|
@ -41,8 +37,7 @@ namespace Bit.App.Pages
|
|||
}
|
||||
_vm.VaultFilterDescription = vaultFilterSelection;
|
||||
|
||||
// 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.iOS)
|
||||
if (DeviceInfo.Platform == DevicePlatform.iOS)
|
||||
{
|
||||
ToolbarItems.Add(_closeItem);
|
||||
_searchBar.Placeholder = AppResources.Search;
|
||||
|
@ -59,7 +54,7 @@ namespace Bit.App.Pages
|
|||
|
||||
public SearchBar SearchBar => _searchBar;
|
||||
|
||||
protected async override void OnAppearing()
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
await _vm.InitAsync();
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Input;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Bit.Core.Resources.Localization;
|
||||
|
@ -13,10 +8,6 @@ using Bit.Core.Exceptions;
|
|||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui;
|
||||
using Bit.App.Utilities;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public class CiphersPageViewModel : VaultFilterViewModel
|
||||
|
@ -164,7 +155,7 @@ namespace Bit.App.Pages
|
|||
{
|
||||
ciphers = new List<CipherView>();
|
||||
}
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
MainThread.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
Ciphers.ResetWithRange(ciphers);
|
||||
ShowNoData = !shouldShowAllWhenEmpty && searchable && Ciphers.Count == 0;
|
||||
|
|
Loading…
Reference in a new issue