Rework attachment approval UI.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent d04f9111db
commit cbb0030b12

@ -730,18 +730,21 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex
[cancelButtonWrapper [cancelButtonWrapper
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(cancelButtonWrapperTapped:)]]; action:@selector(cancelButtonWrapperTapped:)]];
UIView *_Nullable cancelButtonSuperview = [self.attachmentView contentView]; UIView *_Nullable attachmentContentView = [self.attachmentView contentView];
if (cancelButtonSuperview) { // Place the cancel button inside the attachment view's content area,
cancelButtonSuperview.layer.borderColor = self.inputTextView.layer.borderColor; // if possible. If not, just place it inside the attachment view.
cancelButtonSuperview.layer.borderWidth = self.inputTextView.layer.borderWidth; UIView *cancelButtonReferenceView = attachmentContentView;
cancelButtonSuperview.layer.cornerRadius = self.inputTextView.layer.cornerRadius; if (attachmentContentView) {
cancelButtonSuperview.clipsToBounds = YES; attachmentContentView.layer.borderColor = self.inputTextView.layer.borderColor;
attachmentContentView.layer.borderWidth = self.inputTextView.layer.borderWidth;
attachmentContentView.layer.cornerRadius = self.inputTextView.layer.cornerRadius;
attachmentContentView.clipsToBounds = YES;
} else { } else {
cancelButtonSuperview = self.attachmentView; cancelButtonReferenceView = self.attachmentView;
} }
[cancelButtonSuperview addSubview:cancelButtonWrapper]; [self.contentView addSubview:cancelButtonWrapper];
[cancelButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeTop]; [cancelButtonWrapper autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:cancelButtonReferenceView];
[cancelButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeRight]; [cancelButtonWrapper autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:cancelButtonReferenceView];
UIImage *cancelIcon = [UIImage imageNamed:@"cancel-cross-white"]; UIImage *cancelIcon = [UIImage imageNamed:@"cancel-cross-white"];
OWSAssert(cancelIcon); OWSAssert(cancelIcon);

@ -2318,15 +2318,13 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
#pragma mark GifPickerViewControllerDelegate #pragma mark GifPickerViewControllerDelegate
- (void)gifPickerWillSend - (void)gifPickerDidSelectWithAttachment:(SignalAttachment *)attachment
{ {
[ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; OWSAssert(attachment);
}
- (void)gifPickerDidSendWithOutgoingMessage:(TSOutgoingMessage *)message [self tryToSendAttachmentIfApproved:attachment];
{
[self messageWasSent:message];
[ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
[self ensureDynamicInteractions]; [self ensureDynamicInteractions];
} }

@ -6,8 +6,7 @@ import Foundation
@objc @objc
protocol GifPickerViewControllerDelegate: class { protocol GifPickerViewControllerDelegate: class {
func gifPickerWillSend() func gifPickerDidSelect(attachment: SignalAttachment)
func gifPickerDidSend(outgoingMessage: TSOutgoingMessage)
} }
class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollectionViewDataSource, UICollectionViewDelegate, GifPickerLayoutDelegate { class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollectionViewDataSource, UICollectionViewDelegate, GifPickerLayoutDelegate {
@ -359,11 +358,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
} }
let attachment = SignalAttachment(dataSource: dataSource, dataUTI: asset.rendition.utiType) let attachment = SignalAttachment(dataSource: dataSource, dataUTI: asset.rendition.utiType)
strongSelf.delegate?.gifPickerWillSend() strongSelf.delegate?.gifPickerDidSelect(attachment: attachment)
let outgoingMessage = ThreadUtil.sendMessage(with: attachment, in: strongSelf.thread, messageSender: strongSelf.messageSender)
strongSelf.delegate?.gifPickerDidSend(outgoingMessage: outgoingMessage)
strongSelf.dismiss(animated: true, completion: nil) strongSelf.dismiss(animated: true, completion: nil)
}.catch { [weak self] error in }.catch { [weak self] error in

Loading…
Cancel
Save