From 520dad25bb1b511523a1cc1fd158641c2fc6f6c4 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 9 Apr 2018 17:48:31 -0400 Subject: [PATCH] WIP making OWSQuotedMessageView work with preview // FREEBIE --- .../ConversationView/Cells/OWSQuotedMessageView.m | 15 ++++++++++----- Signal/src/views/QuotedReplyPreview.swift | 4 ++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index fb7a3d02c..cdfc5437c 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, nullable, readonly) DisplayableText *displayableQuotedText; @property (nonatomic, nullable) OWSBubbleStrokeView *boundsStrokeView; +@property (nonatomic, readonly) BOOL isForPreview; @end @@ -35,8 +36,9 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssert(quotedMessage); - return - [[OWSQuotedMessageView alloc] initWithQuotedMessage:quotedMessage displayableQuotedText:displayableQuotedText]; + return [[OWSQuotedMessageView alloc] initWithQuotedMessage:quotedMessage + displayableQuotedText:displayableQuotedText + isForPreview:NO]; } + (OWSQuotedMessageView *)quotedMessageViewForPreview:(OWSQuotedReplyModel *)quotedMessage @@ -48,12 +50,14 @@ NS_ASSUME_NONNULL_BEGIN displayableQuotedText = [DisplayableText displayableText:quotedMessage.body]; } - return - [[OWSQuotedMessageView alloc] initWithQuotedMessage:quotedMessage displayableQuotedText:displayableQuotedText]; + return [[OWSQuotedMessageView alloc] initWithQuotedMessage:quotedMessage + displayableQuotedText:displayableQuotedText + isForPreview:YES]; } - (instancetype)initWithQuotedMessage:(OWSQuotedReplyModel *)quotedMessage displayableQuotedText:(nullable DisplayableText *)displayableQuotedText + isForPreview:(BOOL)isForPreview { self = [super init]; @@ -65,6 +69,7 @@ NS_ASSUME_NONNULL_BEGIN _quotedMessage = quotedMessage; _displayableQuotedText = displayableQuotedText; + _isForPreview = isForPreview; [self createContents]; @@ -260,7 +265,7 @@ NS_ASSUME_NONNULL_BEGIN } UILabel *quotedTextLabel = [UILabel new]; - quotedTextLabel.numberOfLines = 3; + quotedTextLabel.numberOfLines = self.isForPreview ? 1 : 3; quotedTextLabel.lineBreakMode = NSLineBreakByWordWrapping; quotedTextLabel.text = text; quotedTextLabel.textColor = textColor; diff --git a/Signal/src/views/QuotedReplyPreview.swift b/Signal/src/views/QuotedReplyPreview.swift index 0dfa1f328..02ce456ca 100644 --- a/Signal/src/views/QuotedReplyPreview.swift +++ b/Signal/src/views/QuotedReplyPreview.swift @@ -21,6 +21,7 @@ class QuotedReplyPreview: UIView { super.init(frame: .zero) let quotedMessageView = OWSQuotedMessageView(forPreview: quotedReply) + quotedMessageView.backgroundColor = .clear let isQuotingSelf = quotedReply.authorId == TSAccountManager.localNumber() @@ -116,6 +117,9 @@ class QuotedReplyPreview: UIView { cancelButton.autoPinEdge(.leading, to: .trailing, of: quotedMessageView) cancelButton.autoSetDimensions(to: CGSize(width: 40, height: 40)) + + // TODO this is arbitrary and breaks with dynamic type + self.autoSetDimension(.height, toSize: 70) } // MARK: UIViewOverrides