Update appearance of draft quoted replies.

This commit is contained in:
Matthew Chen 2019-01-28 15:51:54 -05:00
parent 25fd43d646
commit 2b71c433ac
7 changed files with 111 additions and 59 deletions

View File

@ -297,6 +297,7 @@
34EA69402194933900702471 /* MediaDownloadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34EA693F2194933900702471 /* MediaDownloadView.swift */; };
34EA69422194DE8000702471 /* MediaUploadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34EA69412194DE7F00702471 /* MediaUploadView.swift */; };
34F308A21ECB469700BB7697 /* OWSBezierPathView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34F308A11ECB469700BB7697 /* OWSBezierPathView.m */; };
34FDB29221FF986600A01202 /* UIView+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34FDB29121FF986600A01202 /* UIView+OWS.swift */; };
4503F1BE20470A5B00CEE724 /* classic-quiet.aifc in Resources */ = {isa = PBXBuildFile; fileRef = 4503F1BB20470A5B00CEE724 /* classic-quiet.aifc */; };
4503F1BF20470A5B00CEE724 /* classic.aifc in Resources */ = {isa = PBXBuildFile; fileRef = 4503F1BC20470A5B00CEE724 /* classic.aifc */; };
4503F1C3204711D300CEE724 /* OWS107LegacySounds.m in Sources */ = {isa = PBXBuildFile; fileRef = 4503F1C1204711D200CEE724 /* OWS107LegacySounds.m */; };
@ -1012,6 +1013,7 @@
34EA69412194DE7F00702471 /* MediaUploadView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaUploadView.swift; sourceTree = "<group>"; };
34F308A01ECB469700BB7697 /* OWSBezierPathView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSBezierPathView.h; sourceTree = "<group>"; };
34F308A11ECB469700BB7697 /* OWSBezierPathView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSBezierPathView.m; sourceTree = "<group>"; };
34FDB29121FF986600A01202 /* UIView+OWS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+OWS.swift"; sourceTree = "<group>"; };
435EAC2E5E22D3F087EB3192 /* Pods-SignalShareExtension.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalShareExtension.app store release.xcconfig"; path = "Pods/Target Support Files/Pods-SignalShareExtension/Pods-SignalShareExtension.app store release.xcconfig"; sourceTree = "<group>"; };
4503F1BB20470A5B00CEE724 /* classic-quiet.aifc */ = {isa = PBXFileReference; lastKnownFileType = file; path = "classic-quiet.aifc"; sourceTree = "<group>"; };
4503F1BC20470A5B00CEE724 /* classic.aifc */ = {isa = PBXFileReference; lastKnownFileType = file; path = classic.aifc; sourceTree = "<group>"; };
@ -1596,6 +1598,7 @@
34480B651FD0AA9400BC14EF /* UIFont+OWS.m */,
34480B5F1FD0A98800BC14EF /* UIView+OWS.h */,
34480B601FD0A98800BC14EF /* UIView+OWS.m */,
34FDB29121FF986600A01202 /* UIView+OWS.swift */,
346129D41FD20ADC00532771 /* UIViewController+OWS.h */,
346129D31FD20ADB00532771 /* UIViewController+OWS.m */,
);
@ -3374,6 +3377,7 @@
34BEDB0B21C2FA3D007B0EAE /* OWS114RemoveDynamicInteractions.swift in Sources */,
34AC0A1A211B39EA00997B47 /* CommonStrings.swift in Sources */,
34AC0A19211B39EA00997B47 /* OWSAlerts.swift in Sources */,
34FDB29221FF986600A01202 /* UIView+OWS.swift in Sources */,
451F8A351FD710DE005CB9DA /* Searcher.swift in Sources */,
451F8A481FD715BA005CB9DA /* OWSContactAvatarBuilder.m in Sources */,
4503F1C3204711D300CEE724 /* OWS107LegacySounds.m in Sources */,

View File

@ -1509,6 +1509,11 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
failedThumbnailDownloadAttachmentPointer:attachmentPointer];
}
- (void)didCancelQuotedReply
{
OWSFailDebug(@"Sent quoted replies should not be cancellable.");
}
#pragma mark - OWSContactShareButtonsViewDelegate
- (void)didTapSendMessageToContactShare:(ContactShareViewModel *)contactShare

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "OWSBubbleView.h"
@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didTapQuotedReply:(OWSQuotedReplyModel *)quotedReply
failedThumbnailDownloadAttachmentPointer:(TSAttachmentPointer *)attachmentPointer;
- (void)didCancelQuotedReply;
@end
@interface OWSQuotedMessageView : UIView

View File

