Rename FullImageViewController -> MediaDetailViewController

// FREEBIE
This commit is contained in:
Michael Kirk 2018-01-07 23:33:25 -05:00
parent 8454e512d8
commit 412fe2735e
6 changed files with 64 additions and 65 deletions

View File

@ -44,7 +44,7 @@
34B3F8791E8DF1700035BE1A /* CountryCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8411E8DF1700035BE1A /* CountryCodeViewController.m */; };
34B3F87B1E8DF1700035BE1A /* ExperienceUpgradesPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8441E8DF1700035BE1A /* ExperienceUpgradesPageViewController.swift */; };
34B3F87C1E8DF1700035BE1A /* FingerprintViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8461E8DF1700035BE1A /* FingerprintViewController.m */; };
34B3F87D1E8DF1700035BE1A /* FullImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8481E8DF1700035BE1A /* FullImageViewController.m */; };
34B3F87D1E8DF1700035BE1A /* MediaDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8481E8DF1700035BE1A /* MediaDetailViewController.m */; };
34B3F87E1E8DF1700035BE1A /* InboxTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F84A1E8DF1700035BE1A /* InboxTableViewCell.m */; };
34B3F8801E8DF1700035BE1A /* InviteFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */; };
34B3F8811E8DF1700035BE1A /* LockInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F84E1E8DF1700035BE1A /* LockInteractionController.m */; };
@ -467,8 +467,8 @@
34B3F8441E8DF1700035BE1A /* ExperienceUpgradesPageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExperienceUpgradesPageViewController.swift; sourceTree = "<group>"; };
34B3F8451E8DF1700035BE1A /* FingerprintViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FingerprintViewController.h; sourceTree = "<group>"; };
34B3F8461E8DF1700035BE1A /* FingerprintViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FingerprintViewController.m; sourceTree = "<group>"; };
34B3F8471E8DF1700035BE1A /* FullImageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullImageViewController.h; sourceTree = "<group>"; };
34B3F8481E8DF1700035BE1A /* FullImageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FullImageViewController.m; sourceTree = "<group>"; };
34B3F8471E8DF1700035BE1A /* MediaDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDetailViewController.h; sourceTree = "<group>"; };
34B3F8481E8DF1700035BE1A /* MediaDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MediaDetailViewController.m; sourceTree = "<group>"; };
34B3F8491E8DF1700035BE1A /* InboxTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InboxTableViewCell.h; sourceTree = "<group>"; };
34B3F84A1E8DF1700035BE1A /* InboxTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InboxTableViewCell.m; sourceTree = "<group>"; };
34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InviteFlow.swift; sourceTree = "<group>"; };
@ -1029,8 +1029,8 @@
34B3F8461E8DF1700035BE1A /* FingerprintViewController.m */,
34E8BF361EE9E2FD00F5F4CA /* FingerprintViewScanController.h */,
34E8BF371EE9E2FD00F5F4CA /* FingerprintViewScanController.m */,
34B3F8471E8DF1700035BE1A /* FullImageViewController.h */,
34B3F8481E8DF1700035BE1A /* FullImageViewController.m */,
34B3F8471E8DF1700035BE1A /* MediaDetailViewController.h */,
34B3F8481E8DF1700035BE1A /* MediaDetailViewController.m */,
34BECE2C1F7ABCE000D7438D /* GifPicker */,
34B3F86F1E8DF1700035BE1A /* HomeViewController.h */,
34B3F8701E8DF1700035BE1A /* HomeViewController.m */,
@ -2389,7 +2389,7 @@
45E5A6991F61E6DE001E4A8A /* MarqueeLabel.swift in Sources */,
34D1F0B01F867BFC0066283D /* OWSSystemMessageCell.m in Sources */,
45A663C51F92EC760027B59E /* GroupTableViewCell.swift in Sources */,
34B3F87D1E8DF1700035BE1A /* FullImageViewController.m in Sources */,
34B3F87D1E8DF1700035BE1A /* MediaDetailViewController.m in Sources */,
45666F7B1D9C0533008FE134 /* OWSDatabaseMigration.m in Sources */,
34D1F0861F8678AA0066283D /* ConversationViewController.m in Sources */,
B90418E6183E9DD40038554A /* DateUtil.m in Sources */,

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "AppSettingsViewController.h"
@ -10,7 +10,7 @@
#import "DebugUIPage.h"
#import "Environment.h"
#import "FingerprintViewController.h"
#import "FullImageViewController.h"
#import "MediaDetailViewController.h"
#import "HomeViewController.h"
#import "NSString+OWS.h"
#import "NotificationsManager.h"

View File

@ -19,7 +19,7 @@
#import "DebugUITableViewController.h"
#import "Environment.h"
#import "FingerprintViewController.h"
#import "FullImageViewController.h"
#import "MediaDetailViewController.h"
#import "NSAttributedString+OWS.h"
#import "NSString+OWS.h"
#import "NewGroupViewController.h"
@ -2002,7 +2002,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
UIWindow *window = [UIApplication sharedApplication].keyWindow;
CGRect convertedRect = [imageView convertRect:imageView.bounds toView:window];
FullImageViewController *vc = [[FullImageViewController alloc] initWithAttachmentStream:attachmentStream
MediaDetailViewController *vc = [[MediaDetailViewController alloc] initWithAttachmentStream:attachmentStream
fromRect:convertedRect
viewItem:viewItem];
[vc presentFromViewController:self];
@ -2020,7 +2020,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
UIWindow *window = [UIApplication sharedApplication].keyWindow;
CGRect convertedRect = [imageView convertRect:imageView.bounds toView:window];
FullImageViewController *vc = [[FullImageViewController alloc] initWithAttachmentStream:attachmentStream
MediaDetailViewController *vc = [[MediaDetailViewController alloc] initWithAttachmentStream:attachmentStream
fromRect:convertedRect
viewItem:viewItem];
[vc presentFromViewController:self];

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSViewController.h"
@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
@class SignalAttachment;
@class TSAttachmentStream;
@interface FullImageViewController : OWSViewController
@interface MediaDetailViewController : OWSViewController
// If viewItem is non-null, long press will show a menu controller.
- (instancetype)initWithAttachmentStream:(TSAttachmentStream *)attachmentStream

View File

@ -2,7 +2,7 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "FullImageViewController.h"
#import "MediaDetailViewController.h"
#import "AttachmentSharing.h"
#import "ConversationViewController.h"
#import "ConversationViewItem.h"
@ -44,11 +44,10 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark -
@interface FullImageViewController () <UIScrollViewDelegate, UIGestureRecognizerDelegate, PlayerProgressBarDelegate>
@interface MediaDetailViewController () <UIScrollViewDelegate, UIGestureRecognizerDelegate, PlayerProgressBarDelegate>
@property (nonatomic) UIScrollView *scrollView;
//@property (nonatomic) UIImageView *imageView;
@property (nonatomic) UIView *imageView;
@property (nonatomic) UIView *mediaView;
@property (nonatomic) UIButton *shareButton;
@ -69,14 +68,14 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, nullable) UIBarButtonItem *videoPauseBarButton;
@property (nonatomic, nullable) NSArray<NSLayoutConstraint *> *imageViewConstraints;
@property (nonatomic, nullable) NSLayoutConstraint *imageViewBottomConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *imageViewLeadingConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *imageViewTopConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *imageViewTrailingConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *mediaViewBottomConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *mediaViewLeadingConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *mediaViewTopConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *mediaViewTrailingConstraint;
@end
@implementation FullImageViewController
@implementation MediaDetailViewController
- (instancetype)initWithAttachmentStream:(TSAttachmentStream *)attachmentStream
fromRect:(CGRect)rect
@ -251,32 +250,32 @@ NS_ASSUME_NONNULL_BEGIN
YYImage *animatedGif = [YYImage imageWithData:self.fileData];
YYAnimatedImageView *animatedView = [YYAnimatedImageView new];
animatedView.image = animatedGif;
self.imageView = animatedView;
self.mediaView = animatedView;
} else {
self.imageView = [UIImageView new];
self.mediaView = [UIImageView new];
}
} else if (self.isVideo) {
self.imageView = [self buildVideoPlayerView];
self.mediaView = [self buildVideoPlayerView];
} else {
// Present the static image using standard UIImageView
UIImageView *imageView = [[UIImageView alloc] initWithImage:self.image];
self.imageView = imageView;
self.mediaView = imageView;
}
OWSAssert(self.imageView);
OWSAssert(self.mediaView);
[scrollView addSubview:self.imageView];
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.imageView.userInteractionEnabled = YES;
self.imageView.clipsToBounds = YES;
self.imageView.layer.allowsEdgeAntialiasing = YES;
self.imageView.translatesAutoresizingMaskIntoConstraints = NO;
[scrollView addSubview:self.mediaView];
self.mediaView.contentMode = UIViewContentModeScaleAspectFit;
self.mediaView.userInteractionEnabled = YES;
self.mediaView.clipsToBounds = YES;
self.mediaView.layer.allowsEdgeAntialiasing = YES;
self.mediaView.translatesAutoresizingMaskIntoConstraints = NO;
// Use trilinear filters for better scaling quality at
// some performance cost.
self.imageView.layer.minificationFilter = kCAFilterTrilinear;
self.imageView.layer.magnificationFilter = kCAFilterTrilinear;
self.mediaView.layer.minificationFilter = kCAFilterTrilinear;
self.mediaView.layer.magnificationFilter = kCAFilterTrilinear;
[self applyInitialImageViewConstraints];
@ -373,15 +372,15 @@ NS_ASSUME_NONNULL_BEGIN
}
CGRect convertedRect =
[self.imageView.superview convertRect:self.originRect fromView:[UIApplication sharedApplication].keyWindow];
[self.mediaView.superview convertRect:self.originRect fromView:[UIApplication sharedApplication].keyWindow];
NSMutableArray<NSLayoutConstraint *> *imageViewConstraints = [NSMutableArray new];
self.imageViewConstraints = imageViewConstraints;
[imageViewConstraints addObjectsFromArray:[self.imageView autoSetDimensionsToSize:convertedRect.size]];
[imageViewConstraints addObjectsFromArray:[self.mediaView autoSetDimensionsToSize:convertedRect.size]];
[imageViewConstraints addObjectsFromArray:@[
[self.imageView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:convertedRect.origin.y],
[self.imageView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:convertedRect.origin.x]
[self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:convertedRect.origin.y],
[self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:convertedRect.origin.x]
]];
}
@ -394,16 +393,16 @@ NS_ASSUME_NONNULL_BEGIN
NSMutableArray<NSLayoutConstraint *> *imageViewConstraints = [NSMutableArray new];
self.imageViewConstraints = imageViewConstraints;
self.imageViewLeadingConstraint = [self.imageView autoPinEdgeToSuperviewEdge:ALEdgeLeading];
self.imageViewTopConstraint = [self.imageView autoPinEdgeToSuperviewEdge:ALEdgeTop];
self.imageViewTrailingConstraint = [self.imageView autoPinEdgeToSuperviewEdge:ALEdgeTrailing];
self.imageViewBottomConstraint = [self.imageView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
self.mediaViewLeadingConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeLeading];
self.mediaViewTopConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTop];
self.mediaViewTrailingConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTrailing];
self.mediaViewBottomConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
[imageViewConstraints addObjectsFromArray:@[
self.imageViewTopConstraint,
self.imageViewTrailingConstraint,
self.imageViewBottomConstraint,
self.imageViewLeadingConstraint
self.mediaViewTopConstraint,
self.mediaViewTrailingConstraint,
self.mediaViewBottomConstraint,
self.mediaViewLeadingConstraint
]];
}
@ -710,7 +709,7 @@ NS_ASSUME_NONNULL_BEGIN
// Make sure imageView is layed out before we update it's frame in the next
// animation.
[self.imageView.superview layoutIfNeeded];
[self.mediaView.superview layoutIfNeeded];
// 2. Animate imageView from it's initial position, which should match where it was
// in the presenting view to it's final position, front and center in this view. This
@ -720,13 +719,13 @@ NS_ASSUME_NONNULL_BEGIN
options:UIViewAnimationOptionCurveEaseOut
animations:^(void) {
[self applyFinalImageViewConstraints];
[self.imageView.superview layoutIfNeeded];
[self.mediaView.superview layoutIfNeeded];
// We must lay out *before* we centerImageViewConstraints
// because it uses the imageView.frame to build the contstraints
// that will center the imageView, and then once again
// to ensure that the centered constraints are applied.
[self centerImageViewConstraints];
[self.imageView.superview layoutIfNeeded];
[self.mediaView.superview layoutIfNeeded];
self.view.backgroundColor = UIColor.whiteColor;
}
completion:^(BOOL finished) {
@ -744,9 +743,9 @@ NS_ASSUME_NONNULL_BEGIN
self.view.userInteractionEnabled = NO;
[UIApplication sharedApplication].statusBarHidden = NO;
OWSAssert(self.imageView.superview);
OWSAssert(self.mediaView.superview);
[self.imageView.superview layoutIfNeeded];
[self.mediaView.superview layoutIfNeeded];
// Move the image view pack to it's initial position, i.e. where
// it sits on the screen in the conversation view.
@ -757,7 +756,7 @@ NS_ASSUME_NONNULL_BEGIN
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
[self.imageView.superview layoutIfNeeded];
[self.mediaView.superview layoutIfNeeded];
// In case user has hidden bars, which changes background to black.
self.view.backgroundColor = UIColor.whiteColor;
@ -777,7 +776,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.imageView;
return self.mediaView;
}
- (void)centerImageViewConstraints
@ -785,15 +784,15 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(self.scrollView);
CGSize scrollViewSize = self.scrollView.bounds.size;
CGSize imageViewSize = self.imageView.frame.size;
CGSize imageViewSize = self.mediaView.frame.size;
CGFloat yOffset = MAX(0, (scrollViewSize.height - imageViewSize.height) / 2);
self.imageViewTopConstraint.constant = yOffset;
self.imageViewBottomConstraint.constant = yOffset;
self.mediaViewTopConstraint.constant = yOffset;
self.mediaViewBottomConstraint.constant = yOffset;
CGFloat xOffset = MAX(0, (scrollViewSize.width - imageViewSize.width) / 2);
self.imageViewLeadingConstraint.constant = xOffset;
self.imageViewTrailingConstraint.constant = xOffset;
self.mediaViewLeadingConstraint.constant = xOffset;
self.mediaViewTrailingConstraint.constant = xOffset;
}
- (void)scrollViewDidZoom:(UIScrollView *)scrollView

View File

@ -412,7 +412,7 @@ class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
guard let fromView = sender.view else {
return
}
showFullImageViewController(fromView: fromView)
showMediaDetailViewController(fromView: fromView)
}
private func fromViewController() -> UIViewController? {
@ -437,22 +437,22 @@ class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
guard let fromView = sender.view else {
return
}
showFullImageViewController(fromView: fromView)
showMediaDetailViewController(fromView: fromView)
}
func showFullImageViewController(fromView: UIView) {
func showMediaDetailViewController(fromView: UIView) {
guard let fromViewController = fromViewController() else {
return
}
let window = UIApplication.shared.keyWindow
let convertedRect = fromView.convert(fromView.bounds, to:window)
let viewController: FullImageViewController = {
let viewController: MediaDetailViewController = {
if let viewItem = self.viewItem, let attachmentStream = self.attachmentStream {
return FullImageViewController(attachmentStream: attachmentStream, from: convertedRect, viewItem: viewItem)
return MediaDetailViewController(attachmentStream: attachmentStream, from: convertedRect, viewItem: viewItem)
} else {
// e.g. when MediaMessageView does not belong to a persisted interaction, e.g. approval view.
return FullImageViewController(attachment: attachment, from:convertedRect)
return MediaDetailViewController(attachment: attachment, from:convertedRect)
}
}()