mirror of
https://github.com/bitwarden/mobile.git
synced 2024-09-28 03:57:43 +02: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:
parent
382e547f74
commit
05e8da4bcc
@ -710,7 +710,10 @@
|
|||||||
</StackLayout>
|
</StackLayout>
|
||||||
<BoxView StyleClass="box-row-separator" />
|
<BoxView StyleClass="box-row-separator" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<controls:RepeaterView ItemsSource="{Binding Collections}" IsVisible="{Binding HasCollections}">
|
<controls:RepeaterView
|
||||||
|
x:Name="_collectionsRepeaterView"
|
||||||
|
ItemsSource="{Binding Collections}"
|
||||||
|
IsVisible="{Binding HasCollections}">
|
||||||
<controls:RepeaterView.ItemTemplate>
|
<controls:RepeaterView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="pages:CollectionViewModel">
|
<DataTemplate x:DataType="pages:CollectionViewModel">
|
||||||
<StackLayout Spacing="0" Padding="0">
|
<StackLayout Spacing="0" Padding="0">
|
||||||
|
@ -47,6 +47,7 @@ namespace Bit.App.Pages
|
|||||||
_vm.CipherId = cipherId;
|
_vm.CipherId = cipherId;
|
||||||
_vm.FolderId = folderId == "none" ? null : folderId;
|
_vm.FolderId = folderId == "none" ? null : folderId;
|
||||||
_vm.CollectionIds = collectionId != null ? new HashSet<string>(new List<string> { collectionId }) : null;
|
_vm.CollectionIds = collectionId != null ? new HashSet<string>(new List<string> { collectionId }) : null;
|
||||||
|
_vm.CollectionsRepeaterView = _collectionsRepeaterView;
|
||||||
_vm.Type = type;
|
_vm.Type = type;
|
||||||
_vm.DefaultName = name ?? appOptions?.SaveName;
|
_vm.DefaultName = name ?? appOptions?.SaveName;
|
||||||
_vm.DefaultUri = uri ?? appOptions?.Uri;
|
_vm.DefaultUri = uri ?? appOptions?.Uri;
|
||||||
@ -158,6 +159,7 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
RequestFocus(_nameEntry);
|
RequestFocus(_nameEntry);
|
||||||
}
|
}
|
||||||
|
_scrollView.Scrolled += (sender, args) => _vm.HandleScroll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Bit.App.Abstractions;
|
using System;
|
||||||
|
using Bit.App.Abstractions;
|
||||||
using Bit.App.Models;
|
using Bit.App.Models;
|
||||||
using Bit.App.Resources;
|
using Bit.App.Resources;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
@ -9,6 +10,7 @@ using Bit.Core.Utilities;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Bit.App.Controls;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using View = Xamarin.Forms.View;
|
using View = Xamarin.Forms.View;
|
||||||
|
|
||||||
@ -39,6 +41,7 @@ namespace Bit.App.Pages
|
|||||||
private int _ownershipSelectedIndex;
|
private int _ownershipSelectedIndex;
|
||||||
private bool _hasCollections;
|
private bool _hasCollections;
|
||||||
private string _previousCipherId;
|
private string _previousCipherId;
|
||||||
|
private DateTime _lastHandledScrollTime;
|
||||||
private List<Core.Models.View.CollectionView> _writeableCollections;
|
private List<Core.Models.View.CollectionView> _writeableCollections;
|
||||||
private string[] _additionalCipherProperties = new string[]
|
private string[] _additionalCipherProperties = new string[]
|
||||||
{
|
{
|
||||||
@ -166,6 +169,7 @@ namespace Bit.App.Pages
|
|||||||
public ExtendedObservableCollection<LoginUriView> Uris { get; set; }
|
public ExtendedObservableCollection<LoginUriView> Uris { get; set; }
|
||||||
public ExtendedObservableCollection<AddEditPageFieldViewModel> Fields { get; set; }
|
public ExtendedObservableCollection<AddEditPageFieldViewModel> Fields { get; set; }
|
||||||
public ExtendedObservableCollection<CollectionViewModel> Collections { get; set; }
|
public ExtendedObservableCollection<CollectionViewModel> Collections { get; set; }
|
||||||
|
public RepeaterView CollectionsRepeaterView { get; set; }
|
||||||
public int TypeSelectedIndex
|
public int TypeSelectedIndex
|
||||||
{
|
{
|
||||||
get => _typeSelectedIndex;
|
get => _typeSelectedIndex;
|
||||||
@ -800,13 +804,30 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
var cols = _writeableCollections.Where(c => c.OrganizationId == Cipher.OrganizationId)
|
var cols = _writeableCollections.Where(c => c.OrganizationId == Cipher.OrganizationId)
|
||||||
.Select(c => new CollectionViewModel { Collection = c }).ToList();
|
.Select(c => new CollectionViewModel { Collection = c }).ToList();
|
||||||
|
HasCollections = cols.Any();
|
||||||
Collections.ResetWithRange(cols);
|
Collections.ResetWithRange(cols);
|
||||||
|
Collections = new ExtendedObservableCollection<CollectionViewModel>(cols);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
HasCollections = false;
|
||||||
Collections.ResetWithRange(new List<CollectionViewModel>());
|
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()
|
private void TriggerCipherChanged()
|
||||||
|
Loading…
Reference in New Issue
Block a user