public void calculates_diff_from_level_0_to_level_1() { var node = CreateNodeOfLevel0(); var otherNode = CreateNodeOfLevel1(); var diffResult = TreeMenuDiff.Calculate(node, otherNode); Assert.Equal(new[] { 0, 2, 3, 4 }, diffResult.AddedIndexes); Assert.Equal(new[] { 1 }, diffResult.RemovedIndexes); Assert.Equal(new[] { (0, ItemRelation.Selected) }, diffResult.ChangedIndexes);
private async Task SetCurrentNodeWithAnimationAsync(UICollectionView collectionView, TreeNode <T, TKey> selectedNode) { var diffResult = TreeMenuDiff.Calculate(_currentNode, selectedNode); diffResult .ChangedIndexes .Select(x => (cell: collectionView.CellForItem(NSIndexPath.FromRowSection(x.Index, 0)), relation: x.Relation)) .Where(x => x.cell != null) .ForEach((_, x) => _itemStateChanged(x.cell, x.relation)); _currentNode = selectedNode; _itemCollection.CurrentNode = selectedNode; await AnimateDiffAsync(collectionView, diffResult); NodeSelected?.Invoke(this, selectedNode); }
private async Task SetCurrentNodeWithAnimationAsync(TreeNode <T, TKey> selectedNode) { var diffResult = TreeMenuDiff.Calculate(_currentNode, selectedNode); diffResult .ChangedIndexes .Select(x => (cell: _recyclerView.FindViewHolderForLayoutPosition(x.Index), relation: x.Relation)) .Where(x => x.cell != null) .ForEach((_, x) => _itemStateChanged(x.cell, x.relation)); _currentNode = selectedNode; _itemCollection.CurrentNode = selectedNode; _itemAnimator.DiffResult = diffResult; await AnimateDiffAsync(diffResult); NodeSelected?.Invoke(this, selectedNode); }