@ -66,13 +66,13 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
displayableQuotedText = [DisplayableText displayableText:quotedMessage.body];
}
OWSQuotedMessageView *instance =
[[OWSQuotedMessageView alloc] initWithQuotedMessage:quotedMessage
displayableQuotedText:displayableQuotedText
conversationStyle:conversationStyle
isForPreview:YES
isOutgoing:YES
sharpCorners:OWSDirectionalRectCornerAllCorners];
OWSQuotedMessageView *instance = [[OWSQuotedMessageView alloc]
initWithQuotedMessage:quotedMessage
displayableQuotedText:displayableQuotedText
conversationStyle:conversationStyle
isForPreview:YES
isOutgoing:YES
sharpCorners:(OWSDirectionalRectCornerBottomLeading | OWSDirectionalRectCornerBottomTrailing)];
[instance createContents];
return instance;
}
@ -235,8 +235,9 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
UILabel *quotedTextLabel = [self configureQuotedTextLabel];
[vStackView addArrangedSubview:quotedTextLabel];
[quotedTextLabel setContentHuggingLow];
[quotedTextLabel setCompressionResistanceLow];
[quotedTextLabel setContentHuggingHorizontalLow];
[quotedTextLabel setCompressionResistanceHorizontalLow];
[quotedTextLabel setCompressionResistanceVerticalHigh];
if (self.hasQuotedAttachment) {
UIView *_Nullable quotedAttachmentView = nil;
@ -299,15 +300,57 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
[emptyView autoSetDimension:ALDimensionWidth toSize:0.f];
}
UIStackView *quoteSourceWrapper = [[UIStackView alloc] initWithArrangedSubviews:@[ hStackView ]];
quoteSourceWrapper.axis = UILayoutConstraintAxisVertical;
UIView *contentView = hStackView;
[contentView setContentHuggingHorizontalLow];
[contentView setCompressionResistanceHorizontalLow];
if (self.quotedMessage.isRemotelySourced) {
[quoteSourceWrapper addArrangedSubview:[self buildRemoteContentSourceView]];
UIStackView *quoteSourceWrapper = [[UIStackView alloc] initWithArrangedSubviews:@[
contentView,
[self buildRemoteContentSourceView],
]];
quoteSourceWrapper.axis = UILayoutConstraintAxisVertical;
contentView = quoteSourceWrapper;
[contentView setContentHuggingHorizontalLow];
[contentView setCompressionResistanceHorizontalLow];
}
[innerBubbleView addSubview:quoteSourceWrapper];
[quoteSourceWrapper ows_autoPinToSuperviewEdges];
if (self.isForPreview) {
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[cancelButton
setImage:[[UIImage imageNamed:@"compose-cancel"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal];
cancelButton.imageView.tintColor = Theme.secondaryColor;
[cancelButton addTarget:self action:@selector(didTapCancel) forControlEvents:UIControlEventTouchUpInside];
[cancelButton setContentHuggingHorizontalHigh];
[cancelButton setCompressionResistanceHorizontalHigh];
UIStackView *cancelStack = [[UIStackView alloc] initWithArrangedSubviews:@[ cancelButton ]];
cancelStack.axis = UILayoutConstraintAxisHorizontal;
cancelStack.alignment = UIStackViewAlignmentTop;
cancelStack.layoutMarginsRelativeArrangement = YES;
CGFloat hMarginLeading = 0;
CGFloat hMarginTrailing = 6;
cancelStack.layoutMargins = UIEdgeInsetsMake(6,
CurrentAppContext().isRTL ? hMarginTrailing : hMarginLeading,
0,
CurrentAppContext().isRTL ? hMarginLeading : hMarginTrailing);
[cancelStack setContentHuggingHorizontalHigh];
[cancelStack setCompressionResistanceHorizontalHigh];
UIStackView *cancelWrapper = [[UIStackView alloc] initWithArrangedSubviews:@[
contentView,
cancelStack,
]];
cancelWrapper.axis = UILayoutConstraintAxisHorizontal;
contentView = cancelWrapper;
[contentView setContentHuggingHorizontalLow];
[contentView setCompressionResistanceHorizontalLow];
}
[innerBubbleView addSubview:contentView];
[contentView ows_autoPinToSuperviewEdges];
}
- (UIView *)buildRemoteContentSourceView
@ -637,6 +680,11 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
return [self sizeForMaxWidth:CGFLOAT_MAX];
}
- (void)didTapCancel
{
[self.delegate didCancelQuotedReply];
}
@end
NS_ASSUME_NONNULL_END

View File

