Skip to content

Commit 90eeabf

Browse files
committed
Run SwiftFormat and fix SwiftLint.
1 parent ed73853 commit 90eeabf

15 files changed

+54
-46
lines changed

compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public struct CompoundButtonStyle_Previews: PreviewProvider, TestablePreview {
306306
.foregroundStyle(.compound.textSecondary)
307307
.frame(maxWidth: .infinity, alignment: .leading)
308308
.padding([.leading, .top])
309-
.padding(.leading )
309+
.padding(.leading)
310310
}
311311
}
312312
}

compound-ios/Sources/Compound/Buttons/SendButton.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright 2024 New Vector Ltd
33
//
44
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial

compound-ios/Sources/Compound/Colors/CompoundColors.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class CompoundColors {
3333
private var overrides = [KeyPath<CompoundColorTokens, Color>: Color]()
3434

3535
public subscript(dynamicMember keyPath: KeyPath<CompoundColorTokens, Color>) -> Color {
36-
return overrides[keyPath] ?? tokens[keyPath: keyPath]
36+
overrides[keyPath] ?? tokens[keyPath: keyPath]
3737
}
3838

3939
/// Customise the colour at the specified key path with the supplied colour.
@@ -47,16 +47,17 @@ public class CompoundColors {
4747
self.tokens = tokens
4848

4949
decorativeColors = [
50-
.init(background: tokens.bgDecorative1, text: tokens.textDecorative1),
51-
.init(background: tokens.bgDecorative2, text: tokens.textDecorative2),
52-
.init(background: tokens.bgDecorative3, text: tokens.textDecorative3),
53-
.init(background: tokens.bgDecorative4, text: tokens.textDecorative4),
54-
.init(background: tokens.bgDecorative5, text: tokens.textDecorative5),
55-
.init(background: tokens.bgDecorative6, text: tokens.textDecorative6),
56-
]
50+
.init(background: tokens.bgDecorative1, text: tokens.textDecorative1),
51+
.init(background: tokens.bgDecorative2, text: tokens.textDecorative2),
52+
.init(background: tokens.bgDecorative3, text: tokens.textDecorative3),
53+
.init(background: tokens.bgDecorative4, text: tokens.textDecorative4),
54+
.init(background: tokens.bgDecorative5, text: tokens.textDecorative5),
55+
.init(background: tokens.bgDecorative6, text: tokens.textDecorative6)
56+
]
5757
}
5858

5959
// MARK: - Decorative Colors
60+
6061
// Used to determine the background and text colors of avatars, usernames etc.
6162

