Commit 5202a6de authored by edchin's avatar edchin Committed by Commit Bot

[ios] Fix tab grid empty state disappearance

Previously, the empty state was showing for a split second, then
animating off. If there are items in the grid, the empty state should
just not show, rather than animating off.

Bug: 870267
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I6de30daaf0fb7ee5b1fe0ffe3f2da78ac95c7a83
Reviewed-on: https://chromium-review.googlesource.com/1176647
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584516}
parent 0cb6b59e
......@@ -154,7 +154,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
scrollPosition:UICollectionViewScrollPositionTop];
// Update the delegate, in case it wasn't set when |items| was populated.
[self.delegate gridViewController:self didChangeItemCount:self.items.count];
[self animateEmptyStateOut];
[self removeEmptyStateAnimated:NO];
self.lastInsertedItemID = nil;
}
......@@ -369,7 +369,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self.delegate gridViewController:self didChangeItemCount:self.items.count];
};
auto collectionViewUpdates = ^{
[self animateEmptyStateOut];
[self removeEmptyStateAnimated:YES];
[self.collectionView insertItemsAtIndexPaths:@[ CreateIndexPath(index) ]];
};
auto completion = ^(BOOL finished) {
......@@ -553,20 +553,25 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self.emptyStateAnimator startAnimation];
}
// Animates the empty state out of view.
- (void)animateEmptyStateOut {
// Removes the empty state out of view, with animation if |animated| is YES.
- (void)removeEmptyStateAnimated:(BOOL)animated {
// TODO(crbug.com/820410) : Polish the animation, and put constants where they
// belong.
[self.emptyStateAnimator stopAnimation:YES];
self.emptyStateAnimator = [[UIViewPropertyAnimator alloc]
initWithDuration:self.emptyStateView.alpha
dampingRatio:1.0
animations:^{
self.emptyStateView.alpha = 0.0;
self.emptyStateView.transform = CGAffineTransformScale(
CGAffineTransformIdentity, /*sx=*/0.9, /*sy=*/0.9);
}];
[self.emptyStateAnimator startAnimation];
auto removeEmptyState = ^{
self.emptyStateView.alpha = 0.0;
self.emptyStateView.transform = CGAffineTransformScale(
CGAffineTransformIdentity, /*sx=*/0.9, /*sy=*/0.9);
};
if (animated) {
self.emptyStateAnimator = [[UIViewPropertyAnimator alloc]
initWithDuration:self.emptyStateView.alpha
dampingRatio:1.0
animations:removeEmptyState];
[self.emptyStateAnimator startAnimation];
} else {
removeEmptyState();
}
}
// 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