1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

Workaround for off-screen draw bug in XF4.5+ (#1447)

* workaround for off-screen draw bug in xf4.5+

* check cols even if orgId is present
This commit is contained in:
Matt Portune
2021-06-30 17:46:59 -04:00
committed by GitHub
parent 382e547f74
commit 05e8da4bcc
3 changed files with 29 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
using Bit.App.Abstractions;
using System;
using Bit.App.Abstractions;
using Bit.App.Models;
using Bit.App.Resources;
using Bit.Core.Abstractions;
@@ -9,6 +10,7 @@ using Bit.Core.Utilities;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bit.App.Controls;
using Xamarin.Forms;
using View = Xamarin.Forms.View;
@@ -39,6 +41,7 @@ namespace Bit.App.Pages
private int _ownershipSelectedIndex;
private bool _hasCollections;
private string _previousCipherId;
private DateTime _lastHandledScrollTime;
private List<Core.Models.View.CollectionView> _writeableCollections;
private string[] _additionalCipherProperties = new string[]
{
@@ -166,6 +169,7 @@ namespace Bit.App.Pages
public ExtendedObservableCollection<LoginUriView> Uris { get; set; }
public ExtendedObservableCollection<AddEditPageFieldViewModel> Fields { get; set; }
public ExtendedObservableCollection<CollectionViewModel> Collections { get; set; }
public RepeaterView CollectionsRepeaterView { get; set; }
public int TypeSelectedIndex
{
get => _typeSelectedIndex;
@@ -800,13 +804,30 @@ namespace Bit.App.Pages
{
var cols = _writeableCollections.Where(c => c.OrganizationId == Cipher.OrganizationId)
.Select(c => new CollectionViewModel { Collection = c }).ToList();
HasCollections = cols.Any();
Collections.ResetWithRange(cols);
Collections = new ExtendedObservableCollection<CollectionViewModel>(cols);
}
else
{
HasCollections = false;
Collections.ResetWithRange(new List<CollectionViewModel>());
Collections = new ExtendedObservableCollection<CollectionViewModel>(new List<CollectionViewModel>());
}
HasCollections = Collections.Any();
}
public void HandleScroll()
{
// workaround for https://github.com/xamarin/Xamarin.Forms/issues/13607
// required for org ownership/collections to render properly in XF4.5+
if (!HasCollections ||
EditMode ||
(DateTime.Now - _lastHandledScrollTime < TimeSpan.FromMilliseconds(200)))
{
return;
}
CollectionsRepeaterView.ItemsSource = Collections;
_lastHandledScrollTime = DateTime.Now;
}
private void TriggerCipherChanged()