6263
let decorativeColors: [DecorativeColor]
@@ -67,6 +68,7 @@ public class CompoundColors {
6768

6869
// MARK: - Awaiting Semantic Tokens
6970

71+
// swiftformat:disable numberFormatting
7072
/// This token is a placeholder and hasn't been finalised.
7173
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
7274
public let _borderTextFieldFocused = coreTokens.gray500
@@ -91,6 +93,7 @@ public class CompoundColors {
9193
/// This token is a placeholder and hasn't been finalised.
9294
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
9395
public let _bgEmptyItemAlpha = coreTokens.alphaGray500
96+
// swiftformat:enable numberFormatting
9497
}
9598

9699
private extension UITraitCollection {
@@ -107,9 +110,9 @@ private extension String {
107110
/// Calculates a numeric hash same as Element Web
108111
/// See original function here https://github.com/matrix-org/matrix-react-sdk/blob/321dd49db4fbe360fc2ff109ac117305c955b061/src/utils/FormattingUtils.js#L47
109112
var hashCode: Int {
110-
let characterCodeSum = self.reduce(0) { sum, character in
113+
let characterCodeSum = reduce(0) { sum, character in
111114
sum + Int(character.unicodeScalars.first?.value ?? 0)
112115
}
113-
return (characterCodeSum % Color.compound.decorativeColors.count)
116+
return characterCodeSum % Color.compound.decorativeColors.count
114117
}
115118
}

compound-ios/Sources/Compound/Colors/CompoundGradients.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright 2025 New Vector Ltd
33
//
44
// SPDX-License-Identifier: AGPL-3.0-only

compound-ios/Sources/Compound/Colors/CompoundUIColors.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CompoundUIColors {
2828
private var overrides = [KeyPath<CompoundUIColorTokens, UIColor>: UIColor]()
2929

3030
public subscript(dynamicMember keyPath: KeyPath<CompoundUIColorTokens, UIColor>) -> UIColor {
31-
return overrides[keyPath] ?? tokens[keyPath: keyPath]
31+
overrides[keyPath] ?? tokens[keyPath: keyPath]
3232
}
3333

3434
/// Customise the colour at the specified key path with the supplied colour.
@@ -39,12 +39,14 @@ public class CompoundUIColors {
3939

4040
// MARK: - Awaiting Semantic Tokens
4141

42+
// swiftformat:disable numberFormatting
4243
/// This token is a placeholder and hasn't been finalised.
4344
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
4445
public let _bgCodeBlock = coreTokens.gray100
4546
/// This token is a placeholder and hasn't been finalised.
4647
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
4748
public let _bgSubtleSecondaryAlpha = coreTokens.alphaGray300
49+
// swiftformat:enable numberFormatting
4850
}
4951

5052
private extension UITraitCollection {

compound-ios/Sources/Compound/Icons/CompoundIcon.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public struct CompoundIcon: View {
5252
/// - icon: The icon to show.
5353
public init(_ icon: KeyPath<CompoundIcons, Image>) {
5454
image = .compound[keyPath: icon]
55-
self.size = .medium
56-
self.font = .compound.bodyLG
55+
size = .medium
56+
font = .compound.bodyLG
5757
}
5858

5959
/// Creates an icon using a key path from the Compound tokens.
@@ -78,8 +78,8 @@ public struct CompoundIcon: View {
7878
/// ** Note:** The image should have a square frame or it may end up distorted.
7979
public init(customImage: Image) {
8080
image = customImage
81-
self.size = .medium
82-
self.font = .compound.bodyLG
81+
size = .medium
82+
font = .compound.bodyLG
8383
}
8484

8585
/// Creates an icon using a custom image to allow assets from outside
@@ -180,7 +180,6 @@ struct CompoundIcon_Previews: PreviewProvider, TestablePreview {
180180
}
181181
}
182182

183-
184183
static var accessibilityLabels: some View {
185184
Grid(alignment: .leading) {
186185
ForEach(DynamicTypeSize.allCases, id: \.self) {

compound-ios/Sources/Compound/Layout/ScaledOffsetModifier.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ private struct ScaledOffsetModifier: ViewModifier {
2828
}
2929
}
3030

31-
3231
// MARK: - Previews
3332

3433
struct ScaledOffsetModifier_Previews: PreviewProvider, TestablePreview {

compound-ios/Sources/Compound/List/ListInlinePicker.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ struct ListInlinePicker<SelectedValue: Hashable>: View {
1818
ListRow(label: .plain(title: item.title),
1919
details: isWaiting ? .isWaiting(selection == item.tag) : nil,
2020
kind: .selection(isSelected: !isWaiting ? selection == item.tag : false) {
21-
var transaction = Transaction()
22-
transaction.disablesAnimations = true
21+
var transaction = Transaction()
22+
transaction.disablesAnimations = true
2323

24-
withTransaction(transaction) {
25-
selection = item.tag
26-
}
27-
})
24+
withTransaction(transaction) {
25+
selection = item.tag
26+
}
27+
})
2828
}
2929
}
3030
}

compound-ios/Sources/Compound/List/ListRow.swift

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ public extension ListRow where DetailsIcon == EmptyView, CustomContent == EmptyV
184184
// Custom row without a label or details label.
185185
public extension ListRow where Icon == EmptyView, DetailsIcon == EmptyView {
186186
init(kind: Kind<CustomContent, SelectionValue>) {
187-
self.label = ListRowLabel()
188-
self.details = nil
187+
label = ListRowLabel()
188+
details = nil
189189
self.kind = kind
190190
}
191191

192192
init(kind: Kind<CustomContent, SelectionValue>) where SelectionValue == String {
193-
self.label = ListRowLabel()
194-
self.details = nil
193+
label = ListRowLabel()
194+
details = nil
195195
self.kind = kind
196196
}
197197
}
@@ -249,6 +249,7 @@ private extension Button {
249249

250250
// MARK: - Previews
251251

252+
// swiftlint:disable print_deprecation
252253
public struct ListRow_Previews: PreviewProvider, TestablePreview {
253254
public static var previews: some View {
254255
Form {
@@ -348,14 +349,14 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
348349
systemIcon: .squareDashed),
349350
details: .title("Content"),
350351
kind: .selection(isSelected: true) {
351-
print("I was tapped!")
352-
})
352+
print("I was tapped!")
353+
})
353354
ListRow(label: .default(title: "Title",
354355
systemIcon: .squareDashed),
355356
details: .title("Content"),
356357
kind: .selection(isSelected: true) {
357-
print("I was tapped!")
358-
})
358+
print("I was tapped!")
359+
})
359360

360361
ListRow(label: .plain(title: "Title"),
361362
kind: .inlinePicker(selection: .constant("Item 1"),
@@ -375,7 +376,7 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
375376
ListRow(label: .action(title: "Title",
376377
systemIcon: .squareDashed),
377378
kind: .button { print("I was tapped!") })
378-
.disabled(true)
379+
.disabled(true)
379380
}
380381

381382
static var plainButton: some View {
@@ -401,7 +402,7 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
401402
ListRow(label: .centeredAction(title: "Title",
402403
systemIcon: .squareDashed),
403404
kind: .button { print("I was tapped!") })
404-
.disabled(true)
405+
.disabled(true)
405406
}
406407
}
407408

@@ -445,10 +446,10 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
445446
})
446447
ListRow(label: .plain(title: "Placeholder"),
447448
kind: .textField(text: .constant("This is a disabled text field")))
448-
.disabled(true)
449+
.disabled(true)
449450
ListRow(label: .plain(title: "Placeholder"),
450451
kind: .textField(text: .constant(""), axis: .vertical))
451-
.lineLimit(4...)
452+
.lineLimit(4...)
452453
ListRow(label: .plain(title: "Password"),
453454
kind: .secureField(text: .constant("p4ssw0rd")))
454455
}
@@ -474,3 +475,5 @@ struct ListRowLoadingSelection_Previews: PreviewProvider, TestablePreview {
474475
.compoundList()
475476
}
476477
}
478+
479+
// swiftlint:enable print_deprecation

compound-ios/Sources/Compound/List/ListRowAccessory.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public struct ListRowAccessory: View {
2626

2727
/// A chevron to indicate that the button pushes another screen.
2828
public static var navigationLink: Self {
29-
Self.init(kind: .navigationLink)
29+
Self(kind: .navigationLink)
3030
}
3131

3232
/// A checkmark (or reserved space) to indicate that the row is selected.
3333
public static func selection(_ isSelected: Bool) -> Self {
34-
Self.init(kind: isSelected ? .selected : .unselected)
34+
Self(kind: isSelected ? .selected : .unselected)
3535
}
3636

3737
/// A circular checkmark (or empty circle) to indicate that the row is one of multiple selected.
3838
public static func multiSelection(_ isSelected: Bool) -> Self {
39-
Self.init(kind: isSelected ? .multiSelected : .multiUnselected)
39+
Self(kind: isSelected ? .multiSelected : .multiUnselected)
4040
}
4141

4242
let kind: Kind

0 commit comments

Comments
 (0)