From 93e139cfa614c37ec563ef6892f8c8ef9a6d7900 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Wed, 7 Feb 2024 14:29:01 +1100 Subject: [PATCH] minor fix on minimum width for context menu action --- .../ContextMenuVC+ActionView.swift | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Session/Conversations/Context Menu/ContextMenuVC+ActionView.swift b/Session/Conversations/Context Menu/ContextMenuVC+ActionView.swift index e6b8db900..8c3c38dfc 100644 --- a/Session/Conversations/Context Menu/ContextMenuVC+ActionView.swift +++ b/Session/Conversations/Context Menu/ContextMenuVC+ActionView.swift @@ -42,6 +42,19 @@ extension ContextMenuVC { return result }() + + private lazy var labelContainer: UIView = { + let result: UIView = UIView() + result.addSubview(titleLabel) + result.addSubview(subtitleLabel) + titleLabel.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top ], to: result) + subtitleLabel.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.bottom ], to: result) + titleLabel.pin(.bottom, to: .top, of: subtitleLabel) + + return result + }() + + private lazy var subtitleWidthConstraint = labelContainer.set(.width, greaterThanOrEqualTo: 115) // MARK: - Lifecycle @@ -71,14 +84,6 @@ extension ContextMenuVC { titleLabel.text = action.title setUpSubtitle() - let labelContainer: UIView = UIView() - labelContainer.set(.width, greaterThanOrEqualTo: 115) - labelContainer.addSubview(titleLabel) - labelContainer.addSubview(subtitleLabel) - titleLabel.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top ], to: labelContainer) - subtitleLabel.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.bottom ], to: labelContainer) - titleLabel.pin(.bottom, to: .top, of: subtitleLabel) - // Stack view let stackView: UIStackView = UIStackView(arrangedSubviews: [ iconImageView, labelContainer ]) stackView.axis = .horizontal @@ -107,10 +112,12 @@ extension ContextMenuVC { let expiresStartedAtMs = self.action.expirationInfo?.expiresStartedAtMs else { subtitleLabel.isHidden = true + subtitleWidthConstraint.isActive = false return } subtitleLabel.isHidden = false + subtitleWidthConstraint.isActive = true let timeToExpireInSeconds: TimeInterval = (expiresStartedAtMs + expiresInSeconds * 1000 - Double(SnodeAPI.currentOffsetTimestampMs())) / 1000 subtitleLabel.text = String(format: "DISAPPEARING_MESSAGES_AUTO_DELETES_COUNT_DOWN".localized(), timeToExpireInSeconds.formatted(format: .twoUnits))