Tap on avatar in Member Info page to zoom to view avatar full page #517

Do it on the contact details screen too.
This commit is contained in:
manuroe
2016-09-14 16:38:25 +02:00
parent 24c9cddca2
commit 53a8a8057c
3 changed files with 60 additions and 2 deletions
@@ -117,7 +117,24 @@
contactAvatar = contactTitleView.memberAvatar;
contactAvatar.contentMode = UIViewContentModeScaleAspectFill;
contactAvatar.backgroundColor = [UIColor clearColor];
// Add tap to show the contact avatar in fullscreen
tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
[tap setNumberOfTouchesRequired:1];
[tap setNumberOfTapsRequired:1];
[tap setDelegate:self];
[contactAvatar addGestureRecognizer:tap];
contactAvatar.userInteractionEnabled = YES;
// Need to listen tap gesture on the area part of the avatar image that is outside
// of the navigation bar, its parent but smaller view.
tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
[tap setNumberOfTouchesRequired:1];
[tap setNumberOfTapsRequired:1];
[tap setDelegate:self];
[self.contactAvatarMask addGestureRecognizer:tap];
self.contactAvatarMask.userInteractionEnabled = YES;
// Add the title view and define edge constraints
contactTitleView.translatesAutoresizingMaskIntoConstraints = NO;
[self.navigationItem.titleView addSubview:contactTitleView];
@@ -774,6 +791,35 @@
self.contactNameLabel.text = _contact.displayName;
}
}
else if (view == contactAvatar || view == self.contactAvatarMask)
{
// Show the avatar in full screen
__block MXKImageView * avatarFullScreenView = [[MXKImageView alloc] initWithFrame:CGRectZero];
avatarFullScreenView.stretchable = YES;
[avatarFullScreenView setRightButtonTitle:[NSBundle mxk_localizedStringForKey:@"ok"] handler:^(MXKImageView* imageView, NSString* buttonTitle) {
[avatarFullScreenView dismissSelection];
[avatarFullScreenView removeFromSuperview];
avatarFullScreenView = nil;
}];
NSString *avatarURL = nil;
if (self.firstMatrixId)
{
MXUser *user = [self.mainSession userWithUserId:self.firstMatrixId];
avatarURL = [self.mainSession.matrixRestClient urlOfContent:user.avatarUrl];
}
// TODO: Display the orignal contact avatar when the contast is not a Matrix user
[avatarFullScreenView setImageURL:avatarURL
withType:nil
andImageOrientation:UIImageOrientationUp
previewImage:contactAvatar.image];
[avatarFullScreenView showFullScreen];
}
}
@end