Cleanup before code review

// FREEBIE
pull/1/head
sdkjfhsdkjhfsdlkjhfsdf 8 years ago
parent cf091758a5
commit 513e33b0fd

@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ConversationViewLayout () @interface ConversationViewLayout ()
@property (nonatomic) CGSize mediaSize; @property (nonatomic) CGSize contentSize;
@property (nonatomic, readonly) NSMutableDictionary<NSNumber *, UICollectionViewLayoutAttributes *> *itemAttributesMap; @property (nonatomic, readonly) NSMutableDictionary<NSNumber *, UICollectionViewLayoutAttributes *> *itemAttributesMap;
@ -53,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)clearState - (void)clearState
{ {
self.mediaSize = CGSizeZero; self.contentSize = CGSizeZero;
[self.itemAttributesMap removeAllObjects]; [self.itemAttributesMap removeAllObjects];
self.hasLayout = NO; self.hasLayout = NO;
} }
@ -137,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
contentBottom += vInset; contentBottom += vInset;
self.mediaSize = CGSizeMake(viewWidth, contentBottom); self.contentSize = CGSizeMake(viewWidth, contentBottom);
} }
- (nullable NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect - (nullable NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect
@ -158,7 +158,7 @@ NS_ASSUME_NONNULL_BEGIN
- (CGSize)collectionViewContentSize - (CGSize)collectionViewContentSize
{ {
return self.mediaSize; return self.contentSize;
} }
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds

@ -215,11 +215,9 @@ public class AttachmentApprovalViewController: OWSViewController, MessagingToolb
self.sendAttachment(captionText: captionText) self.sendAttachment(captionText: captionText)
} }
func messagingToolbar(_ messagingToolbar: MessagingToolbar, didChangeHeight newHeight: CGFloat) { // MARK: Helpers
self.scrollView.contentInset.bottom = newHeight
}
func sendAttachment(captionText: String?) { private func sendAttachment(captionText: String?) {
// disable controls after send was tapped. // disable controls after send was tapped.
self.bottomToolbar.isUserInteractionEnabled = false self.bottomToolbar.isUserInteractionEnabled = false
@ -327,7 +325,6 @@ private class GradientView: UIView {
protocol MessagingToolbarDelegate: class { protocol MessagingToolbarDelegate: class {
func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar, captionText: String?) func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar, captionText: String?)
func messagingToolbar(_ messagingToolbar: MessagingToolbar, didChangeHeight newHeight: CGFloat)
} }
class MessagingToolbar: UIView, UITextViewDelegate { class MessagingToolbar: UIView, UITextViewDelegate {
@ -342,14 +339,9 @@ class MessagingToolbar: UIView, UITextViewDelegate {
// Otherwise we risk obscuring too much of the content. // Otherwise we risk obscuring too much of the content.
return UIDevice.current.orientation.isPortrait ? 160 : 100 return UIDevice.current.orientation.isPortrait ? 160 : 100
} }
let kMinTextViewHeight: CGFloat = 38
var textViewHeight: CGFloat { let kMinTextViewHeight: CGFloat = 38
didSet { var textViewHeight: CGFloat
// TODO magic numbers
self.messagingToolbarDelegate?.messagingToolbar(self, didChangeHeight: textViewHeight + 2 * 4)
}
}
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")

@ -311,30 +311,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
- (void)longPressTextGesture:(UIGestureRecognizer *)sender - (void)longPressGesture:(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
{ {
// We "eagerly" respond when the long press begins, not when it ends. // We "eagerly" respond when the long press begins, not when it ends.
if (sender.state == UIGestureRecognizerStateBegan) { if (sender.state == UIGestureRecognizerStateBegan) {
@ -365,21 +342,11 @@ NS_ASSUME_NONNULL_BEGIN
return [self.viewItem canPerformAction:action]; return [self.viewItem canPerformAction:action];
} }
- (void)copyTextAction:(nullable id)sender
{
[self.viewItem copyTextAction];
}
- (void)copyMediaAction:(nullable id)sender - (void)copyMediaAction:(nullable id)sender
{ {
[self.viewItem copyMediaAction]; [self.viewItem copyMediaAction];
} }
- (void)shareTextAction:(nullable id)sender
{
[self.viewItem shareTextAction];
}
- (void)shareMediaAction:(nullable id)sender - (void)shareMediaAction:(nullable id)sender
{ {
[self.viewItem shareMediaAction]; [self.viewItem shareMediaAction];

@ -173,7 +173,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
self.addSubview(stackView) self.addSubview(stackView)
fileNameLabel?.autoPinWidthToSuperview(withMargin: 32) 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. // it's superview is big enough to contain it.
stackView.autoPinWidthToSuperview() stackView.autoPinWidthToSuperview()
stackView.autoVCenterInSuperview() stackView.autoVCenterInSuperview()
@ -295,7 +295,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
self.addSubview(stackView) self.addSubview(stackView)
fileNameLabel?.autoPinWidthToSuperview(withMargin: 32) 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. // it's superview is big enough to contain it.
stackView.autoPinWidthToSuperview() stackView.autoPinWidthToSuperview()
stackView.autoVCenterInSuperview() stackView.autoVCenterInSuperview()

Loading…
Cancel
Save