Skip to content

Commit 0ece34c

Browse files
authored
Merge pull request #597 from session-foundation/dev
Release 2.14.4 RC 2
2 parents 14aba9d + 2d3033f commit 0ece34c

31 files changed

+492
-371
lines changed

Session.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8320,7 +8320,7 @@
83208320
CODE_SIGN_IDENTITY = "iPhone Developer";
83218321
COMPILE_LIB_SESSION = "";
83228322
COPY_PHASE_STRIP = NO;
8323-
CURRENT_PROJECT_VERSION = 636;
8323+
CURRENT_PROJECT_VERSION = 639;
83248324
ENABLE_BITCODE = NO;
83258325
ENABLE_STRICT_OBJC_MSGSEND = YES;
83268326
ENABLE_TESTABILITY = YES;
@@ -8401,7 +8401,7 @@
84018401
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
84028402
CODE_SIGN_IDENTITY = "iPhone Distribution";
84038403
COMPILE_LIB_SESSION = "";
8404-
CURRENT_PROJECT_VERSION = 636;
8404+
CURRENT_PROJECT_VERSION = 639;
84058405
ENABLE_BITCODE = NO;
84068406
ENABLE_MODULE_VERIFIER = YES;
84078407
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -8882,7 +8882,7 @@
88828882
CODE_SIGN_IDENTITY = "iPhone Developer";
88838883
COMPILE_LIB_SESSION = YES;
88848884
COPY_PHASE_STRIP = NO;
8885-
CURRENT_PROJECT_VERSION = 636;
8885+
CURRENT_PROJECT_VERSION = 639;
88868886
ENABLE_BITCODE = NO;
88878887
ENABLE_STRICT_OBJC_MSGSEND = YES;
88888888
ENABLE_TESTABILITY = YES;
@@ -9469,7 +9469,7 @@
94699469
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
94709470
CODE_SIGN_IDENTITY = "iPhone Distribution";
94719471
COMPILE_LIB_SESSION = YES;
9472-
CURRENT_PROJECT_VERSION = 636;
9472+
CURRENT_PROJECT_VERSION = 639;
94739473
ENABLE_BITCODE = NO;
94749474
ENABLE_STRICT_OBJC_MSGSEND = YES;
94759475
GCC_NO_COMMON_BLOCKS = YES;

Session/Conversations/ConversationVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ final class ConversationVC: BaseVC, LibSessionRespondingViewController, Conversa
365365
.backgroundPrimary,
366366
.backgroundPrimary
367367
]
368-
result.set(.height, to: 92)
369368

370369
return result
371370
}()
@@ -1720,6 +1719,7 @@ final class ConversationVC: BaseVC, LibSessionRespondingViewController, Conversa
17201719
shouldExpanded: viewModel.messageExpandedInteractionIds
17211720
.contains(cellViewModel.id),
17221721
lastSearchText: viewModel.lastSearchedText,
1722+
tableSize: tableView.bounds.size,
17231723
using: viewModel.dependencies
17241724
)
17251725
cell.delegate = self

