mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Run SwiftFormat and fix SwiftLint.
This commit is contained in:
@@ -33,7 +33,7 @@ public class CompoundColors {
|
|||||||
private var overrides = [KeyPath<CompoundColorTokens, Color>: Color]()
|
private var overrides = [KeyPath<CompoundColorTokens, Color>: Color]()
|
||||||
|
|
||||||
public subscript(dynamicMember keyPath: KeyPath<CompoundColorTokens, Color>) -> Color {
|
public subscript(dynamicMember keyPath: KeyPath<CompoundColorTokens, Color>) -> Color {
|
||||||
return overrides[keyPath] ?? tokens[keyPath: keyPath]
|
overrides[keyPath] ?? tokens[keyPath: keyPath]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Customise the colour at the specified key path with the supplied colour.
|
/// Customise the colour at the specified key path with the supplied colour.
|
||||||
@@ -52,11 +52,12 @@ public class CompoundColors {
|
|||||||
.init(background: tokens.bgDecorative3, text: tokens.textDecorative3),
|
.init(background: tokens.bgDecorative3, text: tokens.textDecorative3),
|
||||||
.init(background: tokens.bgDecorative4, text: tokens.textDecorative4),
|
.init(background: tokens.bgDecorative4, text: tokens.textDecorative4),
|
||||||
.init(background: tokens.bgDecorative5, text: tokens.textDecorative5),
|
.init(background: tokens.bgDecorative5, text: tokens.textDecorative5),
|
||||||
.init(background: tokens.bgDecorative6, text: tokens.textDecorative6),
|
.init(background: tokens.bgDecorative6, text: tokens.textDecorative6)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Decorative Colors
|
// MARK: - Decorative Colors
|
||||||
|
|
||||||
// Used to determine the background and text colors of avatars, usernames etc.
|
// Used to determine the background and text colors of avatars, usernames etc.
|
||||||
|
|
||||||
let decorativeColors: [DecorativeColor]
|
let decorativeColors: [DecorativeColor]
|
||||||
@@ -67,6 +68,7 @@ public class CompoundColors {
|
|||||||
|
|
||||||
// MARK: - Awaiting Semantic Tokens
|
// MARK: - Awaiting Semantic Tokens
|
||||||
|
|
||||||
|
// swiftformat:disable numberFormatting
|
||||||
/// This token is a placeholder and hasn't been finalised.
|
/// This token is a placeholder and hasn't been finalised.
|
||||||
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
|
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
|
||||||
public let _borderTextFieldFocused = coreTokens.gray500
|
public let _borderTextFieldFocused = coreTokens.gray500
|
||||||
@@ -91,6 +93,7 @@ public class CompoundColors {
|
|||||||
/// This token is a placeholder and hasn't been finalised.
|
/// This token is a placeholder and hasn't been finalised.
|
||||||
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
|
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
|
||||||
public let _bgEmptyItemAlpha = coreTokens.alphaGray500
|
public let _bgEmptyItemAlpha = coreTokens.alphaGray500
|
||||||
|
// swiftformat:enable numberFormatting
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension UITraitCollection {
|
private extension UITraitCollection {
|
||||||
@@ -107,9 +110,9 @@ private extension String {
|
|||||||
/// Calculates a numeric hash same as Element Web
|
/// 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
|
/// See original function here https://github.com/matrix-org/matrix-react-sdk/blob/321dd49db4fbe360fc2ff109ac117305c955b061/src/utils/FormattingUtils.js#L47
|
||||||
var hashCode: Int {
|
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)
|
sum + Int(character.unicodeScalars.first?.value ?? 0)
|
||||||
}
|
}
|
||||||
return (characterCodeSum % Color.compound.decorativeColors.count)
|
return characterCodeSum % Color.compound.decorativeColors.count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class CompoundUIColors {
|
|||||||
private var overrides = [KeyPath<CompoundUIColorTokens, UIColor>: UIColor]()
|
private var overrides = [KeyPath<CompoundUIColorTokens, UIColor>: UIColor]()
|
||||||
|
|
||||||
public subscript(dynamicMember keyPath: KeyPath<CompoundUIColorTokens, UIColor>) -> UIColor {
|
public subscript(dynamicMember keyPath: KeyPath<CompoundUIColorTokens, UIColor>) -> UIColor {
|
||||||
return overrides[keyPath] ?? tokens[keyPath: keyPath]
|
overrides[keyPath] ?? tokens[keyPath: keyPath]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Customise the colour at the specified key path with the supplied colour.
|
/// Customise the colour at the specified key path with the supplied colour.
|
||||||
@@ -39,12 +39,14 @@ public class CompoundUIColors {
|
|||||||
|
|
||||||
// MARK: - Awaiting Semantic Tokens
|
// MARK: - Awaiting Semantic Tokens
|
||||||
|
|
||||||
|
// swiftformat:disable numberFormatting
|
||||||
/// This token is a placeholder and hasn't been finalised.
|
/// This token is a placeholder and hasn't been finalised.
|
||||||
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
|
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
|
||||||
public let _bgCodeBlock = coreTokens.gray100
|
public let _bgCodeBlock = coreTokens.gray100
|
||||||
/// This token is a placeholder and hasn't been finalised.
|
/// This token is a placeholder and hasn't been finalised.
|
||||||
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
|
@available(iOS, deprecated: 100000.0, message: "This token should be generated by now.")
|
||||||
public let _bgSubtleSecondaryAlpha = coreTokens.alphaGray300
|
public let _bgSubtleSecondaryAlpha = coreTokens.alphaGray300
|
||||||
|
// swiftformat:enable numberFormatting
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension UITraitCollection {
|
private extension UITraitCollection {
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ public struct CompoundIcon: View {
|
|||||||
/// - icon: The icon to show.
|
/// - icon: The icon to show.
|
||||||
public init(_ icon: KeyPath<CompoundIcons, Image>) {
|
public init(_ icon: KeyPath<CompoundIcons, Image>) {
|
||||||
image = .compound[keyPath: icon]
|
image = .compound[keyPath: icon]
|
||||||
self.size = .medium
|
size = .medium
|
||||||
self.font = .compound.bodyLG
|
font = .compound.bodyLG
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an icon using a key path from the Compound tokens.
|
/// 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.
|
/// ** Note:** The image should have a square frame or it may end up distorted.
|
||||||
public init(customImage: Image) {
|
public init(customImage: Image) {
|
||||||
image = customImage
|
image = customImage
|
||||||
self.size = .medium
|
size = .medium
|
||||||
self.font = .compound.bodyLG
|
font = .compound.bodyLG
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an icon using a custom image to allow assets from outside
|
/// 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 {
|
static var accessibilityLabels: some View {
|
||||||
Grid(alignment: .leading) {
|
Grid(alignment: .leading) {
|
||||||
ForEach(DynamicTypeSize.allCases, id: \.self) {
|
ForEach(DynamicTypeSize.allCases, id: \.self) {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ private struct ScaledOffsetModifier: ViewModifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
struct ScaledOffsetModifier_Previews: PreviewProvider, TestablePreview {
|
struct ScaledOffsetModifier_Previews: PreviewProvider, TestablePreview {
|
||||||
|
|||||||
@@ -184,14 +184,14 @@ public extension ListRow where DetailsIcon == EmptyView, CustomContent == EmptyV
|
|||||||
// Custom row without a label or details label.
|
// Custom row without a label or details label.
|
||||||
public extension ListRow where Icon == EmptyView, DetailsIcon == EmptyView {
|
public extension ListRow where Icon == EmptyView, DetailsIcon == EmptyView {
|
||||||
init(kind: Kind<CustomContent, SelectionValue>) {
|
init(kind: Kind<CustomContent, SelectionValue>) {
|
||||||
self.label = ListRowLabel()
|
label = ListRowLabel()
|
||||||
self.details = nil
|
details = nil
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
}
|
}
|
||||||
|
|
||||||
init(kind: Kind<CustomContent, SelectionValue>) where SelectionValue == String {
|
init(kind: Kind<CustomContent, SelectionValue>) where SelectionValue == String {
|
||||||
self.label = ListRowLabel()
|
label = ListRowLabel()
|
||||||
self.details = nil
|
details = nil
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,6 +249,7 @@ private extension Button {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
|
// swiftlint:disable print_deprecation
|
||||||
public struct ListRow_Previews: PreviewProvider, TestablePreview {
|
public struct ListRow_Previews: PreviewProvider, TestablePreview {
|
||||||
public static var previews: some View {
|
public static var previews: some View {
|
||||||
Form {
|
Form {
|
||||||
@@ -474,3 +475,5 @@ struct ListRowLoadingSelection_Previews: PreviewProvider, TestablePreview {
|
|||||||
.compoundList()
|
.compoundList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// swiftlint:enable print_deprecation
|
||||||
|
|||||||
@@ -26,17 +26,17 @@ public struct ListRowAccessory: View {
|
|||||||
|
|
||||||
/// A chevron to indicate that the button pushes another screen.
|
/// A chevron to indicate that the button pushes another screen.
|
||||||
public static var navigationLink: Self {
|
public static var navigationLink: Self {
|
||||||
Self.init(kind: .navigationLink)
|
Self(kind: .navigationLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A checkmark (or reserved space) to indicate that the row is selected.
|
/// A checkmark (or reserved space) to indicate that the row is selected.
|
||||||
public static func selection(_ isSelected: Bool) -> Self {
|
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.
|
/// A circular checkmark (or empty circle) to indicate that the row is one of multiple selected.
|
||||||
public static func multiSelection(_ isSelected: Bool) -> Self {
|
public static func multiSelection(_ isSelected: Bool) -> Self {
|
||||||
Self.init(kind: isSelected ? .multiSelected : .multiUnselected)
|
Self(kind: isSelected ? .multiSelected : .multiUnselected)
|
||||||
}
|
}
|
||||||
|
|
||||||
let kind: Kind
|
let kind: Kind
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public struct ListRowLabel<Icon: View>: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var iconAlignment: VerticalAlignment = .center
|
var iconAlignment: VerticalAlignment = .center
|
||||||
var hideIconBackground: Bool = false
|
var hideIconBackground = false
|
||||||
|
|
||||||
enum Layout { case `default`, centered, avatar }
|
enum Layout { case `default`, centered, avatar }
|
||||||
var layout: Layout = .default
|
var layout: Layout = .default
|
||||||
@@ -77,6 +77,7 @@ public struct ListRowLabel<Icon: View>: View {
|
|||||||
guard isEnabled else { return .compound.textDisabled }
|
guard isEnabled else { return .compound.textDisabled }
|
||||||
return role == .destructive ? .compound.textCriticalPrimary : .compound.textPrimary
|
return role == .destructive ? .compound.textCriticalPrimary : .compound.textPrimary
|
||||||
}
|
}
|
||||||
|
|
||||||
var titleLineLimit: Int? { layout == .avatar ? 1 : lineLimit }
|
var titleLineLimit: Int? { layout == .avatar ? 1 : lineLimit }
|
||||||
|
|
||||||
var statusColor: Color {
|
var statusColor: Color {
|
||||||
@@ -86,6 +87,7 @@ public struct ListRowLabel<Icon: View>: View {
|
|||||||
var descriptionColor: Color {
|
var descriptionColor: Color {
|
||||||
isEnabled ? .compound.textSecondary : .compound.textDisabled
|
isEnabled ? .compound.textSecondary : .compound.textDisabled
|
||||||
}
|
}
|
||||||
|
|
||||||
var descriptionLineLimit: Int? {
|
var descriptionLineLimit: Int? {
|
||||||
guard layout == .avatar else { return lineLimit }
|
guard layout == .avatar else { return lineLimit }
|
||||||
return role != .error ? 1 : lineLimit
|
return role != .error ? 1 : lineLimit
|
||||||
|
|||||||
Reference in New Issue
Block a user