Commit 7df29c7b authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Chromium LUCI CQ

[iOS] Have correct zPosition for grid cells

This CL makes sure to update the zPosition of the cells in the TabGrid
when they are inserted to allow the upper rows to be above the lower
rows.

Fixed: 1155122
Change-Id: Ib232dab6d35fa23c828fb027358cb2411e396982
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2571284Reviewed-by: default avatarRobbie Gibson <rkgibson@google.com>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833355}
parent d2ee30a3
...@@ -369,9 +369,9 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -369,9 +369,9 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
GridCell* gridCell = base::mac::ObjCCastStrict<GridCell>(cell); GridCell* gridCell = base::mac::ObjCCastStrict<GridCell>(cell);
[self configureCell:gridCell withItem:item]; [self configureCell:gridCell withItem:item];
} }
// Set the z index of cells so that lower rows are superposed during // Set the z index of cells so that lower rows are moving behind the upper
// transitions between grid and horizontal layouts. // rows during transitions between grid and horizontal layouts.
cell.layer.zPosition = itemIndex; cell.layer.zPosition = self.items.count - itemIndex;
#if defined(__IPHONE_13_4) #if defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) { if (@available(iOS 13.4, *)) {
...@@ -710,6 +710,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -710,6 +710,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self performModelUpdates:modelUpdates [self performModelUpdates:modelUpdates
collectionViewUpdates:collectionViewUpdates collectionViewUpdates:collectionViewUpdates
collectionViewUpdatesCompletion:completion]; collectionViewUpdatesCompletion:completion];
[self updateVisibleCellZIndex];
} }
- (void)removeItemWithID:(NSString*)removedItemID - (void)removeItemWithID:(NSString*)removedItemID
...@@ -750,6 +752,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -750,6 +752,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self performModelUpdates:modelUpdates [self performModelUpdates:modelUpdates
collectionViewUpdates:collectionViewUpdates collectionViewUpdates:collectionViewUpdates
collectionViewUpdatesCompletion:completion]; collectionViewUpdatesCompletion:completion];
[self updateVisibleCellZIndex];
} }
- (void)selectItemWithID:(NSString*)selectedItemID { - (void)selectItemWithID:(NSString*)selectedItemID {
...@@ -804,6 +808,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -804,6 +808,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self performModelUpdates:modelUpdates [self performModelUpdates:modelUpdates
collectionViewUpdates:collectionViewUpdates collectionViewUpdates:collectionViewUpdates
collectionViewUpdatesCompletion:completion]; collectionViewUpdatesCompletion:completion];
[self updateVisibleCellZIndex];
} }
#pragma mark - LayoutSwitcher #pragma mark - LayoutSwitcher
...@@ -1010,6 +1016,19 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -1010,6 +1016,19 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
1 - offset / kScrollThresholdForPlusSignButtonHide, 0, 1); 1 - offset / kScrollThresholdForPlusSignButtonHide, 0, 1);
} }
// Updates the ZIndex of the visible cells to have the cells of the upper rows
// be above the cell of the lower rows.
- (void)updateVisibleCellZIndex {
for (NSIndexPath* indexPath in self.collectionView
.indexPathsForVisibleItems) {
// Set the z index of cells so that lower rows are moving behind the upper
// rows during transitions between grid and horizontal layouts.
UICollectionViewCell* cell =
[self.collectionView cellForItemAtIndexPath:indexPath];
cell.layer.zPosition = self.items.count - indexPath.item;
}
}
#pragma mark - Custom Gesture-based Reordering #pragma mark - Custom Gesture-based Reordering
// Handle the long-press gesture used to reorder cells in the collection view. // Handle the long-press gesture used to reorder cells in the collection view.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment