rename: imageView -> mediaView

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 8851413b35
commit 7c2bfdfb1f

@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, nullable) UIBarButtonItem *videoPlayBarButton; @property (nonatomic, nullable) UIBarButtonItem *videoPlayBarButton;
@property (nonatomic, nullable) UIBarButtonItem *videoPauseBarButton; @property (nonatomic, nullable) UIBarButtonItem *videoPauseBarButton;
@property (nonatomic, nullable) NSArray<NSLayoutConstraint *> *imageViewConstraints; @property (nonatomic, nullable) NSArray<NSLayoutConstraint *> *mediaViewConstraints;
@property (nonatomic, nullable) NSLayoutConstraint *mediaViewBottomConstraint; @property (nonatomic, nullable) NSLayoutConstraint *mediaViewBottomConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *mediaViewLeadingConstraint; @property (nonatomic, nullable) NSLayoutConstraint *mediaViewLeadingConstraint;
@property (nonatomic, nullable) NSLayoutConstraint *mediaViewTopConstraint; @property (nonatomic, nullable) NSLayoutConstraint *mediaViewTopConstraint;
@ -361,18 +361,18 @@ NS_ASSUME_NONNULL_BEGIN
- (void)applyInitialMediaViewConstraints - (void)applyInitialMediaViewConstraints
{ {
if (self.imageViewConstraints.count > 0) { if (self.mediaViewConstraints.count > 0) {
[NSLayoutConstraint deactivateConstraints:self.imageViewConstraints]; [NSLayoutConstraint deactivateConstraints:self.mediaViewConstraints];
} }
CGRect convertedRect = CGRect convertedRect =
[self.mediaView.superview convertRect:self.originRect fromView:[UIApplication sharedApplication].keyWindow]; [self.mediaView.superview convertRect:self.originRect fromView:[UIApplication sharedApplication].keyWindow];
NSMutableArray<NSLayoutConstraint *> *imageViewConstraints = [NSMutableArray new]; NSMutableArray<NSLayoutConstraint *> *mediaViewConstraints = [NSMutableArray new];
self.imageViewConstraints = imageViewConstraints; self.mediaViewConstraints = mediaViewConstraints;
[imageViewConstraints addObjectsFromArray:[self.mediaView autoSetDimensionsToSize:convertedRect.size]]; [mediaViewConstraints addObjectsFromArray:[self.mediaView autoSetDimensionsToSize:convertedRect.size]];
[imageViewConstraints addObjectsFromArray:@[ [mediaViewConstraints addObjectsFromArray:@[
[self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:convertedRect.origin.y], [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:convertedRect.origin.y],
[self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:convertedRect.origin.x] [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:convertedRect.origin.x]
]]; ]];
@ -380,19 +380,19 @@ NS_ASSUME_NONNULL_BEGIN
- (void)applyFinalMediaViewConstraints - (void)applyFinalMediaViewConstraints
{ {
if (self.imageViewConstraints.count > 0) { if (self.mediaViewConstraints.count > 0) {
[NSLayoutConstraint deactivateConstraints:self.imageViewConstraints]; [NSLayoutConstraint deactivateConstraints:self.mediaViewConstraints];
} }
NSMutableArray<NSLayoutConstraint *> *imageViewConstraints = [NSMutableArray new]; NSMutableArray<NSLayoutConstraint *> *mediaViewConstraints = [NSMutableArray new];
self.imageViewConstraints = imageViewConstraints; self.mediaViewConstraints = mediaViewConstraints;
self.mediaViewLeadingConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeLeading]; self.mediaViewLeadingConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeLeading];
self.mediaViewTopConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTop]; self.mediaViewTopConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTop];
self.mediaViewTrailingConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTrailing]; self.mediaViewTrailingConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeTrailing];
self.mediaViewBottomConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeBottom]; self.mediaViewBottomConstraint = [self.mediaView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
[imageViewConstraints addObjectsFromArray:@[ [mediaViewConstraints addObjectsFromArray:@[
self.mediaViewTopConstraint, self.mediaViewTopConstraint,
self.mediaViewTrailingConstraint, self.mediaViewTrailingConstraint,
self.mediaViewBottomConstraint, self.mediaViewBottomConstraint,
@ -742,11 +742,12 @@ NS_ASSUME_NONNULL_BEGIN
self.mediaView.layer.cornerRadius = 0; self.mediaView.layer.cornerRadius = 0;
[self updateMinZoomScale]; [self updateMinZoomScale];
[self.mediaView.superview layoutIfNeeded]; [self.mediaView.superview layoutIfNeeded];
// We must lay out once *before* we centerImageViewConstraints
// We must lay out once *before* we centerMediaViewConstraints
// because it uses the imageView.frame to build the constraints // because it uses the imageView.frame to build the constraints
// that will center the imageView, and then once again *after* // that will center the imageView, and then once again *after*
// to ensure that the centered constraints are applied. // to ensure that the centered constraints are applied.
[self centerImageViewConstraints]; [self centerMediaViewConstraints];
[self.mediaView.superview layoutIfNeeded]; [self.mediaView.superview layoutIfNeeded];
self.view.backgroundColor = UIColor.whiteColor; self.view.backgroundColor = UIColor.whiteColor;
} }
@ -806,7 +807,7 @@ NS_ASSUME_NONNULL_BEGIN
return self.mediaView; return self.mediaView;
} }
- (void)centerImageViewConstraints - (void)centerMediaViewConstraints
{ {
OWSAssert(self.scrollView); OWSAssert(self.scrollView);
@ -824,7 +825,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)scrollViewDidZoom:(UIScrollView *)scrollView - (void)scrollViewDidZoom:(UIScrollView *)scrollView
{ {
[self centerImageViewConstraints]; [self centerMediaViewConstraints];
[self.view layoutIfNeeded]; [self.view layoutIfNeeded];
} }

Loading…
Cancel
Save