Cleanup before code review

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

@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ConversationViewLayout ()
@property (nonatomic) CGSize mediaSize;
@property (nonatomic) CGSize contentSize;
@property (nonatomic, readonly) NSMutableDictionary<NSNumber *, UICollectionViewLayoutAttributes *> *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

@ -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")

@ -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];

@ -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()

Loading…
Cancel
Save