Convert to swift

// FREEBIE
This commit is contained in:
Michael Kirk 2018-04-03 21:59:19 -04:00
parent cfbbeca7ac
commit 6874a9e28e
10 changed files with 167 additions and 168 deletions

View File

@ -113,7 +113,6 @@
346129C91FD2072E00532771 /* NSString+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129C21FD2072D00532771 /* NSString+OWS.m */; };
346129CB1FD2072E00532771 /* Promise+retainUntilComplete.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129C41FD2072D00532771 /* Promise+retainUntilComplete.swift */; };
346129CC1FD2072E00532771 /* NSAttributedString+OWS.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129C51FD2072D00532771 /* NSAttributedString+OWS.h */; settings = {ATTRIBUTES = (Public, ); }; };
346129CD1FD2072E00532771 /* UIImage+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129C61FD2072D00532771 /* UIImage+OWS.m */; };
346129D01FD207F300532771 /* OWSAlerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129CF1FD207F200532771 /* OWSAlerts.swift */; };
346129D21FD2085A00532771 /* CommonStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129D11FD2085A00532771 /* CommonStrings.swift */; };
346129D51FD20ADC00532771 /* UIViewController+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129D31FD20ADB00532771 /* UIViewController+OWS.m */; };
@ -202,9 +201,9 @@
34D1F0BA1F8800D90066283D /* OWSAudioMessageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0B91F8800D90066283D /* OWSAudioMessageView.m */; };
34D1F0BD1F8D108C0066283D /* AttachmentUploadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0BC1F8D108C0066283D /* AttachmentUploadView.m */; };
34D1F0C01F8EC1760066283D /* MessageRecipientStatusUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0BF1F8EC1760066283D /* MessageRecipientStatusUtils.swift */; };
34D2CCD220618B3000CB1A14 /* OWSBackupLazyRestoreJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D2CCD120618B2F00CB1A14 /* OWSBackupLazyRestoreJob.swift */; };
34D2CCD4206294B900CB1A14 /* OWSScreenLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D2CCD3206294B900CB1A14 /* OWSScreenLock.swift */; };
34D2CCDA2062E7D000CB1A14 /* OWSScreenLockUI.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D2CCD92062E7D000CB1A14 /* OWSScreenLockUI.m */; };
34D2CCD220618B3000CB1A14 /* OWSBackupLazyRestoreJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D2CCD120618B2F00CB1A14 /* OWSBackupLazyRestoreJob.swift */; };
34D2CCDF206939B400CB1A14 /* DebugUIMessagesAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D2CCDB206939B100CB1A14 /* DebugUIMessagesAction.m */; };
34D2CCE0206939B400CB1A14 /* DebugUIMessagesAssetLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D2CCDC206939B200CB1A14 /* DebugUIMessagesAssetLoader.m */; };
34D5CCA91EAE3D30005515DB /* AvatarViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCA81EAE3D30005515DB /* AvatarViewHelper.m */; };
@ -314,6 +313,7 @@
4579431E1E7C8CE9008ED0C0 /* Pastelog.m in Sources */ = {isa = PBXBuildFile; fileRef = 4579431D1E7C8CE9008ED0C0 /* Pastelog.m */; };
45794E861E00620000066731 /* CallUIAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45794E851E00620000066731 /* CallUIAdapter.swift */; };
457C87B82032645C008D52D6 /* DebugUINotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 457C87B72032645C008D52D6 /* DebugUINotifications.swift */; };
457F671B20746193000EABCD /* QuotedReplyPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 457F671A20746193000EABCD /* QuotedReplyPreview.swift */; };
45847E871E4283C30080EAB3 /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 45847E861E4283C30080EAB3 /* Intents.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
4585C4681ED8F8D200896AEA /* SafetyNumberConfirmationAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4585C4671ED8F8D200896AEA /* SafetyNumberConfirmationAlert.swift */; };
458967111DC117CC00E9DD21 /* AccountManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 458967101DC117CC00E9DD21 /* AccountManagerTest.swift */; };
@ -812,10 +812,10 @@
34D1F0BB1F8D108C0066283D /* AttachmentUploadView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttachmentUploadView.h; sourceTree = "<group>"; };
34D1F0BC1F8D108C0066283D /* AttachmentUploadView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AttachmentUploadView.m; sourceTree = "<group>"; };
34D1F0BF1F8EC1760066283D /* MessageRecipientStatusUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageRecipientStatusUtils.swift; sourceTree = "<group>"; };
34D2CCD120618B2F00CB1A14 /* OWSBackupLazyRestoreJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSBackupLazyRestoreJob.swift; sourceTree = "<group>"; };
34D2CCD3206294B900CB1A14 /* OWSScreenLock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSScreenLock.swift; sourceTree = "<group>"; };
34D2CCD82062E7D000CB1A14 /* OWSScreenLockUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSScreenLockUI.h; sourceTree = "<group>"; };
34D2CCD92062E7D000CB1A14 /* OWSScreenLockUI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSScreenLockUI.m; sourceTree = "<group>"; };
34D2CCD120618B2F00CB1A14 /* OWSBackupLazyRestoreJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSBackupLazyRestoreJob.swift; sourceTree = "<group>"; };
34D2CCDB206939B100CB1A14 /* DebugUIMessagesAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DebugUIMessagesAction.m; sourceTree = "<group>"; };
34D2CCDC206939B200CB1A14 /* DebugUIMessagesAssetLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DebugUIMessagesAssetLoader.m; sourceTree = "<group>"; };
34D2CCDD206939B200CB1A14 /* DebugUIMessagesAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugUIMessagesAction.h; sourceTree = "<group>"; };
@ -918,6 +918,7 @@
4579431D1E7C8CE9008ED0C0 /* Pastelog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Pastelog.m; sourceTree = "<group>"; };
45794E851E00620000066731 /* CallUIAdapter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CallUIAdapter.swift; path = UserInterface/CallUIAdapter.swift; sourceTree = "<group>"; };
457C87B72032645C008D52D6 /* DebugUINotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugUINotifications.swift; sourceTree = "<group>"; };
457F671A20746193000EABCD /* QuotedReplyPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuotedReplyPreview.swift; sourceTree = "<group>"; };
45847E861E4283C30080EAB3 /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; };
45855F351D9498A40084F340 /* OWSContactAvatarBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactAvatarBuilder.h; sourceTree = "<group>"; };
45855F361D9498A40084F340 /* OWSContactAvatarBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactAvatarBuilder.m; sourceTree = "<group>"; };
@ -2029,6 +2030,7 @@
4523149F1F7E9E18003A428C /* DirectionalPanGestureRecognizer.swift */,
45D308AB2049A439000189E4 /* PinEntryView.h */,
45D308AC2049A439000189E4 /* PinEntryView.m */,
457F671A20746193000EABCD /* QuotedReplyPreview.swift */,
);
name = Views;
path = views;
@ -3252,6 +3254,7 @@
458DE9D61DEE3FD00071BB03 /* PeerConnectionClient.swift in Sources */,
45F32C242057297A00A300D5 /* MessageDetailViewController.swift in Sources */,
34D1F0841F8678AA0066283D /* ConversationInputToolbar.m in Sources */,
457F671B20746193000EABCD /* QuotedReplyPreview.swift in Sources */,
34DBF004206BD5A500025978 /* OWSBubbleView.m in Sources */,
FCC81A981A44558300DFEC7D /* UIDevice+TSHardwareVersion.m in Sources */,
76EB054018170B33006006FC /* AppDelegate.m in Sources */,

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -21,145 +21,11 @@ NS_ASSUME_NONNULL_BEGIN
static void *kConversationInputTextViewObservingContext = &kConversationInputTextViewObservingContext;
static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
@class QuotedMessagePreviewView;
@protocol QuotedMessagePreviewViewDelegate
- (void)quoteMessagePreviewViewDidPressCancel:(QuotedMessagePreviewView *)view;
@end
@interface QuotedMessagePreviewView : UIView
@property (nonatomic, weak) id<QuotedMessagePreviewViewDelegate> delegate;
@end
@implementation QuotedMessagePreviewView
+ (nullable UIView *)iconViewForMessage:(TSQuotedMessage *)message
{
NSString *iconText = [TSAttachmentStream emojiForMimeType:message.contentType];
if (!iconText) {
return nil;
}
UILabel *iconLabel = [UILabel new];
[iconLabel setContentHuggingHigh];
iconLabel.text = iconText;
return iconLabel;
}
- (instancetype)initWithQuotedMessage:(TSQuotedMessage *)message
{
self = [super initWithFrame:CGRectZero];
if (!self) {
return self;
}
BOOL isQuotingSelf = [message.authorId isEqualToString:[TSAccountManager localNumber]];
// used for stripe and author
// FIXME actual colors TBD
UIColor *authorColor = isQuotingSelf ? [UIColor ows_materialBlueColor] : [UIColor blackColor];
// used for text and cancel
UIColor *foregroundColor = UIColor.darkGrayColor;
UILabel *authorLabel = [UILabel new];
authorLabel.textColor = authorColor;
authorLabel.text = [[Environment current].contactsManager displayNameForPhoneIdentifier:message.authorId];
authorLabel.font = UIFont.ows_dynamicTypeHeadlineFont;
UILabel *bodyLabel = [UILabel new];
bodyLabel.textColor = foregroundColor;
bodyLabel.font = UIFont.ows_footnoteFont;
bodyLabel.text = message.body;
UIView *iconView = [self.class iconViewForMessage:message];
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
// FIXME proper image asset/size
UIImage *buttonImage =
[[UIImage imageNamed:@"quoted-message-cancel"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[cancelButton setImage:buttonImage forState:UIControlStateNormal];
cancelButton.imageView.tintColor = foregroundColor;
[cancelButton addTarget:self action:@selector(didTapCancel:) forControlEvents:UIControlEventTouchUpInside];
UIView *quoteStripe = [UIView new];
quoteStripe.backgroundColor = authorColor;
NSArray<__kindof UIView *> *contentViews = iconView ? @[ iconView, bodyLabel ] : @[ bodyLabel ];
UIStackView *contentContainer = [[UIStackView alloc] initWithArrangedSubviews:contentViews];
contentContainer.axis = UILayoutConstraintAxisHorizontal;
contentContainer.spacing = 4.0;
[self addSubview:authorLabel];
[self addSubview:contentContainer];
[self addSubview:cancelButton];
[self addSubview:quoteStripe];
// Layout
CGFloat kCancelButtonMargin = 4;
CGFloat kQuoteStripeWidth = 4;
CGFloat leadingMargin = kQuoteStripeWidth + 8;
CGFloat vMargin = 6;
CGFloat trailingMargin = 8;
self.layoutMargins = UIEdgeInsetsMake(vMargin, leadingMargin, vMargin, trailingMargin);
[quoteStripe autoPinEdgeToSuperviewEdge:ALEdgeLeading];
[quoteStripe autoPinHeightToSuperview];
[quoteStripe autoSetDimension:ALDimensionWidth toSize:kQuoteStripeWidth];
[authorLabel autoPinTopToSuperviewMargin];
[authorLabel autoPinLeadingToSuperviewMargin];
[authorLabel autoPinEdge:ALEdgeTrailing toEdge:ALEdgeLeading ofView:cancelButton withOffset:-kCancelButtonMargin];
[authorLabel setCompressionResistanceHigh];
[contentContainer autoPinLeadingToSuperviewMargin];
[contentContainer autoPinBottomToSuperviewMargin];
[contentContainer autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:authorLabel];
[contentContainer autoPinEdge:ALEdgeTrailing
toEdge:ALEdgeLeading
ofView:cancelButton
withOffset:-kCancelButtonMargin];
[cancelButton autoPinTrailingToSuperviewMargin];
[cancelButton autoVCenterInSuperview];
[cancelButton setContentHuggingHigh];
[cancelButton autoSetDimensionsToSize:CGSizeMake(40, 40)];
return self;
}
// MARK: UIViewOverrides
// Used by stack view to determin size.
- (CGSize)intrinsicContentSize
{
return CGSizeMake(0, 30);
}
// MARK: Actions
- (void)didTapCancel:(id)sender
{
[self.delegate quoteMessagePreviewViewDidPressCancel:self];
}
@end
#pragma mark -
@interface ConversationInputToolbar () <UIGestureRecognizerDelegate,
ConversationTextViewToolbarDelegate,
QuotedMessagePreviewViewDelegate>
QuotedReplyPreviewDelegate>
@property (nonatomic, readonly) UIView *composeContainer;
@property (nonatomic, readonly) ConversationInputTextView *inputTextView;
@ -179,7 +45,7 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
#pragma mark -
@property (nonatomic, nullable) QuotedMessagePreviewView *quotedMessageView;
@property (nonatomic, nullable) QuotedReplyPreview *quotedMessagePreview;
#pragma mark - Voice Memo Recording UI
@ -220,8 +86,8 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
// Since we have `self.autoresizingMask = UIViewAutoresizingFlexibleHeight`, the intrinsicContentSize is used
// to determine the height of the rendered inputAccessoryView.
CGFloat height = self.toolbarHeight + ConversationInputToolbarBorderViewHeight;
if (self.quotedMessageView) {
height += self.quotedMessageView.intrinsicContentSize.height;
if (self.quotedMessagePreview) {
height += self.quotedMessagePreview.intrinsicContentSize.height;
}
CGSize newSize = CGSizeMake(self.bounds.size.width, height);
@ -386,25 +252,25 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
- (void)setQuotedMessage:(TSQuotedMessage *)quotedMessage
{
OWSAssert(self.quotedMessageView == nil);
OWSAssert(self.quotedMessagePreview == nil);
// TODO update preview view with message in case we switch which message we're quoting.
if (quotedMessage) {
self.quotedMessageView = [[QuotedMessagePreviewView alloc] initWithQuotedMessage:quotedMessage];
self.quotedMessageView.delegate = self;
self.quotedMessagePreview = [[QuotedReplyPreview alloc] initWithQuotedMessage:quotedMessage];
self.quotedMessagePreview.delegate = self;
}
// TODO animate
[self.contentStackView insertArrangedSubview:self.quotedMessageView atIndex:0];
[self.contentStackView insertArrangedSubview:self.quotedMessagePreview atIndex:0];
}
- (void)clearQuotedMessage
{
// TODO animate
if (self.quotedMessageView) {
[self.contentStackView removeArrangedSubview:self.quotedMessageView];
[self.quotedMessageView removeFromSuperview];
self.quotedMessageView = nil;
if (self.quotedMessagePreview) {
[self.contentStackView removeArrangedSubview:self.quotedMessagePreview];
[self.quotedMessagePreview removeFromSuperview];
self.quotedMessagePreview = nil;
}
}
@ -878,9 +744,9 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
}
}
#pragma mark QuotedMessagePreviewViewDelegate
#pragma mark QuotedReplyPreviewViewDelegate
- (void)quoteMessagePreviewViewDidPressCancel:(QuotedMessagePreviewView *)view
- (void)quotedReplyPreviewDidPressCancel:(QuotedReplyPreview *)preview
{
[self clearQuotedMessage];
}

View File

@ -239,7 +239,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate, Medi
// We use the "short" status message to avoid being redundant with the section title.
statusLabel.text = shortStatusMessage
statusLabel.textColor = UIColor.ows_darkGray
statusLabel.font = UIFont.ows_footnote()
statusLabel.font = UIFont.ows_footnote
statusLabel.adjustsFontSizeToFitWidth = true
statusLabel.sizeToFit()
cell.accessoryView = statusLabel
@ -345,7 +345,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate, Medi
// See comments on updateTextLayout.
let messageTextView = UITextView()
self.messageTextView = messageTextView
messageTextView.font = UIFont.ows_dynamicTypeBody()
messageTextView.font = UIFont.ows_dynamicTypeBody
messageTextView.backgroundColor = UIColor.clear
messageTextView.isOpaque = false
messageTextView.isEditable = false

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -42,9 +42,9 @@ class AttachmentPointerView: UIView {
if attachmentPointer.state == .downloading {
NotificationCenter.default.addObserver(self,
selector:#selector(attachmentDownloadProgress(_:)),
name:NSNotification.Name.attachmentDownloadProgress,
object:nil)
selector: #selector(attachmentDownloadProgress(_:)),
name: NSNotification.Name.attachmentDownloadProgress,
object: nil)
}
}
@ -103,7 +103,7 @@ class AttachmentPointerView: UIView {
nameLabel.textAlignment = .center
nameLabel.textColor = self.textColor
nameLabel.font = UIFont.ows_dynamicTypeBody()
nameLabel.font = UIFont.ows_dynamicTypeBody
nameLabel.autoPinWidthToSuperview()
nameLabel.autoPinEdge(toSuperviewEdge: .top)
@ -118,7 +118,7 @@ class AttachmentPointerView: UIView {
statusLabel.numberOfLines = 2
statusLabel.textColor = self.textColor
statusLabel.font = UIFont.ows_footnote()
statusLabel.font = UIFont.ows_footnote
statusLabel.autoPinWidthToSuperview()
statusLabel.autoPinEdge(.top, to: .bottom, of: progressView, withOffset: 4)

View File

@ -24,8 +24,8 @@ import SignalServiceKit
self.contentView.addSubview(textContainer)
// Font config
nameLabel.font = UIFont.ows_dynamicTypeBody()
subtitleLabel.font = UIFont.ows_footnote()
nameLabel.font = UIFont.ows_dynamicTypeBody
subtitleLabel.font = UIFont.ows_footnote
subtitleLabel.textColor = UIColor.ows_darkGray
// Listen to notifications...

View File

@ -0,0 +1,122 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
@objc
protocol QuotedReplyPreviewDelegate: class {
func quotedReplyPreviewDidPressCancel(_ preview: QuotedReplyPreview)
}
@objc
class QuotedReplyPreview: UIView {
public weak var delegate: QuotedReplyPreviewDelegate?
private class func iconView(message: TSQuotedMessage) -> UIView? {
guard let contentType = message.contentType else {
return nil
}
let iconText = TSAttachmentStream.emoji(forMimeType: contentType)
let label = UILabel()
label.setContentHuggingHigh()
label.text = iconText
return label
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(quotedMessage: TSQuotedMessage) {
super.init(frame: .zero)
let isQuotingSelf = quotedMessage.authorId == TSAccountManager.localNumber()
// used for stripe and author
// FIXME actual colors TBD
let authorColor: UIColor = isQuotingSelf ? .ows_materialBlue : .black
// used for text and cancel
let foregroundColor: UIColor = .darkGray
let authorLabel: UILabel = UILabel()
authorLabel.textColor = authorColor
authorLabel.text = Environment.current().contactsManager.displayName(forPhoneIdentifier: quotedMessage.authorId)
authorLabel.font = .ows_dynamicTypeHeadline
let bodyLabel: UILabel = UILabel()
bodyLabel.textColor = foregroundColor
bodyLabel.font = .ows_footnote
bodyLabel.text = quotedMessage.body
let iconView: UIView? = QuotedReplyPreview.iconView(message: quotedMessage)
let cancelButton: UIButton = UIButton(type: .custom)
// FIXME proper image asset/size
let buttonImage: UIImage = #imageLiteral(resourceName: "quoted-message-cancel").withRenderingMode(.alwaysTemplate)
cancelButton.setImage(buttonImage, for: .normal)
cancelButton.imageView?.tintColor = foregroundColor
cancelButton.addTarget(self, action: #selector(didTapCancel), for: .touchUpInside)
let quoteStripe: UIView = UIView()
quoteStripe.backgroundColor = authorColor
let contentViews: [UIView] = iconView == nil ? [bodyLabel] : [iconView!, bodyLabel]
let contentContainer: UIStackView = UIStackView(arrangedSubviews: contentViews)
contentContainer.axis = .horizontal
contentContainer.spacing = 4.0
self.addSubview(authorLabel)
self.addSubview(contentContainer)
self.addSubview(cancelButton)
self.addSubview(quoteStripe)
// Layout
let kCancelButtonMargin: CGFloat = 4
let kQuoteStripeWidth: CGFloat = 4
let leadingMargin: CGFloat = kQuoteStripeWidth + 8
let vMargin: CGFloat = 6
let trailingMargin: CGFloat = 8
self.layoutMargins = UIEdgeInsets(top: vMargin, left: leadingMargin, bottom: vMargin, right: trailingMargin)
quoteStripe.autoPinEdge(toSuperviewEdge: .leading)
quoteStripe.autoPinHeightToSuperview()
quoteStripe.autoSetDimension(.width, toSize: kQuoteStripeWidth)
authorLabel.autoPinTopToSuperviewMargin()
authorLabel.autoPinLeadingToSuperviewMargin()
authorLabel.autoPinEdge(.trailing, to: .leading, of: cancelButton, withOffset: -kCancelButtonMargin)
authorLabel.setCompressionResistanceHigh()
contentContainer.autoPinLeadingToSuperviewMargin()
contentContainer.autoPinBottomToSuperviewMargin()
contentContainer.autoPinEdge(.top, to: .bottom, of: authorLabel)
contentContainer.autoPinEdge(.trailing, to: .leading, of: cancelButton, withOffset: -kCancelButtonMargin)
cancelButton.autoPinTrailingToSuperviewMargin()
cancelButton.autoVCenterInSuperview()
cancelButton.setContentHuggingHigh()
cancelButton.autoSetDimensions(to: CGSize(width: 40, height: 40))
}
// MARK: UIViewOverrides
// Used by stack view to determin size.
override var intrinsicContentSize: CGSize {
return CGSize(width: 0, height: 30)
}
// MARK: Actions
@objc
func didTapCancel(_ sender: Any) {
self.delegate?.quotedReplyPreviewDidPressCancel(self)
}
}

View File

@ -536,7 +536,7 @@ class CaptioningToolbar: UIView, UITextViewDelegate {
textView.backgroundColor = UIColor.white
textView.layer.cornerRadius = 4.0
textView.addBorder(with: UIColor.lightGray)
textView.font = UIFont.ows_dynamicTypeBody()
textView.font = UIFont.ows_dynamicTypeBody
textView.returnKeyType = .done
let sendTitle = NSLocalizedString("ATTACHMENT_APPROVAL_SEND_BUTTON", comment: "Label for 'send' button in the 'attachment approval' dialog.")

View File

@ -97,7 +97,7 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
textView.delegate = self
textView.backgroundColor = UIColor.white
textView.textColor = UIColor.black
textView.font = UIFont.ows_dynamicTypeBody()
textView.font = UIFont.ows_dynamicTypeBody
textView.text = self.initialMessageText
textView.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
textView.textContainerInset = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)

View File

@ -26,11 +26,11 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Dynamic Type
+ (UIFont *)ows_dynamicTypeBodyFont;
+ (UIFont *)ows_dynamicTypeTitle2Font;
+ (UIFont *)ows_dynamicTypeHeadlineFont;
+ (UIFont *)ows_infoMessageFont;
+ (UIFont *)ows_footnoteFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeBodyFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeTitle2Font;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeHeadlineFont;
@property (class, readonly, nonatomic) UIFont *ows_infoMessageFont;
@property (class, readonly, nonatomic) UIFont *ows_footnoteFont;
@end