Skip to content

Commit c264e9e

Browse files
authored
Use the UIColors directly instead of wrapping the SwiftUI Colors. (#3324)
1 parent d736812 commit c264e9e

File tree

8 files changed

+21
-11
lines changed

8 files changed

+21
-11
lines changed

.swiftlint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ custom_rules:
6060
message: "Please use explicit spacing in HStacks."
6161
severity: warning
6262

63+
compound_color_conversion:
64+
regex: "UIColor\\(\\.compound"
65+
match_kinds: identifier
66+
message: "Please use the UIColor token directly to ensure the colour scheme is honoured."
67+
severity: warning
68+
6369
print_deprecation:
6470
regex: "\\b(print)\\b"
6571
match_kinds: identifier

ElementX.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7887,7 +7887,7 @@
78877887
repositoryURL = "https://github.com/element-hq/compound-ios";
78887888
requirement = {
78897889
kind = revision;
7890-
revision = 0d6248492aa577b3747a34c50104cc738b628478;
7890+
revision = 92110afc158ac6ee7c68d5e975144bafa6c58396;
78917891
};
78927892
};
78937893
F76A08D0EA29A07A54F4EB4D /* XCRemoteSwiftPackageReference "swift-collections" */ = {

ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Please see LICENSE in the repository root for full details.
66
//
77

8+
import Compound
89
import DTCoreText
910
import Foundation
1011
import LRUCache
@@ -267,7 +268,7 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
267268
attributedString.enumerateAttribute(.backgroundColor, in: .init(location: 0, length: attributedString.length), options: []) { value, range, _ in
268269
if let value = value as? UIColor,
269270
value == temporaryCodeBlockMarkingColor {
270-
attributedString.addAttribute(.backgroundColor, value: UIColor(.compound._bgCodeBlock) as Any, range: range)
271+
attributedString.addAttribute(.backgroundColor, value: UIColor.compound._bgCodeBlock as Any, range: range)
271272
attributedString.removeAttribute(.link, range: range)
272273
}
273274
}

ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// SPDX-License-Identifier: AGPL-3.0-only
55
// Please see LICENSE in the repository root for full details.
66
//
7+
8+
import Compound
79
import SwiftUI
810

911
struct MessageComposerTextField: View {
@@ -96,7 +98,7 @@ private struct UITextViewWrapper: UIViewRepresentable {
9698
func updateUIView(_ textView: UITextView, context: UIViewRepresentableContext<UITextViewWrapper>) {
9799
// Prevent the textView from inheriting attributes from mention pills
98100
textView.typingAttributes = [.font: font,
99-
.foregroundColor: UIColor(.compound.textPrimary)]
101+
.foregroundColor: UIColor.compound.textPrimary]
100102

101103
if textView.attributedText != text {
102104
// Remember the selection if only the attributes have changed.
@@ -311,7 +313,7 @@ struct MessageComposerTextField_Previews: PreviewProvider, TestablePreview {
311313

312314
init(text: String) {
313315
_text = .init(initialValue: .init(string: text, attributes: [.font: UIFont.preferredFont(forTextStyle: .body),
314-
.foregroundColor: UIColor(.compound.textPrimary)]))
316+
.foregroundColor: UIColor.compound.textPrimary]))
315317
}
316318

317319
var body: some View {

ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import Combine
9+
import Compound
910
import HTMLParser
1011
import SwiftUI
1112
import WysiwygComposer
@@ -207,14 +208,14 @@ enum ComposerConstant {
207208
private extension HTMLParserStyle {
208209
static let elementX = HTMLParserStyle(textColor: UIColor.label,
209210
linkColor: UIColor.link,
210-
codeBlockStyle: BlockStyle(backgroundColor: UIColor(.compound._bgCodeBlock),
211-
borderColor: UIColor(.compound.borderInteractiveSecondary),
211+
codeBlockStyle: BlockStyle(backgroundColor: UIColor.compound._bgCodeBlock,
212+
borderColor: UIColor.compound.borderInteractiveSecondary,
212213
borderWidth: 1.0,
213214
cornerRadius: 2.0,
214215
padding: BlockStyle.Padding(horizontal: 10, vertical: 12),
215216
type: .background),
216-
quoteBlockStyle: BlockStyle(backgroundColor: UIColor(.compound.iconTertiary),
217-
borderColor: UIColor(.compound.borderInteractiveSecondary),
217+
quoteBlockStyle: BlockStyle(backgroundColor: UIColor.compound.iconTertiary,
218+
borderColor: UIColor.compound.borderInteractiveSecondary,
218219
borderWidth: 0.0,
219220
cornerRadius: 0.0,
220221
padding: BlockStyle.Padding(horizontal: 25, vertical: 12),

ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class TimelineTableViewController: UIViewController {
173173
tableView.separatorStyle = .none
174174
tableView.allowsSelection = false
175175
tableView.keyboardDismissMode = .onDrag
176-
tableView.backgroundColor = UIColor(.compound.bgCanvasDefault)
176+
tableView.backgroundColor = .compound.bgCanvasDefault
177177
tableView.transform = CGAffineTransform(scaleX: 1, y: -1)
178178
view.addSubview(tableView)
179179

project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ packages:
6464
# path: ../matrix-rust-sdk
6565
Compound:
6666
url: https://github.com/element-hq/compound-ios
67-
revision: 0d6248492aa577b3747a34c50104cc738b628478
67+
revision: 92110afc158ac6ee7c68d5e975144bafa6c58396
6868
# path: ../compound-ios
6969
AnalyticsEvents:
7070
url: https://github.com/matrix-org/matrix-analytics-events

0 commit comments

Comments
 (0)