From c2ab45449944a28c2c6ff08de3fc31d81d8775a5 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Tue, 22 Mar 2022 10:08:14 +1100 Subject: [PATCH] fix conversation screen title & button arrangement after message request is approved --- .../ConversationTitleView.swift | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Session/Conversations/Views & Modals/ConversationTitleView.swift b/Session/Conversations/Views & Modals/ConversationTitleView.swift index 39896a3f3..83153c48d 100644 --- a/Session/Conversations/Views & Modals/ConversationTitleView.swift +++ b/Session/Conversations/Views & Modals/ConversationTitleView.swift @@ -23,6 +23,14 @@ final class ConversationTitleView : UIView { result.lineBreakMode = .byTruncatingTail return result }() + + private lazy var stackView: UIStackView = { + let result = UIStackView(arrangedSubviews: [ titleLabel, subtitleLabel ]) + result.axis = .vertical + result.alignment = .center + result.isLayoutMarginsRelativeArrangement = true + return result + }() // MARK: Lifecycle init(thread: TSThread) { @@ -40,13 +48,6 @@ final class ConversationTitleView : UIView { } private func initialize() { - let stackView = UIStackView(arrangedSubviews: [ titleLabel, subtitleLabel ]) - stackView.axis = .vertical - stackView.alignment = .center - stackView.isLayoutMarginsRelativeArrangement = true - let shouldShowCallButton = SessionCall.isEnabled && !thread.isNoteToSelf() && !thread.isGroupThread() && !thread.isMessageRequest() - let leftMargin: CGFloat = shouldShowCallButton ? 54 : 8 // Contact threads also have the call button to compensate for - stackView.layoutMargins = UIEdgeInsets(top: 0, left: leftMargin, bottom: 0, right: 0) addSubview(stackView) stackView.pin(to: self) let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap)) @@ -69,6 +70,11 @@ final class ConversationTitleView : UIView { subtitleLabel.attributedText = subtitle let titleFontSize = (subtitle != nil) ? Values.mediumFontSize : Values.veryLargeFontSize titleLabel.font = .boldSystemFont(ofSize: titleFontSize) + + // Update title left margin + let shouldShowCallButton = SessionCall.isEnabled && !thread.isNoteToSelf() && !thread.isGroupThread() && !thread.isMessageRequest() + let leftMargin: CGFloat = shouldShowCallButton ? 54 : 8 // Contact threads also have the call button to compensate for + stackView.layoutMargins = UIEdgeInsets(top: 0, left: leftMargin, bottom: 0, right: 0) } // MARK: General