1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-30 15:13:24 +00:00

redraw stack layouts on ios tableviews

This commit is contained in:
Kyle Spearrin
2018-01-03 12:18:15 -05:00
parent fa9e22730a
commit 9456f5dc31
16 changed files with 130 additions and 103 deletions

View File

@@ -63,7 +63,7 @@ namespace Bit.iOS.Controls
private void SetSource()
{
var view = (ExtendedTableView)Element;
if(view.NoFooter || view.NoHeader)
if(true || view.NoFooter || view.NoHeader)
{
Control.Source = new CustomTableViewModelRenderer(view);
}
@@ -116,6 +116,7 @@ namespace Bit.iOS.Controls
public class CustomTableViewModelRenderer : UnEvenTableViewModelRenderer
{
private readonly ExtendedTableView _view;
private bool _didRedraw = false;
public CustomTableViewModelRenderer(ExtendedTableView model)
: base(model)
@@ -123,6 +124,16 @@ namespace Bit.iOS.Controls
_view = model;
}
public override async void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
{
// ref https://stackoverflow.com/a/48076188/1090359
if(!_didRedraw && _view.WrappingStackLayout != null)
{
_didRedraw = true;
await _view.WrappingStackLayout()?.RedrawIfNeededAsync(10, false);
}
}
public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
if(_view.HasUnevenRows)
@@ -143,6 +154,16 @@ namespace Bit.iOS.Controls
return base.GetHeightForHeader(tableView, section);
}
public override UIView GetViewForHeader(UITableView tableView, nint section)
{
if(_view.NoHeader && section == 0)
{
return new UIView(new CGRect(0, 0, 0, 0));
}
return null;
}
public override nfloat GetHeightForFooter(UITableView tableView, nint section)
{
if(_view.NoFooter && (section + 1) == NumberOfSections(tableView))
@@ -152,6 +173,16 @@ namespace Bit.iOS.Controls
return 10f;
}
public override UIView GetViewForFooter(UITableView tableView, nint section)
{
if(_view.NoFooter && (section + 1) == NumberOfSections(tableView))
{
return new UIView(new CGRect(0, 0, 0, 0));
}
return null;
}
}
}
}