Skip to content

Commit bf08cd0

Browse files
authored
fix: update self-deleting system message - WPB-21395 (#4186)
1 parent f984f3d commit bf08cd0

File tree

6 files changed

+47
-16
lines changed

6 files changed

+47
-16
lines changed
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

wire-ios/Wire-iOS/Sources/Helpers/DynamicFontLabel.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,21 @@ class DynamicFontLabel: UILabel, DynamicTypeCapable {
4545
self.adjustsFontForContentSizeCategory = true
4646
}
4747

48-
@available(*, deprecated, message: "Use `init(text:style:color)` instead")
48+
init(
49+
attributedText: NSAttributedString,
50+
style: WireTextStyle = .body1,
51+
color: UIColor
52+
) {
53+
// Not needed when we use a font style.
54+
self.onRedrawFont = { nil }
55+
super.init(frame: .zero)
56+
self.attributedText = attributedText
57+
self.textColor = color
58+
self.font = .font(for: style)
59+
self.adjustsFontForContentSizeCategory = true
60+
}
61+
62+
@available(*, deprecated, message: "Use `init(text:style:color)` or `init(attributedText:style:color)` instead")
4963
init(
5064
text: String? = nil,
5165
fontSpec: FontSpec = .normalRegularFont,

wire-ios/Wire-iOS/Sources/UserInterface/Conversation/Content/Cells/ConfigurationMessageCell/Components/ConversationFileCollaborationSystemMessageCellDescription.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import WireDesign
2323

2424
final class ConversationFileCollaborationSystemMessageCellDescription: ConversationMessageCellDescription {
2525

26-
typealias View = ConversationSystemMessageCell<ConversationFileCollaborationSystemMessageCellDescription>
26+
typealias View = ConversationWarningSystemMessageCell<ConversationFileCollaborationSystemMessageCellDescription>
2727
typealias LabelColors = SemanticColors.Label
2828
typealias IconColors = SemanticColors.Icon
2929

@@ -59,7 +59,11 @@ final class ConversationFileCollaborationSystemMessageCellDescription: Conversat
5959
attributedText.addAttribute(.font, value: UIFont.mediumSemiboldFont, range: nsRange)
6060
}
6161

62-
self.configuration = View.Configuration(icon: icon, attributedText: attributedText, showLine: false)
62+
self.configuration = View.Configuration(
63+
icon: icon,
64+
topText: NSAttributedString(string: ""),
65+
bottomText: attributedText,
66+
)
6367
self.accessibilityLabel = attributedText.string
6468
self.actionController = nil
6569
}

wire-ios/Wire-iOS/Sources/UserInterface/Conversation/Content/Cells/ConfigurationMessageCell/Components/ConversationMessageTimerSystemMessageCellDescription.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import WireDesign
2323

2424
final class ConversationMessageTimerSystemMessageCellDescription: ConversationMessageCellDescription {
2525

26-
typealias View = ConversationSystemMessageCell<ConversationMessageTimerSystemMessageCellDescription>
26+
typealias View = ConversationWarningSystemMessageCell<ConversationMessageTimerSystemMessageCellDescription>
2727
typealias LabelColors = SemanticColors.Label
2828
typealias IconColors = SemanticColors.Icon
2929

@@ -82,7 +82,11 @@ final class ConversationMessageTimerSystemMessageCellDescription: ConversationMe
8282

8383
typealias LabelColors = SemanticColors.Label
8484
let icon = StyleKitIcon.hourglass.makeImage(size: 16, color: IconColors.backgroundDefault)
85-
self.configuration = View.Configuration(icon: icon, attributedText: updateText, showLine: false)
85+
self.configuration = View.Configuration(
86+
icon: icon,
87+
topText: NSAttributedString(string: ""),
88+
bottomText: updateText ?? NSAttributedString(string: "")
89+
)
8690
self.accessibilityLabel = updateText?.string
8791
self.actionController = nil
8892
}

wire-ios/Wire-iOS/Sources/UserInterface/Conversation/Content/Cells/ConfigurationMessageCell/Components/ConversationWarningSystemMessageCell.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,26 @@ final class ConversationWarningSystemMessageCell<
2828
private typealias IconColors = SemanticColors.Icon
2929

3030
struct Configuration: Equatable {
31-
let topText: String
32-
let bottomText: String
31+
let icon: UIImage?
32+
let topText: NSAttributedString
33+
let bottomText: NSAttributedString
3334
}
3435

3536
private let encryptionLabel = DynamicFontLabel(
37+
attributedText: NSAttributedString(string: ""),
3638
style: .subline1,
3739
color: LabelColors.textDefault
3840
)
3941
private let sensitiveInfoLabel = DynamicFontLabel(
42+
attributedText: NSAttributedString(string: ""),
4043
style: .subline1,
4144
color: LabelColors.textDefault
4245
)
4346

4447
func configure(with object: Configuration, animated: Bool) {
45-
encryptionLabel.text = object.topText
46-
sensitiveInfoLabel.text = object.bottomText
48+
encryptionLabel.attributedText = object.topText
49+
sensitiveInfoLabel.attributedText = object.bottomText
50+
imageView.image = object.icon
4751
}
4852

4953
override func configureSubviews() {
@@ -57,14 +61,19 @@ final class ConversationWarningSystemMessageCell<
5761
bottomContentView.addSubview(sensitiveInfoLabel)
5862

5963
lineView.isHidden = true
60-
imageView.image = .init(resource: .attention)
6164
imageView.tintColor = IconColors.backgroundDefault
6265
}
6366

6467
override func configureConstraints() {
6568
super.configureConstraints()
66-
encryptionLabel.fitIn(view: topContentView)
67-
sensitiveInfoLabel.fitIn(view: bottomContentView)
69+
let padding: CGFloat = 6.0
70+
71+
encryptionLabel.fitIn(view: topContentView, insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: padding))
72+
sensitiveInfoLabel.fitIn(
73+
view: bottomContentView,
74+
insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: padding)
75+
)
76+
6877
NSLayoutConstraint.activate([
6978
imageContainer.topAnchor.constraint(equalTo: bottomContentView.topAnchor).withPriority(.required)
7079
])

0 commit comments

Comments
 (0)