@ -590,9 +590,9 @@ public class LinkPreviewView: UIStackView {
let hMarginLeading: CGFloat = hasImage ? 6 : 12
let hMarginTrailing: CGFloat = 12
self.layoutMargins = UIEdgeInsets(top: draftMarginTop,
left: CurrentAppContext().isRTL ? hMarginTrailing : hMarginLeading,
leading: hMarginLeading,
bottom: 0,
right: CurrentAppContext().isRTL ? hMarginLeading : hMarginTrailing)
trailing: hMarginTrailing)
// Right

View File

@ -10,7 +10,7 @@ protocol QuotedReplyPreviewDelegate: class {
}
@objc
class QuotedReplyPreview: UIStackView {
class QuotedReplyPreview: UIView, OWSQuotedMessageViewDelegate {
@objc
public weak var delegate: QuotedReplyPreviewDelegate?
@ -48,58 +48,27 @@ class QuotedReplyPreview: UIStackView {
func updateContents() {
subviews.forEach { $0.removeFromSuperview() }
let hMargin: CGFloat = 6
self.layoutMargins = UIEdgeInsets(top: draftMarginTop,
left: hMargin,
bottom: 0,
right: hMargin)
// We instantiate quotedMessageView late to ensure that it is updated
// every time contentSizeCategoryDidChange (i.e. when dynamic type
// sizes changes).
let quotedMessageView = OWSQuotedMessageView(forPreview: quotedReply, conversationStyle: conversationStyle)
quotedMessageView.delegate = self
self.quotedMessageView = quotedMessageView
quotedMessageView.setContentHuggingHorizontalLow()
quotedMessageView.setCompressionResistanceHorizontalLow()
quotedMessageView.backgroundColor = .clear
let cancelButton: UIButton = UIButton(type: .custom)
let cancelImage = UIImage(named: "compose-cancel")?.withRenderingMode(.alwaysTemplate)
cancelButton.setImage(cancelImage, for: .normal)
cancelButton.imageView?.tintColor = Theme.secondaryColor
cancelButton.addTarget(self, action: #selector(didTapCancel), for: .touchUpInside)
if let cancelSize = cancelImage?.size {
cancelButton.autoSetDimensions(to: cancelSize)
}
self.axis = .horizontal
self.alignment = .fill
self.distribution = .fill
self.spacing = 8
self.isLayoutMarginsRelativeArrangement = true
let hMarginLeading: CGFloat = 6
let hMarginTrailing: CGFloat = 12
self.layoutMargins = UIEdgeInsets(top: draftMarginTop,
left: CurrentAppContext().isRTL ? hMarginTrailing : hMarginLeading,
bottom: 0,
right: CurrentAppContext().isRTL ? hMarginLeading : hMarginTrailing)
self.addArrangedSubview(quotedMessageView)
let cancelStack = UIStackView()
cancelStack.axis = .horizontal
cancelStack.alignment = .top
cancelStack.setContentHuggingHigh()
cancelStack.setCompressionResistanceHigh()
cancelStack.addArrangedSubview(cancelButton)
self.addArrangedSubview(cancelStack)
self.addSubview(quotedMessageView)
quotedMessageView.ows_autoPinToSuperviewMargins()
updateHeight()
}
// MARK: Actions
@objc
func didTapCancel(_ sender: Any) {
self.delegate?.quotedReplyPreviewDidPressCancel(self)
}
// MARK: Sizing
func updateHeight() {
@ -108,7 +77,7 @@ class QuotedReplyPreview: UIStackView {
return
}
let size = quotedMessageView.size(forMaxWidth: CGFloat.infinity)
self.heightConstraint.constant = size.height
self.heightConstraint.constant = size.height + draftMarginTop
}
@objc func contentSizeCategoryDidChange(_ notification: Notification) {
@ -116,4 +85,14 @@ class QuotedReplyPreview: UIStackView {
updateContents()
}
// MARK: - OWSQuotedMessageViewDelegate
@objc public func didTapQuotedReply(_ quotedReply: OWSQuotedReplyModel, failedThumbnailDownloadAttachmentPointer attachmentPointer: TSAttachmentPointer) {
// Do nothing.
}
@objc public func didCancelQuotedReply() {
self.delegate?.quotedReplyPreviewDidPressCancel(self)
}
}

View File

@ -0,0 +1,14 @@
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
public extension UIEdgeInsets {
public init(top: CGFloat, leading: CGFloat, bottom: CGFloat, trailing: CGFloat) {
self.init(top: top,
left: CurrentAppContext().isRTL ? trailing : leading,
bottom: bottom,
right: CurrentAppContext().isRTL ? leading : trailing)
}
}