Session/Conversations/Message Cells/CallMessageCell.swift

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,27 @@ final class CallMessageCell: MessageCell {
2828
// MARK: - UI
2929

3030
private lazy var topConstraint: NSLayoutConstraint = mainStackView.pin(.top, to: .top, of: self, withInset: CallMessageCell.inset)
31-
private lazy var iconImageViewWidthConstraint: NSLayoutConstraint = iconImageView.set(.width, to: 0)
32-
private lazy var iconImageViewHeightConstraint: NSLayoutConstraint = iconImageView.set(.height, to: 0)
33-
private lazy var infoImageViewWidthConstraint: NSLayoutConstraint = infoImageView.set(.width, to: 0)
34-
private lazy var infoImageViewHeightConstraint: NSLayoutConstraint = infoImageView.set(.height, to: 0)
3531

36-
private lazy var iconImageView: UIImageView = UIImageView()
32+
private lazy var iconImageView: UIImageView = {
33+
let result: UIImageView = UIImageView()
34+
result.themeTintColor = .textPrimary
35+
result.set(.width, to: CallMessageCell.iconSize)
36+
result.set(.height, to: CallMessageCell.iconSize)
37+
result.setContentHugging(.horizontal, to: .required)
38+
result.setCompressionResistance(.horizontal, to: .required)
39+
40+
return result
41+
}()
3742
private lazy var infoImageView: UIImageView = {
3843
let result: UIImageView = UIImageView(
3944
image: UIImage(named: "ic_info")?
4045
.withRenderingMode(.alwaysTemplate)
4146
)
4247
result.themeTintColor = .textPrimary
48+
result.set(.width, to: CallMessageCell.iconSize)
49+
result.set(.height, to: CallMessageCell.iconSize)
50+
result.setContentHugging(.horizontal, to: .required)
51+
result.setCompressionResistance(.horizontal, to: .required)
4352

4453
return result
4554
}()
@@ -62,38 +71,25 @@ final class CallMessageCell: MessageCell {
6271
result.textAlignment = .center
6372
result.lineBreakMode = .byWordWrapping
6473
result.numberOfLines = 0
74+
result.setContentHugging(.horizontal, to: .defaultLow)
75+
result.setCompressionResistance(.horizontal, to: .defaultLow)
6576

6677
return result
6778
}()
6879

69-
private lazy var container: UIView = {
70-
let result: UIView = UIView()
80+
private lazy var contentStackView: UIStackView = {
81+
let result: UIStackView = UIStackView(arrangedSubviews: [iconImageView, label, infoImageView])
82+
result.axis = .horizontal
83+
result.alignment = .center
84+
result.spacing = CallMessageCell.horizontalInset
85+
86+
return result
87+
}()
88+
89+
private lazy var container: UIStackView = {
90+
let result: UIStackView = UIStackView()
7191
result.themeBackgroundColor = .backgroundSecondary
7292
result.layer.cornerRadius = 18
73-
result.addSubview(label)
74-
75-
label.pin(.top, to: .top, of: result, withInset: CallMessageCell.verticalInset)
76-
label.pin(
77-
.left,
78-
to: .left,
79-
of: result,
80-
withInset: ((CallMessageCell.horizontalInset * 2) + infoImageView.bounds.size.width)
81-
)
82-
label.pin(
83-
.right,
84-
to: .right,
85-
of: result,
86-
withInset: -((CallMessageCell.horizontalInset * 2) + infoImageView.bounds.size.width)
87-
)
88-
label.pin(.bottom, to: .bottom, of: result, withInset: -CallMessageCell.verticalInset)
89-
90-
result.addSubview(iconImageView)
91-
iconImageView.center(.vertical, in: result)
92-
iconImageView.pin(.left, to: .left, of: result, withInset: CallMessageCell.horizontalInset)
93-
94-
result.addSubview(infoImageView)
95-
infoImageView.center(.vertical, in: result)
96-
infoImageView.pin(.right, to: .right, of: result, withInset: -CallMessageCell.horizontalInset)
9793

9894
return result
9995
}()
@@ -112,10 +108,14 @@ final class CallMessageCell: MessageCell {
112108
override func setUpViewHierarchy() {
113109
super.setUpViewHierarchy()
114110

115-
iconImageViewWidthConstraint.isActive = true
116-
iconImageViewHeightConstraint.isActive = true
111+
container.addSubview(contentStackView)
117112
addSubview(mainStackView)
118113

114+
contentStackView.pin(.top, to: .top, of: container, withInset: CallMessageCell.verticalInset)
115+
contentStackView.pin(.leading, to: .leading, of: container, withInset: CallMessageCell.horizontalInset)
116+
contentStackView.pin(.trailing, to: .trailing, of: container, withInset: -CallMessageCell.horizontalInset)
117+
contentStackView.pin(.bottom, to: .bottom, of: container, withInset: -CallMessageCell.verticalInset)
118+
119119
topConstraint.isActive = true
120120
mainStackView.pin(.left, to: .left, of: self, withInset: CallMessageCell.margin)
121121
mainStackView.pin(.right, to: .right, of: self, withInset: -CallMessageCell.margin)
@@ -130,6 +130,7 @@ final class CallMessageCell: MessageCell {
130130
showExpandedReactions: Bool,
131131
shouldExpanded: Bool,
132132
lastSearchText: String?,
133+
tableSize: CGSize,
133134
using dependencies: Dependencies
134135
) {
135136
guard
@@ -163,8 +164,7 @@ final class CallMessageCell: MessageCell {
163164
default: return nil
164165
}
165166
}()
166-
iconImageViewWidthConstraint.constant = (iconImageView.image != nil ? CallMessageCell.iconSize : 0)
167-
iconImageViewHeightConstraint.constant = (iconImageView.image != nil ? CallMessageCell.iconSize : 0)
167+
iconImageView.isHidden = (iconImageView.image == nil)
168168

169169
let shouldShowInfoIcon: Bool = (
170170
(
@@ -175,8 +175,7 @@ final class CallMessageCell: MessageCell {
175175
Permissions.microphone != .granted
176176
)
177177
)
178-
infoImageViewWidthConstraint.constant = (shouldShowInfoIcon ? CallMessageCell.iconSize : 0)
179-
infoImageViewHeightConstraint.constant = (shouldShowInfoIcon ? CallMessageCell.iconSize : 0)
178+
infoImageView.isHidden = !shouldShowInfoIcon
180179

181180
label.text = cellViewModel.body
182181

Session/Conversations/Message Cells/Content Views/DeletedMessageView.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ final class DeletedMessageView: UIView {
4141
imageView.set(.width, to: DeletedMessageView.iconSize)
4242
imageView.set(.height, to: DeletedMessageView.iconSize)
4343

44+
let imageViewContainer: UIView = UIView()
45+
imageViewContainer.addSubview(imageView)
46+
imageView.center(.vertical, in: imageViewContainer)
47+
imageView.pin(.leading, to: .leading, of: imageViewContainer)
48+
imageView.pin(.trailing, to: .trailing, of: imageViewContainer)
49+
4450
// Body label
4551
let titleLabel = UILabel()
4652
titleLabel.setContentHuggingPriority(.required, for: .vertical)
@@ -57,26 +63,26 @@ final class DeletedMessageView: UIView {
5763
titleLabel.alpha = Values.highOpacity
5864
titleLabel.lineBreakMode = .byTruncatingTail
5965
titleLabel.numberOfLines = 2
66+
titleLabel.setContentHugging(.vertical, to: .required)
67+
titleLabel.setCompressionResistance(.vertical, to: .required)
6068

6169
// Stack view
6270
let stackView = UIStackView(arrangedSubviews: [
63-
imageView,
71+
imageViewContainer,
6472
titleLabel
6573
])
6674
stackView.axis = .horizontal
67-
stackView.alignment = .center
75+
stackView.alignment = .fill
6876
stackView.spacing = Values.smallSpacing
6977
stackView.isLayoutMarginsRelativeArrangement = true
7078
stackView.layoutMargins = UIEdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 6)
7179
addSubview(stackView)
7280

73-
let calculatedSize: CGSize = stackView.systemLayoutSizeFitting(CGSize(width: maxWidth, height: 999))
74-
7581
stackView.pin(.top, to: .top, of: self, withInset: Self.verticalInset)
7682
stackView.pin(.leading, to: .leading, of: self, withInset: Self.horizontalInset)
7783
stackView.pin(.trailing, to: .trailing, of: self, withInset: -Self.horizontalInset)
7884
stackView.pin(.bottom, to: .bottom, of: self, withInset: -Self.verticalInset)
79-
80-
stackView.set(.height, greaterThanOrEqualTo: calculatedSize.height)
85+
stackView.setContentHugging(.vertical, to: .required)
86+
stackView.setCompressionResistance(.vertical, to: .required)
8187
}
8288
}

Session/Conversations/Message Cells/Content Views/MediaLoaderView.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import SessionUIKit
55

66
final class MediaLoaderView: UIView {
77
private let bar = UIView()
8+
private var cachedWidth: CGFloat = 0
89

910
private lazy var barLeftConstraint = bar.pin(.left, to: .left, of: self)
10-
private lazy var barRightConstraint = bar.pin(.right, to: .right, of: self)
11+
private lazy var barRightConstraint = bar
12+
.pin(.right, to: .right, of: self)
13+
.setting(priority: .defaultHigh)
1114

1215
// MARK: - Lifecycle
1316

@@ -30,14 +33,22 @@ final class MediaLoaderView: UIView {
3033
barLeftConstraint.isActive = true
3134
bar.pin(.top, to: .top, of: self)
3235
barRightConstraint.isActive = true
33-
bar.pin(.bottom, to: .bottom, of: self)
36+
bar.pin(.bottom, to: .bottom, of: self).setting(priority: .defaultHigh)
3437
step1()
3538
}
3639

40+
override func layoutSubviews() {
41+
super.layoutSubviews()
42+
43+
if cachedWidth != bounds.width {
44+
cachedWidth = bounds.width
45+
}
46+
}
47+
3748
// MARK: - Animation
3849

3950
func step1() {
40-
barRightConstraint.constant = -bounds.width
51+
barRightConstraint.constant = -cachedWidth
4152
UIView.animate(withDuration: 0.5, animations: { [weak self] in
4253
guard let self = self else { return }
4354
self.barRightConstraint.constant = 0
@@ -51,7 +62,7 @@ final class MediaLoaderView: UIView {
5162
barLeftConstraint.constant = 0
5263
UIView.animate(withDuration: 0.5, animations: { [weak self] in
5364
guard let self = self else { return }
54-
self.barLeftConstraint.constant = self.bounds.width
65+
self.barLeftConstraint.constant = cachedWidth
5566
self.layoutIfNeeded()
5667
}, completion: { [weak self] _ in
5768
Timer.scheduledTimer(withTimeInterval: 0.25, repeats: false) { _ in
@@ -75,7 +86,7 @@ final class MediaLoaderView: UIView {
7586
barRightConstraint.constant = 0
7687
UIView.animate(withDuration: 0.5, animations: { [weak self] in
7788
guard let self = self else { return }
78-
self.barRightConstraint.constant = -self.bounds.width
89+
self.barRightConstraint.constant = -cachedWidth
7990
self.layoutIfNeeded()
8091
}, completion: { [weak self] _ in
8192
Timer.scheduledTimer(withTimeInterval: 0.25, repeats: false) { _ in

Session/Conversations/Message Cells/Content Views/MediaView.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ public class MediaView: UIView {
117117
let result: GradientView = GradientView()
118118
result.themeBackgroundGradient = [
119119
.value(.black, alpha: 0),
120-
.value(.black, alpha: 0.4)
120+
.value(.black, alpha: 0.75),
121+
.value(.black, alpha: 0.75)
121122
]
122123
result.isHidden = true
123124

@@ -129,7 +130,6 @@ public class MediaView: UIView {
129130
result.font = .systemFont(ofSize: Values.smallFontSize)
130131
result.text = attachment.duration.map { Format.duration($0) }
131132
result.themeTextColor = .white
132-
result.isHidden = true
133133

134134
return result
135135
}()
@@ -162,14 +162,12 @@ public class MediaView: UIView {
162162
errorIconView.center(in: self)
163163

164164
addSubview(durationBackgroundView)
165-
durationBackgroundView.set(.height, to: 40)
166165
durationBackgroundView.pin(.leading, to: .leading, of: imageView)
167166
durationBackgroundView.pin(.trailing, to: .trailing, of: imageView)
168167
durationBackgroundView.pin(.bottom, to: .bottom, of: imageView)
169168

170-
addSubview(durationLabel)
171-
durationLabel.pin(.trailing, to: .trailing, of: imageView, withInset: -Values.smallSpacing)
172-
durationLabel.pin(.bottom, to: .bottom, of: imageView, withInset: -Values.smallSpacing)
169+
durationBackgroundView.addSubview(durationLabel)
170+
durationLabel.pin(to: durationBackgroundView, withInset: Values.smallSpacing)
173171

174172
addSubview(playButtonIcon)
175173
playButtonIcon.set(.width, to: 72)
@@ -215,13 +213,12 @@ public class MediaView: UIView {
215213
!loadingIndicator.isHidden ||
216214
!attachment.isVideo
217215
)
218-
durationLabel.isHidden = (
216+
durationBackgroundView.isHidden = (
219217
shouldSupressControls ||
220218
attachment.duration == nil ||
221219
!loadingIndicator.isHidden ||
222220
!attachment.isVideo
223221
)
224-
durationBackgroundView.isHidden = durationLabel.isHidden
225222
}
226223

227224
@MainActor

Session/Conversations/Message Cells/Content Views/QuoteView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ final class QuoteView: UIView {
9090
mainStackView.isLayoutMarginsRelativeArrangement = true
9191
mainStackView.layoutMargins = UIEdgeInsets(top: 0, leading: 0, bottom: 0, trailing: smallSpacing)
9292
mainStackView.alignment = .center
93+
mainStackView.setCompressionResistance(.vertical, to: .required)
9394

9495
// Content view
9596
let contentView = UIView()
@@ -220,13 +221,15 @@ final class QuoteView: UIView {
220221
authorLabel.lineBreakMode = .byTruncatingTail
221222
authorLabel.isHidden = (authorLabel.text == nil)
222223
authorLabel.numberOfLines = 1
224+
authorLabel.setCompressionResistance(.vertical, to: .required)
223225

224226
let labelStackView = UIStackView(arrangedSubviews: [ authorLabel, bodyLabel ])
225227
labelStackView.axis = .vertical
226228
labelStackView.spacing = labelStackViewSpacing
227229
labelStackView.distribution = .equalCentering
228230
labelStackView.isLayoutMarginsRelativeArrangement = true
229231
labelStackView.layoutMargins = UIEdgeInsets(top: labelStackViewVMargin, left: 0, bottom: labelStackViewVMargin, right: 0)
232+
labelStackView.setCompressionResistance(.vertical, to: .required)
230233
mainStackView.addArrangedSubview(labelStackView)
231234

232235
// Constraints

Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ final class ReactionContainerView: UIView {
107107

108108
mainStackView.pin(.top, to: .top, of: self)
109109
mainStackView.pin(.leading, to: .leading, of: self)
110-
mainStackView.pin(.trailing, to: .trailing, of: self)
110+
mainStackView.pin(.trailing, to: .trailing, of: self).setting(priority: .defaultHigh)
111111
mainStackView.pin(.bottom, to: .bottom, of: self, withInset: -Values.verySmallSpacing)
112112
reactionContainerView.set(.width, to: .width, of: mainStackView)
113113
collapseButton.set(.width, to: .width, of: mainStackView)
@@ -125,6 +125,8 @@ final class ReactionContainerView: UIView {
125125
self.reactionViews = []
126126
self.reactionContainerView.arrangedSubviews.forEach { $0.removeFromSuperview() }
127127

128+
guard !reactions.isEmpty else { return }
129+
128130
let collapsedCount: Int = {
129131
// If there are already more than 'maxEmojiBeforeCollapse' then no need to calculate, just
130132
// always collapse

Session/Conversations/Message Cells/Content Views/ReactionView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,6 @@ final class ExpandingReactionButton: UIView {
152152
rightMargin += margin
153153
}
154154

155-
set(.width, to: rightMargin - margin + size)
155+
set(.width, to: rightMargin - margin + size).setting(priority: .defaultHigh)
156156
}
157157
}

Session/Conversations/Message Cells/DateHeaderCell.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ final class DateHeaderCell: MessageCell {
4545
showExpandedReactions: Bool,
4646
shouldExpanded: Bool,
4747
lastSearchText: String?,
48+
tableSize: CGSize,
4849
using dependencies: Dependencies
4950
) {
5051
guard cellViewModel.cellType == .dateHeader else { return }

0 commit comments

Comments
 (0)