diff --git a/compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift b/compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift index d8d46d02c..e1fb580b8 100644 --- a/compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift +++ b/compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift @@ -306,7 +306,7 @@ public struct CompoundButtonStyle_Previews: PreviewProvider, TestablePreview { .foregroundStyle(.compound.textSecondary) .frame(maxWidth: .infinity, alignment: .leading) .padding([.leading, .top]) - .padding(.leading ) + .padding(.leading) } } } diff --git a/compound-ios/Sources/Compound/Buttons/SendButton.swift b/compound-ios/Sources/Compound/Buttons/SendButton.swift index 043486612..80792bbba 100644 --- a/compound-ios/Sources/Compound/Buttons/SendButton.swift +++ b/compound-ios/Sources/Compound/Buttons/SendButton.swift @@ -1,4 +1,4 @@ -// +// // Copyright 2024 New Vector Ltd // // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial diff --git a/compound-ios/Sources/Compound/Colors/CompoundColors.swift b/compound-ios/Sources/Compound/Colors/CompoundColors.swift index 985ae43a2..83795ab14 100644 --- a/compound-ios/Sources/Compound/Colors/CompoundColors.swift +++ b/compound-ios/Sources/Compound/Colors/CompoundColors.swift @@ -33,7 +33,7 @@ public class CompoundColors { private var overrides = [KeyPath: Color]() public subscript(dynamicMember keyPath: KeyPath) -> Color { - return overrides[keyPath] ?? tokens[keyPath: keyPath] + overrides[keyPath] ?? tokens[keyPath: keyPath] } /// Customise the colour at the specified key path with the supplied colour. @@ -47,16 +47,17 @@ public class CompoundColors { self.tokens = tokens decorativeColors = [ - .init(background: tokens.bgDecorative1, text: tokens.textDecorative1), - .init(background: tokens.bgDecorative2, text: tokens.textDecorative2), - .init(background: tokens.bgDecorative3, text: tokens.textDecorative3), - .init(background: tokens.bgDecorative4, text: tokens.textDecorative4), - .init(background: tokens.bgDecorative5, text: tokens.textDecorative5), - .init(background: tokens.bgDecorative6, text: tokens.textDecorative6), - ] + .init(background: tokens.bgDecorative1, text: tokens.textDecorative1), + .init(background: tokens.bgDecorative2, text: tokens.textDecorative2), + .init(background: tokens.bgDecorative3, text: tokens.textDecorative3), + .init(background: tokens.bgDecorative4, text: tokens.textDecorative4), + .init(background: tokens.bgDecorative5, text: tokens.textDecorative5), + .init(background: tokens.bgDecorative6, text: tokens.textDecorative6) + ] } // MARK: - Decorative Colors + // Used to determine the background and text colors of avatars, usernames etc. let decorativeColors: [DecorativeColor] @@ -67,6 +68,7 @@ public class CompoundColors { // MARK: - Awaiting Semantic Tokens + // swiftformat:disable numberFormatting /// This token is a placeholder and hasn't been finalised. @available(iOS, deprecated: 100000.0, message: "This token should be generated by now.") public let _borderTextFieldFocused = coreTokens.gray500 @@ -91,6 +93,7 @@ public class CompoundColors { /// This token is a placeholder and hasn't been finalised. @available(iOS, deprecated: 100000.0, message: "This token should be generated by now.") public let _bgEmptyItemAlpha = coreTokens.alphaGray500 + // swiftformat:enable numberFormatting } private extension UITraitCollection { @@ -107,9 +110,9 @@ private extension String { /// Calculates a numeric hash same as Element Web /// See original function here https://github.com/matrix-org/matrix-react-sdk/blob/321dd49db4fbe360fc2ff109ac117305c955b061/src/utils/FormattingUtils.js#L47 var hashCode: Int { - let characterCodeSum = self.reduce(0) { sum, character in + let characterCodeSum = reduce(0) { sum, character in sum + Int(character.unicodeScalars.first?.value ?? 0) } - return (characterCodeSum % Color.compound.decorativeColors.count) + return characterCodeSum % Color.compound.decorativeColors.count } } diff --git a/compound-ios/Sources/Compound/Colors/CompoundGradients.swift b/compound-ios/Sources/Compound/Colors/CompoundGradients.swift index 283a9e1f0..d51cd08aa 100644 --- a/compound-ios/Sources/Compound/Colors/CompoundGradients.swift +++ b/compound-ios/Sources/Compound/Colors/CompoundGradients.swift @@ -1,4 +1,4 @@ -// +// // Copyright 2025 New Vector Ltd // // SPDX-License-Identifier: AGPL-3.0-only diff --git a/compound-ios/Sources/Compound/Colors/CompoundUIColors.swift b/compound-ios/Sources/Compound/Colors/CompoundUIColors.swift index 6ecae1423..0b5487761 100644 --- a/compound-ios/Sources/Compound/Colors/CompoundUIColors.swift +++ b/compound-ios/Sources/Compound/Colors/CompoundUIColors.swift @@ -28,7 +28,7 @@ public class CompoundUIColors { private var overrides = [KeyPath: UIColor]() public subscript(dynamicMember keyPath: KeyPath) -> UIColor { - return overrides[keyPath] ?? tokens[keyPath: keyPath] + overrides[keyPath] ?? tokens[keyPath: keyPath] } /// Customise the colour at the specified key path with the supplied colour. @@ -39,12 +39,14 @@ public class CompoundUIColors { // MARK: - Awaiting Semantic Tokens + // swiftformat:disable numberFormatting /// This token is a placeholder and hasn't been finalised. @available(iOS, deprecated: 100000.0, message: "This token should be generated by now.") public let _bgCodeBlock = coreTokens.gray100 /// This token is a placeholder and hasn't been finalised. @available(iOS, deprecated: 100000.0, message: "This token should be generated by now.") public let _bgSubtleSecondaryAlpha = coreTokens.alphaGray300 + // swiftformat:enable numberFormatting } private extension UITraitCollection { diff --git a/compound-ios/Sources/Compound/Icons/CompoundIcon.swift b/compound-ios/Sources/Compound/Icons/CompoundIcon.swift index 8577e0078..3b600a2ab 100644 --- a/compound-ios/Sources/Compound/Icons/CompoundIcon.swift +++ b/compound-ios/Sources/Compound/Icons/CompoundIcon.swift @@ -52,8 +52,8 @@ public struct CompoundIcon: View { /// - icon: The icon to show. public init(_ icon: KeyPath) { image = .compound[keyPath: icon] - self.size = .medium - self.font = .compound.bodyLG + size = .medium + font = .compound.bodyLG } /// Creates an icon using a key path from the Compound tokens. @@ -78,8 +78,8 @@ public struct CompoundIcon: View { /// ** Note:** The image should have a square frame or it may end up distorted. public init(customImage: Image) { image = customImage - self.size = .medium - self.font = .compound.bodyLG + size = .medium + font = .compound.bodyLG } /// Creates an icon using a custom image to allow assets from outside @@ -180,7 +180,6 @@ struct CompoundIcon_Previews: PreviewProvider, TestablePreview { } } - static var accessibilityLabels: some View { Grid(alignment: .leading) { ForEach(DynamicTypeSize.allCases, id: \.self) { diff --git a/compound-ios/Sources/Compound/Layout/ScaledOffsetModifier.swift b/compound-ios/Sources/Compound/Layout/ScaledOffsetModifier.swift index 7ad5fd27d..481b75fbc 100644 --- a/compound-ios/Sources/Compound/Layout/ScaledOffsetModifier.swift +++ b/compound-ios/Sources/Compound/Layout/ScaledOffsetModifier.swift @@ -28,7 +28,6 @@ private struct ScaledOffsetModifier: ViewModifier { } } - // MARK: - Previews struct ScaledOffsetModifier_Previews: PreviewProvider, TestablePreview { diff --git a/compound-ios/Sources/Compound/List/ListInlinePicker.swift b/compound-ios/Sources/Compound/List/ListInlinePicker.swift index 71a9442b5..01bc4430a 100644 --- a/compound-ios/Sources/Compound/List/ListInlinePicker.swift +++ b/compound-ios/Sources/Compound/List/ListInlinePicker.swift @@ -18,13 +18,13 @@ struct ListInlinePicker: View { ListRow(label: .plain(title: item.title), details: isWaiting ? .isWaiting(selection == item.tag) : nil, kind: .selection(isSelected: !isWaiting ? selection == item.tag : false) { - var transaction = Transaction() - transaction.disablesAnimations = true + var transaction = Transaction() + transaction.disablesAnimations = true - withTransaction(transaction) { - selection = item.tag - } - }) + withTransaction(transaction) { + selection = item.tag + } + }) } } } diff --git a/compound-ios/Sources/Compound/List/ListRow.swift b/compound-ios/Sources/Compound/List/ListRow.swift index 4a91460bf..6d787782a 100644 --- a/compound-ios/Sources/Compound/List/ListRow.swift +++ b/compound-ios/Sources/Compound/List/ListRow.swift @@ -184,14 +184,14 @@ public extension ListRow where DetailsIcon == EmptyView, CustomContent == EmptyV // Custom row without a label or details label. public extension ListRow where Icon == EmptyView, DetailsIcon == EmptyView { init(kind: Kind) { - self.label = ListRowLabel() - self.details = nil + label = ListRowLabel() + details = nil self.kind = kind } init(kind: Kind) where SelectionValue == String { - self.label = ListRowLabel() - self.details = nil + label = ListRowLabel() + details = nil self.kind = kind } } @@ -249,6 +249,7 @@ private extension Button { // MARK: - Previews +// swiftlint:disable print_deprecation public struct ListRow_Previews: PreviewProvider, TestablePreview { public static var previews: some View { Form { @@ -348,14 +349,14 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview { systemIcon: .squareDashed), details: .title("Content"), kind: .selection(isSelected: true) { - print("I was tapped!") - }) + print("I was tapped!") + }) ListRow(label: .default(title: "Title", systemIcon: .squareDashed), details: .title("Content"), kind: .selection(isSelected: true) { - print("I was tapped!") - }) + print("I was tapped!") + }) ListRow(label: .plain(title: "Title"), kind: .inlinePicker(selection: .constant("Item 1"), @@ -375,7 +376,7 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview { ListRow(label: .action(title: "Title", systemIcon: .squareDashed), kind: .button { print("I was tapped!") }) - .disabled(true) + .disabled(true) } static var plainButton: some View { @@ -401,7 +402,7 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview { ListRow(label: .centeredAction(title: "Title", systemIcon: .squareDashed), kind: .button { print("I was tapped!") }) - .disabled(true) + .disabled(true) } } @@ -445,10 +446,10 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview { }) ListRow(label: .plain(title: "Placeholder"), kind: .textField(text: .constant("This is a disabled text field"))) - .disabled(true) + .disabled(true) ListRow(label: .plain(title: "Placeholder"), kind: .textField(text: .constant(""), axis: .vertical)) - .lineLimit(4...) + .lineLimit(4...) ListRow(label: .plain(title: "Password"), kind: .secureField(text: .constant("p4ssw0rd"))) } @@ -474,3 +475,5 @@ struct ListRowLoadingSelection_Previews: PreviewProvider, TestablePreview { .compoundList() } } + +// swiftlint:enable print_deprecation diff --git a/compound-ios/Sources/Compound/List/ListRowAccessory.swift b/compound-ios/Sources/Compound/List/ListRowAccessory.swift index f94140a9d..a2c764e87 100644 --- a/compound-ios/Sources/Compound/List/ListRowAccessory.swift +++ b/compound-ios/Sources/Compound/List/ListRowAccessory.swift @@ -26,17 +26,17 @@ public struct ListRowAccessory: View { /// A chevron to indicate that the button pushes another screen. public static var navigationLink: Self { - Self.init(kind: .navigationLink) + Self(kind: .navigationLink) } /// A checkmark (or reserved space) to indicate that the row is selected. public static func selection(_ isSelected: Bool) -> Self { - Self.init(kind: isSelected ? .selected : .unselected) + Self(kind: isSelected ? .selected : .unselected) } /// A circular checkmark (or empty circle) to indicate that the row is one of multiple selected. public static func multiSelection(_ isSelected: Bool) -> Self { - Self.init(kind: isSelected ? .multiSelected : .multiUnselected) + Self(kind: isSelected ? .multiSelected : .multiUnselected) } let kind: Kind diff --git a/compound-ios/Sources/Compound/List/ListRowDetails.swift b/compound-ios/Sources/Compound/List/ListRowDetails.swift index b610298b4..9acb5f527 100644 --- a/compound-ios/Sources/Compound/List/ListRowDetails.swift +++ b/compound-ios/Sources/Compound/List/ListRowDetails.swift @@ -61,7 +61,7 @@ public struct ListRowDetails { public static func icon(_ icon: KeyPath, counter: Int? = nil, isWaiting: Bool = false) -> Self where Icon == CompoundIcon { - ListRowDetails(icon:CompoundIcon(icon), + ListRowDetails(icon: CompoundIcon(icon), counter: counter, isWaiting: isWaiting) } diff --git a/compound-ios/Sources/Compound/List/ListRowLabel.swift b/compound-ios/Sources/Compound/List/ListRowLabel.swift index c13f457b5..7621de5d6 100644 --- a/compound-ios/Sources/Compound/List/ListRowLabel.swift +++ b/compound-ios/Sources/Compound/List/ListRowLabel.swift @@ -68,7 +68,7 @@ public struct ListRowLabel: View { } var iconAlignment: VerticalAlignment = .center - var hideIconBackground: Bool = false + var hideIconBackground = false enum Layout { case `default`, centered, avatar } var layout: Layout = .default @@ -77,6 +77,7 @@ public struct ListRowLabel: View { guard isEnabled else { return .compound.textDisabled } return role == .destructive ? .compound.textCriticalPrimary : .compound.textPrimary } + var titleLineLimit: Int? { layout == .avatar ? 1 : lineLimit } var statusColor: Color { @@ -86,6 +87,7 @@ public struct ListRowLabel: View { var descriptionColor: Color { isEnabled ? .compound.textSecondary : .compound.textDisabled } + var descriptionLineLimit: Int? { guard layout == .avatar else { return lineLimit } return role != .error ? 1 : lineLimit diff --git a/compound-ios/Sources/Compound/Previews/Snapshotting.swift b/compound-ios/Sources/Compound/Previews/Snapshotting.swift index 8142ebe8a..e529e87f2 100644 --- a/compound-ios/Sources/Compound/Previews/Snapshotting.swift +++ b/compound-ios/Sources/Compound/Previews/Snapshotting.swift @@ -1,4 +1,4 @@ -// +// // Copyright 2025 New Vector Ltd // // SPDX-License-Identifier: AGPL-3.0-only diff --git a/compound-ios/Sources/Compound/Previews/TestablePreview.swift b/compound-ios/Sources/Compound/Previews/TestablePreview.swift index eb6ea0f79..b75eda8df 100644 --- a/compound-ios/Sources/Compound/Previews/TestablePreview.swift +++ b/compound-ios/Sources/Compound/Previews/TestablePreview.swift @@ -1,4 +1,4 @@ -// +// // Copyright 2025 New Vector Ltd // // SPDX-License-Identifier: AGPL-3.0-only diff --git a/compound-ios/Tests/CompoundTests/PreviewTests.swift b/compound-ios/Tests/CompoundTests/PreviewTests.swift index 3e2a36109..66b6ec199 100644 --- a/compound-ios/Tests/CompoundTests/PreviewTests.swift +++ b/compound-ios/Tests/CompoundTests/PreviewTests.swift @@ -1,4 +1,4 @@ -// +// // Copyright 2025 New Vector Ltd // // SPDX-License-Identifier: AGPL-3.0-only