From 609b5929b549b3a1dfe2efce145d7a6f72dd3caf Mon Sep 17 00:00:00 2001 From: filipealva Date: Fri, 9 Nov 2018 00:15:46 -0200 Subject: [PATCH 1/8] Test for landscape only with .phone interface idiom --- Rocket.Chat/Controllers/Chat/MessagesViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rocket.Chat/Controllers/Chat/MessagesViewController.swift b/Rocket.Chat/Controllers/Chat/MessagesViewController.swift index b81d8e0321..4dfdda3eef 100644 --- a/Rocket.Chat/Controllers/Chat/MessagesViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MessagesViewController.swift @@ -99,7 +99,7 @@ final class MessagesViewController: RocketChatViewController { lazy var screenSize = view.frame.size var isInLandscape: Bool { - return screenSize.width / screenSize.height > 1 ? true : false + return screenSize.width / screenSize.height > 1 && UIDevice.current.userInterfaceIdiom == .phone } deinit { From d4041e8faef497c73c6b04bdef2babd739083b00 Mon Sep 17 00:00:00 2001 From: filipealva Date: Fri, 9 Nov 2018 00:22:07 -0200 Subject: [PATCH 2/8] Add messageWidth() function to calculate the message's width --- .../Controllers/Chat/MessagesViewController.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Rocket.Chat/Controllers/Chat/MessagesViewController.swift b/Rocket.Chat/Controllers/Chat/MessagesViewController.swift index 4dfdda3eef..bc653a8e23 100644 --- a/Rocket.Chat/Controllers/Chat/MessagesViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MessagesViewController.swift @@ -251,6 +251,19 @@ final class MessagesViewController: RocketChatViewController { API.current()?.client(SubscriptionsClient.self).markAsRead(subscription: subscription) } + // MARK: Sizing + + func messageWidth() -> CGFloat { + var horizontalMargins: CGFloat + if isInLandscape { + horizontalMargins = collectionView.adjustedContentInset.top + collectionView.adjustedContentInset.bottom + } else { + horizontalMargins = 0 + } + + return screenSize.width - horizontalMargins + } + } extension MessagesViewController { From a9716199e88c4ab1122ce872a37730037c46fd75 Mon Sep 17 00:00:00 2001 From: filipealva Date: Fri, 9 Nov 2018 00:22:46 -0200 Subject: [PATCH 3/8] Use messageWidth() on MessageSection --- .../Controllers/Chat/ChatSections/MessageSection.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift b/Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift index 57a6267dbb..9eaac597c6 100644 --- a/Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift +++ b/Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift @@ -251,9 +251,7 @@ final class MessageSection: ChatSection { cell.delegate = self } - let adjustedContentInsets = messagesController?.collectionView.adjustedContentInset ?? .zero - let adjustedHoritonzalInsets = adjustedContentInsets.left + adjustedContentInsets.right - cell.adjustedHorizontalInsets = adjustedHoritonzalInsets + cell.adjustedHorizontalInsets = messagesController?.messageWidth() ?? 0 cell.viewModel = viewModel cell.configure() return cell From b53a9bc47b7a1b70d98047d2c76601a09cc44593 Mon Sep 17 00:00:00 2001 From: filipealva Date: Fri, 9 Nov 2018 00:23:00 -0200 Subject: [PATCH 4/8] Use messageWidth() when calculating cell's size --- .../Chat/MessagesViewController.swift | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Rocket.Chat/Controllers/Chat/MessagesViewController.swift b/Rocket.Chat/Controllers/Chat/MessagesViewController.swift index bc653a8e23..d540972824 100644 --- a/Rocket.Chat/Controllers/Chat/MessagesViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MessagesViewController.swift @@ -13,14 +13,14 @@ import DifferenceKit protocol SizingCell: class { static var sizingCell: UICollectionViewCell & ChatCell { get } - static func size(for viewModel: AnyChatItem, with horizontalMargins: CGFloat) -> CGSize + static func size(for viewModel: AnyChatItem, with cellWidth: CGFloat) -> CGSize } extension SizingCell { - static func size(for viewModel: AnyChatItem, with horizontalMargins: CGFloat) -> CGSize { + static func size(for viewModel: AnyChatItem, with cellWidth: CGFloat) -> CGSize { var mutableSizingCell = sizingCell mutableSizingCell.prepareForReuse() - mutableSizingCell.adjustedHorizontalInsets = horizontalMargins + mutableSizingCell.adjustedHorizontalInsets = cellWidth mutableSizingCell.viewModel = viewModel mutableSizingCell.configure() mutableSizingCell.setNeedsLayout() @@ -296,15 +296,9 @@ extension MessagesViewController { """) } - var horizontalMargins: CGFloat - if isInLandscape { - horizontalMargins = collectionView.adjustedContentInset.top + collectionView.adjustedContentInset.bottom - } else { - horizontalMargins = 0 - } - - var size = type(of: sizingCell).size(for: item, with: horizontalMargins) - size = CGSize(width: screenSize.width - horizontalMargins, height: size.height) + let cellWidth = messageWidth() + var size = type(of: sizingCell).size(for: item, with: cellWidth) + size = CGSize(width: cellWidth, height: size.height) viewSizingModel.set(size: size, for: item.differenceIdentifier) return size } From d397a7adb998bbcb51e21ea6adc3ccc97ba07d33 Mon Sep 17 00:00:00 2001 From: filipealva Date: Fri, 9 Nov 2018 00:23:34 -0200 Subject: [PATCH 5/8] Use messageWidth (as horizontal margins for now) instead of basing the width on UIScreen bounds --- .../New Chat/Cells/BaseQuoteMessageCell.swift | 8 +++---- .../Cells/BaseTextAttachmentMessageCell.swift | 5 ++--- .../New Chat/Cells/BasicMessageCell.swift | 22 ++++++++----------- .../Chat/New Chat/Cells/MessageURLCell.swift | 5 ++--- .../Chat/New Chat/Cells/MessageURLCell.xib | 4 ++-- .../Cells/SequentialMessageCell.swift | 19 +++++++--------- 6 files changed, 26 insertions(+), 37 deletions(-) diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift index 784a5ca0f4..3299304c08 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift @@ -21,7 +21,7 @@ class BaseQuoteMessageCell: BaseMessageCell { var readReceiptTrailingInitialConstant: CGFloat = 0 var textLabelWidth: CGFloat { return - UIScreen.main.bounds.width - + adjustedHorizontalInsets - avatarLeadingInitialConstant - avatarWidthInitialConstant - containerLeadingInitialConstant - @@ -29,8 +29,7 @@ class BaseQuoteMessageCell: BaseMessageCell { textTrailingInitialConstant - containerTrailingInitialConstant - readReceiptWidthInitialConstant - - readReceiptTrailingInitialConstant - - adjustedHorizontalInsets + readReceiptTrailingInitialConstant } var isCollapsible = false @@ -39,8 +38,7 @@ class BaseQuoteMessageCell: BaseMessageCell { @objc func didTapContainerView() { guard isCollapsible, - let viewModel = viewModel, - let quoteViewModel = viewModel.base as? QuoteChatItem + let viewModel = viewModel else { return } diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift index a3b1c1885c..1dc5facd06 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift @@ -29,7 +29,7 @@ class BaseTextAttachmentMessageCell: BaseMessageCell { var readReceiptTrailingInitialConstant: CGFloat = 0 var fieldLabelWidth: CGFloat { return - UIScreen.main.bounds.width - + adjustedHorizontalInsets - avatarLeadingInitialConstant - avatarWidthInitialConstant - textContainerLeadingInitialConstant - @@ -39,8 +39,7 @@ class BaseTextAttachmentMessageCell: BaseMessageCell { fieldsStackViewTrailingInitialConstant - textContainerTrailingInitialConstant - readReceiptWidthInitialConstant - - readReceiptTrailingInitialConstant - - adjustedHorizontalInsets + readReceiptTrailingInitialConstant } func configure(stackView: UIStackView) -> CGFloat { diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift index 819ce66c06..b0d0c93fc5 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift @@ -43,15 +43,15 @@ final class BasicMessageCell: BaseMessageCell, BaseMessageCellProtocol, SizingCe @IBOutlet weak var readReceiptTrailingConstraint: NSLayoutConstraint! @IBOutlet weak var avatarWidthConstraint: NSLayoutConstraint! @IBOutlet weak var avatarLeadingConstraint: NSLayoutConstraint! - var textHorizontalMargins: CGFloat { + var textWidth: CGFloat { return - textLeadingConstraint.constant + - textTrailingConstraint.constant + - readReceiptWidthConstraint.constant + - readReceiptTrailingConstraint.constant + - avatarWidthConstraint.constant + - avatarLeadingConstraint.constant + - adjustedHorizontalInsets + adjustedHorizontalInsets - + textLeadingConstraint.constant - + textTrailingConstraint.constant - + readReceiptWidthConstraint.constant - + readReceiptTrailingConstraint.constant - + avatarWidthConstraint.constant - + avatarLeadingConstraint.constant } weak var longPressGesture: UILongPressGestureRecognizer? @@ -95,12 +95,8 @@ final class BasicMessageCell: BaseMessageCell, BaseMessageCellProtocol, SizingCe text.message = message - // FA NOTE: Using UIScreen.main bounds is fine because we are not using - // section insets, but in the future we can create a mechanism that - // discounts the UICollectionView's section insets from the main screen's bounds - let screenWidth = UIScreen.main.bounds.width let maxSize = CGSize( - width: screenWidth - textHorizontalMargins, + width: textWidth, height: .greatestFiniteMagnitude ) diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift index c9410a521a..75c1251025 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift @@ -33,10 +33,9 @@ final class MessageURLCell: UICollectionViewCell, BaseMessageCellProtocol, ChatC @IBOutlet weak var containerTrailingConstraint: NSLayoutConstraint! var containerWidth: CGFloat { return - UIScreen.main.bounds.width - + adjustedHorizontalInsets - containerLeadingConstraint.constant - - containerTrailingConstraint.constant - - adjustedHorizontalInsets + containerTrailingConstraint.constant } weak var delegate: ChatMessageCellProtocol? diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.xib b/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.xib index 954b764976..4de3a55585 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.xib +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.xib @@ -1,11 +1,11 @@ - + - + diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/SequentialMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/SequentialMessageCell.swift index d0fcfd800b..4f51124f42 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/SequentialMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/SequentialMessageCell.swift @@ -28,12 +28,13 @@ final class SequentialMessageCell: BaseMessageCell, BaseMessageCellProtocol, Siz @IBOutlet weak var textTrailingConstraint: NSLayoutConstraint! @IBOutlet weak var readReceiptWidthConstraint: NSLayoutConstraint! @IBOutlet weak var readReceiptTrailingConstraint: NSLayoutConstraint! - var textHorizontalMargins: CGFloat { - return textLeadingConstraint.constant + - textTrailingConstraint.constant + - readReceiptWidthConstraint.constant + - readReceiptTrailingConstraint.constant + - adjustedHorizontalInsets + var textWidth: CGFloat { + return + adjustedHorizontalInsets - + textLeadingConstraint.constant - + textTrailingConstraint.constant - + readReceiptWidthConstraint.constant - + readReceiptTrailingConstraint.constant } weak var longPressGesture: UILongPressGestureRecognizer? @@ -75,12 +76,8 @@ final class SequentialMessageCell: BaseMessageCell, BaseMessageCellProtocol, Siz text.message = message - // FA NOTE: Using UIScreen.main bounds is fine because we are not using - // section insets, but in the future we can create a mechanism that - // discounts the UICollectionView's section insets from the main screen's bounds - let screenWidth = UIScreen.main.bounds.width let maxSize = CGSize( - width: screenWidth - textHorizontalMargins, + width: textWidth, height: .greatestFiniteMagnitude ) From fe00a1289f26a486afeefd92c99ae3d9016b18b8 Mon Sep 17 00:00:00 2001 From: filipealva Date: Fri, 9 Nov 2018 10:38:02 -0200 Subject: [PATCH 6/8] Adjust chat cell implementation on controllers --- Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift | 2 +- Rocket.Chat/Controllers/Chat/MessagesViewController.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift b/Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift index 9eaac597c6..2d7ef94550 100644 --- a/Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift +++ b/Rocket.Chat/Controllers/Chat/ChatSections/MessageSection.swift @@ -251,7 +251,7 @@ final class MessageSection: ChatSection { cell.delegate = self } - cell.adjustedHorizontalInsets = messagesController?.messageWidth() ?? 0 + cell.messageWidth = messagesController?.messageWidth() ?? 0 cell.viewModel = viewModel cell.configure() return cell diff --git a/Rocket.Chat/Controllers/Chat/MessagesViewController.swift b/Rocket.Chat/Controllers/Chat/MessagesViewController.swift index d540972824..62233d7da8 100644 --- a/Rocket.Chat/Controllers/Chat/MessagesViewController.swift +++ b/Rocket.Chat/Controllers/Chat/MessagesViewController.swift @@ -20,7 +20,7 @@ extension SizingCell { static func size(for viewModel: AnyChatItem, with cellWidth: CGFloat) -> CGSize { var mutableSizingCell = sizingCell mutableSizingCell.prepareForReuse() - mutableSizingCell.adjustedHorizontalInsets = cellWidth + mutableSizingCell.messageWidth = cellWidth mutableSizingCell.viewModel = viewModel mutableSizingCell.configure() mutableSizingCell.setNeedsLayout() From 9aafa1034ae610db46c04e0b17c0f82acaf26ceb Mon Sep 17 00:00:00 2001 From: filipealva Date: Fri, 9 Nov 2018 10:38:33 -0200 Subject: [PATCH 7/8] Update chat cell implementation on cells --- Rocket.Chat/Views/Chat/New Chat/Cells/BaseMessageCell.swift | 2 +- .../Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift | 2 +- .../Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift | 2 +- Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift | 2 +- Rocket.Chat/Views/Chat/New Chat/Cells/DateSeparatorCell.swift | 2 +- .../Views/Chat/New Chat/Cells/MessageActionsCell.swift | 2 +- Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift | 4 ++-- Rocket.Chat/Views/Chat/New Chat/Cells/ReactionsCell.swift | 2 +- .../Views/Chat/New Chat/Cells/SequentialMessageCell.swift | 2 +- Rocket.Chat/Views/Chat/New Chat/Cells/UnreadMarkerCell.swift | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseMessageCell.swift index 117c94422b..484ee3baf5 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseMessageCell.swift @@ -10,7 +10,7 @@ import UIKit import RocketChatViewController class BaseMessageCell: UICollectionViewCell, ChatCell { - var adjustedHorizontalInsets: CGFloat = 0 + var messageWidth: CGFloat = 0 var viewModel: AnyChatItem? lazy var avatarView: AvatarView = { diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift index 3299304c08..a28c943eb2 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseQuoteMessageCell.swift @@ -21,7 +21,7 @@ class BaseQuoteMessageCell: BaseMessageCell { var readReceiptTrailingInitialConstant: CGFloat = 0 var textLabelWidth: CGFloat { return - adjustedHorizontalInsets - + messageWidth - avatarLeadingInitialConstant - avatarWidthInitialConstant - containerLeadingInitialConstant - diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift index 1dc5facd06..9be1a850ce 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/BaseTextAttachmentMessageCell.swift @@ -29,7 +29,7 @@ class BaseTextAttachmentMessageCell: BaseMessageCell { var readReceiptTrailingInitialConstant: CGFloat = 0 var fieldLabelWidth: CGFloat { return - adjustedHorizontalInsets - + messageWidth - avatarLeadingInitialConstant - avatarWidthInitialConstant - textContainerLeadingInitialConstant - diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift index b0d0c93fc5..7eb99d0d66 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/BasicMessageCell.swift @@ -45,7 +45,7 @@ final class BasicMessageCell: BaseMessageCell, BaseMessageCellProtocol, SizingCe @IBOutlet weak var avatarLeadingConstraint: NSLayoutConstraint! var textWidth: CGFloat { return - adjustedHorizontalInsets - + messageWidth - textLeadingConstraint.constant - textTrailingConstraint.constant - readReceiptWidthConstraint.constant - diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/DateSeparatorCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/DateSeparatorCell.swift index c2ae7f3862..fb4dec090b 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/DateSeparatorCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/DateSeparatorCell.swift @@ -24,7 +24,7 @@ final class DateSeparatorCell: UICollectionViewCell, ChatCell, SizingCell { @IBOutlet weak var date: UILabel! @IBOutlet weak var rightLine: UIView! - var adjustedHorizontalInsets: CGFloat = 0 + var messageWidth: CGFloat = 0 var viewModel: AnyChatItem? func configure() { diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/MessageActionsCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/MessageActionsCell.swift index 3d73997215..21c05766cb 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/MessageActionsCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/MessageActionsCell.swift @@ -30,7 +30,7 @@ class MessageActionsCell: UICollectionViewCell, BaseMessageCellProtocol, ChatCel } weak var delegate: ChatMessageCellProtocol? - var adjustedHorizontalInsets: CGFloat = 0 + var messageWidth: CGFloat = 0 var viewModel: AnyChatItem? func configure() {} diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift index 75c1251025..b7a311c5a1 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/MessageURLCell.swift @@ -33,14 +33,14 @@ final class MessageURLCell: UICollectionViewCell, BaseMessageCellProtocol, ChatC @IBOutlet weak var containerTrailingConstraint: NSLayoutConstraint! var containerWidth: CGFloat { return - adjustedHorizontalInsets - + messageWidth - containerLeadingConstraint.constant - containerTrailingConstraint.constant } weak var delegate: ChatMessageCellProtocol? - var adjustedHorizontalInsets: CGFloat = 0 + var messageWidth: CGFloat = 0 var viewModel: AnyChatItem? var thumbnailHeightInitialConstant: CGFloat = 0 diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/ReactionsCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/ReactionsCell.swift index 32310a5ea4..fe47a9e631 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/ReactionsCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/ReactionsCell.swift @@ -20,7 +20,7 @@ final class ReactionsCell: UICollectionViewCell, ChatCell, SizingCell { return cell }() - var adjustedHorizontalInsets: CGFloat = 0 + var messageWidth: CGFloat = 0 var viewModel: AnyChatItem? @IBOutlet weak var reactionsList: ReactionListView! { diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/SequentialMessageCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/SequentialMessageCell.swift index 4f51124f42..1a944f3c1b 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/SequentialMessageCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/SequentialMessageCell.swift @@ -30,7 +30,7 @@ final class SequentialMessageCell: BaseMessageCell, BaseMessageCellProtocol, Siz @IBOutlet weak var readReceiptTrailingConstraint: NSLayoutConstraint! var textWidth: CGFloat { return - adjustedHorizontalInsets - + messageWidth - textLeadingConstraint.constant - textTrailingConstraint.constant - readReceiptWidthConstraint.constant - diff --git a/Rocket.Chat/Views/Chat/New Chat/Cells/UnreadMarkerCell.swift b/Rocket.Chat/Views/Chat/New Chat/Cells/UnreadMarkerCell.swift index c9e9e67b16..a389f9a020 100644 --- a/Rocket.Chat/Views/Chat/New Chat/Cells/UnreadMarkerCell.swift +++ b/Rocket.Chat/Views/Chat/New Chat/Cells/UnreadMarkerCell.swift @@ -29,7 +29,7 @@ final class UnreadMarkerCell: UICollectionViewCell, ChatCell, SizingCell { @IBOutlet weak var separatorLeft: UIView! @IBOutlet weak var separatorRight: UIView! - var adjustedHorizontalInsets: CGFloat = 0 + var messageWidth: CGFloat = 0 var viewModel: AnyChatItem? func configure() { From 087d7f869dc4088d46ed2814241b2e8e1ccda0f2 Mon Sep 17 00:00:00 2001 From: filipealva Date: Fri, 9 Nov 2018 10:38:44 -0200 Subject: [PATCH 8/8] Update RocketChatViewController --- Podfile.lock | 2 +- Pods/Manifest.lock | 2 +- .../Classes/Delegate/ComposerViewDelegate.swift | 9 +++++++++ .../Composer/Classes/Views/ComposerView.swift | 12 +++++++++++- .../Classes/RocketChatViewController.swift | 2 +- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index f53109d925..b41693e05e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -157,7 +157,7 @@ CHECKOUT OPTIONS: :commit: c34d9ccef689c55b9eae69f3c65283da8d8b0c6c :git: https://github.com/RocketChat/RCMarkdownParser.git RocketChatViewController: - :commit: 5d98d7c149fa0f43f7a53fba37b3af444a4f0402 + :commit: 65681ffd775907ea6d29e75269eb605a933ea25c :git: https://github.com/RocketChat/RocketChatViewController SimpleImageViewer: :commit: 8222c338de0f285ca0c2d556c5d8dedd4a365b52 diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock index f53109d925..b41693e05e 100644 --- a/Pods/Manifest.lock +++ b/Pods/Manifest.lock @@ -157,7 +157,7 @@ CHECKOUT OPTIONS: :commit: c34d9ccef689c55b9eae69f3c65283da8d8b0c6c :git: https://github.com/RocketChat/RCMarkdownParser.git RocketChatViewController: - :commit: 5d98d7c149fa0f43f7a53fba37b3af444a4f0402 + :commit: 65681ffd775907ea6d29e75269eb605a933ea25c :git: https://github.com/RocketChat/RocketChatViewController SimpleImageViewer: :commit: 8222c338de0f285ca0c2d556c5d8dedd4a365b52 diff --git a/Pods/RocketChatViewController/Composer/Classes/Delegate/ComposerViewDelegate.swift b/Pods/RocketChatViewController/Composer/Classes/Delegate/ComposerViewDelegate.swift index 1e91ba74e9..3fdab0299b 100644 --- a/Pods/RocketChatViewController/Composer/Classes/Delegate/ComposerViewDelegate.swift +++ b/Pods/RocketChatViewController/Composer/Classes/Delegate/ComposerViewDelegate.swift @@ -23,6 +23,11 @@ public protocol ComposerViewDelegate: class { */ func composerView(_ composerView: ComposerView, addonAt slot: ComposerAddonSlot, index: UInt) -> ComposerAddon? + /** + Asks the delegate if the composer view should process the pressing of the return button. + */ + func composerViewShouldReturn(_ composerView: ComposerView) -> Bool + /** Tells the delegate that the text selection changed in the specified composer view's text view. */ @@ -48,6 +53,10 @@ public extension ComposerViewDelegate { return nil } + func composerViewShouldReturn(_ composerView: ComposerView) -> Bool { + return true + } + func composerViewDidChangeSelection(_ composerView: ComposerView) { } func composerView(_ composerView: ComposerView, didUpdateAddonView view: UIView?, at slot: ComposerAddonSlot, index: UInt) { } func composerView(_ composerView: ComposerView, didTapButton button: ComposerButton) { } diff --git a/Pods/RocketChatViewController/Composer/Classes/Views/ComposerView.swift b/Pods/RocketChatViewController/Composer/Classes/Views/ComposerView.swift index e0a1fbb2d9..a22a51f885 100644 --- a/Pods/RocketChatViewController/Composer/Classes/Views/ComposerView.swift +++ b/Pods/RocketChatViewController/Composer/Classes/Views/ComposerView.swift @@ -314,10 +314,20 @@ public extension ComposerView { } // MARK: UITextView Delegate - extension ComposerView: UITextViewDelegate { @objc public func textViewDidChangeSelection(_ textView: UITextView) { currentDelegate.composerViewDidChangeSelection(self) return } + + public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { + // it would be good if we could support "soft return" + // (shift+enter) to allow the user to type newlines + // but as of iOS 12, it's not possible yet :( + if text == "\n" { + return currentDelegate.composerViewShouldReturn(self) + } + + return true + } } diff --git a/Pods/RocketChatViewController/RocketChatViewController/Classes/RocketChatViewController.swift b/Pods/RocketChatViewController/RocketChatViewController/Classes/RocketChatViewController.swift index 4d67a40aa8..88cf4141f1 100644 --- a/Pods/RocketChatViewController/RocketChatViewController/Classes/RocketChatViewController.swift +++ b/Pods/RocketChatViewController/RocketChatViewController/Classes/RocketChatViewController.swift @@ -142,7 +142,7 @@ public extension ChatItem where Self: Differentiable { */ public protocol ChatCell { - var adjustedHorizontalInsets: CGFloat { get set } + var messageWidth: CGFloat { get set } var viewModel: AnyChatItem? { get set } func configure() }