private async Task InitTableViewAsync() { // delay is need to delay UI thread freezing while TableNode items are loaded // thus previous screen will not be frozen await Task.Delay(1); Table.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.Interactive; Table.TranslatesAutoresizingMaskIntoConstraints = false; Table.BackgroundColor = UIColor.FromRGB(245, 245, 245); Table.AddGestureRecognizer(new UITapGestureRecognizer((obj) => Input.TextView.ResignFirstResponder())); var tableSource = new GroupedTableDataSource <DateTimeOffset, ChatMessageViewModel>( ViewModel.MessagesList.Messages, Table, viewModel => GetMessageNode(viewModel), TableNode.Inverted); Table.EstimatedRowHeight = MinCellHeight; Table.SeparatorStyle = UITableViewCellSeparatorStyle.None; _dataSourceRef = WeakReferenceEx.Create(tableSource); TableNode.DataSource = tableSource; TableNode.Delegate = _tableDelegate; TableNode.SetTuningParameters(new ASRangeTuningParameters { leadingBufferScreenfuls = 1, trailingBufferScreenfuls = 1 }, ASLayoutRangeType.Display); TableNode.SetTuningParameters(new ASRangeTuningParameters { leadingBufferScreenfuls = 1, trailingBufferScreenfuls = 1 }, ASLayoutRangeType.Preload); TableNode.ReloadData(); TableNode.LeadingScreensForBatching = 3; }
public override void WillDisplayNodeForRowAtIndexPath(ASTableView tableView, NSIndexPath indexPath) { if (_source == null) { var table = tableView as ASTableView; _source = table.TableNode.DataSource as GroupedTableDataSource <DateTimeOffset, ChatMessageViewModel>; } var count = _source.DataSource[0].Count; if (indexPath.Section == _source.DataSource.Count - 1 && indexPath.Row == count - 1) { LastItemRequested?.Invoke(this, EventArgs.Empty); } }