From 513e33b0fd8fed9cb8ffea5a26636a0952e9ae2e Mon Sep 17 00:00:00 2001 From: sdkjfhsdkjhfsdlkjhfsdf Date: Tue, 19 Dec 2017 21:26:27 -0600 Subject: [PATCH] Cleanup before code review // FREEBIE --- .../ConversationView/ConversationViewLayout.m | 8 ++--- .../AttachmentApprovalViewController.swift | 16 +++------ .../attachments/FullImageViewController.m | 35 +------------------ .../attachments/MediaMessageView.swift | 4 +-- 4 files changed, 11 insertions(+), 52 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m index 7c8d7625d..76398a747 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN @interface ConversationViewLayout () -@property (nonatomic) CGSize mediaSize; +@property (nonatomic) CGSize contentSize; @property (nonatomic, readonly) NSMutableDictionary *itemAttributesMap; @@ -53,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)clearState { - self.mediaSize = CGSizeZero; + self.contentSize = CGSizeZero; [self.itemAttributesMap removeAllObjects]; self.hasLayout = NO; } @@ -137,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN } contentBottom += vInset; - self.mediaSize = CGSizeMake(viewWidth, contentBottom); + self.contentSize = CGSizeMake(viewWidth, contentBottom); } - (nullable NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect @@ -158,7 +158,7 @@ NS_ASSUME_NONNULL_BEGIN - (CGSize)collectionViewContentSize { - return self.mediaSize; + return self.contentSize; } - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds diff --git a/SignalMessaging/attachments/AttachmentApprovalViewController.swift b/SignalMessaging/attachments/AttachmentApprovalViewController.swift index 72d8ab587..7350c4df7 100644 --- a/SignalMessaging/attachments/AttachmentApprovalViewController.swift +++ b/SignalMessaging/attachments/AttachmentApprovalViewController.swift @@ -215,11 +215,9 @@ public class AttachmentApprovalViewController: OWSViewController, MessagingToolb self.sendAttachment(captionText: captionText) } - func messagingToolbar(_ messagingToolbar: MessagingToolbar, didChangeHeight newHeight: CGFloat) { - self.scrollView.contentInset.bottom = newHeight - } + // MARK: Helpers - func sendAttachment(captionText: String?) { + private func sendAttachment(captionText: String?) { // disable controls after send was tapped. self.bottomToolbar.isUserInteractionEnabled = false @@ -327,7 +325,6 @@ private class GradientView: UIView { protocol MessagingToolbarDelegate: class { func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar, captionText: String?) - func messagingToolbar(_ messagingToolbar: MessagingToolbar, didChangeHeight newHeight: CGFloat) } class MessagingToolbar: UIView, UITextViewDelegate { @@ -342,14 +339,9 @@ class MessagingToolbar: UIView, UITextViewDelegate { // Otherwise we risk obscuring too much of the content. return UIDevice.current.orientation.isPortrait ? 160 : 100 } - let kMinTextViewHeight: CGFloat = 38 - var textViewHeight: CGFloat { - didSet { - // TODO magic numbers - self.messagingToolbarDelegate?.messagingToolbar(self, didChangeHeight: textViewHeight + 2 * 4) - } - } + let kMinTextViewHeight: CGFloat = 38 + var textViewHeight: CGFloat required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") diff --git a/SignalMessaging/attachments/FullImageViewController.m b/SignalMessaging/attachments/FullImageViewController.m index b6e251db9..36b07118e 100644 --- a/SignalMessaging/attachments/FullImageViewController.m +++ b/SignalMessaging/attachments/FullImageViewController.m @@ -311,30 +311,7 @@ NS_ASSUME_NONNULL_BEGIN } } -- (void)longPressTextGesture:(UIGestureRecognizer *)sender -{ - // We "eagerly" respond when the long press begins, not when it ends. - if (sender.state == UIGestureRecognizerStateBegan) { - if (!self.viewItem) { - return; - } - - [self.view becomeFirstResponder]; - - if ([UIMenuController sharedMenuController].isMenuVisible) { - [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO]; - } - - NSArray *menuItems = self.viewItem.textMenuControllerItems; - [UIMenuController sharedMenuController].menuItems = menuItems; - CGPoint location = [sender locationInView:self.view]; - CGRect targetRect = CGRectMake(location.x, location.y, 1, 1); - [[UIMenuController sharedMenuController] setTargetRect:targetRect inView:self.view]; - [[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES]; - } -} - -- (void)longPressMediaGesture:(UIGestureRecognizer *)sender +- (void)longPressGesture:(UIGestureRecognizer *)sender { // We "eagerly" respond when the long press begins, not when it ends. if (sender.state == UIGestureRecognizerStateBegan) { @@ -365,21 +342,11 @@ NS_ASSUME_NONNULL_BEGIN return [self.viewItem canPerformAction:action]; } -- (void)copyTextAction:(nullable id)sender -{ - [self.viewItem copyTextAction]; -} - - (void)copyMediaAction:(nullable id)sender { [self.viewItem copyMediaAction]; } -- (void)shareTextAction:(nullable id)sender -{ - [self.viewItem shareTextAction]; -} - - (void)shareMediaAction:(nullable id)sender { [self.viewItem shareMediaAction]; diff --git a/SignalMessaging/attachments/MediaMessageView.swift b/SignalMessaging/attachments/MediaMessageView.swift index 451978ee9..62dd4377c 100644 --- a/SignalMessaging/attachments/MediaMessageView.swift +++ b/SignalMessaging/attachments/MediaMessageView.swift @@ -173,7 +173,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { self.addSubview(stackView) fileNameLabel?.autoPinWidthToSuperview(withMargin: 32) - // We want to center the stackView in it's superview while ensuring + // We want to center the stackView in it's superview while also ensuring // it's superview is big enough to contain it. stackView.autoPinWidthToSuperview() stackView.autoVCenterInSuperview() @@ -295,7 +295,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { self.addSubview(stackView) fileNameLabel?.autoPinWidthToSuperview(withMargin: 32) - // We want to center the stackView in it's superview while ensuring + // We want to center the stackView in it's superview while also ensuring // it's superview is big enough to contain it. stackView.autoPinWidthToSuperview() stackView.autoVCenterInSuperview()