Skip to content

Instantly share code, notes, and snippets.

@karlwhite
Last active March 15, 2016 14:35
Show Gist options
  • Save karlwhite/294523ee2842dc7fc60a to your computer and use it in GitHub Desktop.
Save karlwhite/294523ee2842dc7fc60a to your computer and use it in GitHub Desktop.
- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
switch( tableView.tag ) {
case InboxTable_Folders: {
// Expand folders
self.folderWidth.constant = FOLDERS_OPEN;
self.threadWidth.constant = THREADS_OPEN;
[self.view setNeedsLayout];
[self.view setNeedsUpdateConstraints];
[UIView animateWithDuration:0.35 delay:0 usingSpringWithDamping:0.75 initialSpringVelocity:0.05 options:UIViewAnimationOptionCurveLinear|UIViewAnimationOptionBeginFromCurrentState animations:^{
[self.view layoutIfNeeded];
[self.mailPreviewContainer zoomToRect:CGRectMake(0, 0, MIN_PREVIEW_WIDTH, 1) animated:NO];
} completion:nil];
break;
}
case InboxTable_Threads: {
// Collapse folders
if ( context.previouslyFocusedView != self.mailPreview ) {
if ( context.previouslyFocusedView.superview != context.nextFocusedView.superview ) {
self.folderWidth.constant = FOLDERS_COLLAPSED;
self.threadWidth.constant = THREADS_OPEN;
[self.view setNeedsLayout];
[self.view setNeedsUpdateConstraints];
[UIView animateWithDuration:0.35 delay:0 usingSpringWithDamping:0.75 initialSpringVelocity:0.05 options:UIViewAnimationOptionCurveLinear|UIViewAnimationOptionBeginFromCurrentState animations:^{
[self.view layoutIfNeeded];
[self.mailPreviewContainer zoomToRect:CGRectMake(0, 0, MIN_PREVIEW_WIDTH, 1) animated:NO];
} completion:nil];
}
}
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment