Rework attachment approval UI.

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

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

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

@ -6,8 +6,7 @@ import Foundation
@objc
protocol GifPickerViewControllerDelegate: class {
func gifPickerWillSend()
func gifPickerDidSend(outgoingMessage: TSOutgoingMessage)
func gifPickerDidSelect(attachment: SignalAttachment)
}
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)
strongSelf.delegate?.gifPickerWillSend()
let outgoingMessage = ThreadUtil.sendMessage(with: attachment, in: strongSelf.thread, messageSender: strongSelf.messageSender)
strongSelf.delegate?.gifPickerDidSend(outgoingMessage: outgoingMessage)
strongSelf.delegate?.gifPickerDidSelect(attachment: attachment)
strongSelf.dismiss(animated: true, completion: nil)
}.catch { [weak self] error in

Loading…
Cancel
Save