mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Update files following swiftformat upgrade
This commit is contained in:
committed by
Stefan Ceriu
parent
fe189fcfed
commit
23062901c0
@@ -15,8 +15,13 @@ struct CompoundInspectorApp: App {
|
||||
@State private var colorScheme: ColorScheme = .light
|
||||
@State private var dynamicTypeSize: DynamicTypeSize = .large
|
||||
|
||||
private var isDark: Bool { colorScheme == .dark }
|
||||
private var preferredColorScheme: ColorScheme? { ProcessInfo.processInfo.isMacCatalystApp ? colorScheme : nil }
|
||||
private var isDark: Bool {
|
||||
colorScheme == .dark
|
||||
}
|
||||
|
||||
private var preferredColorScheme: ColorScheme? {
|
||||
ProcessInfo.processInfo.isMacCatalystApp ? colorScheme : nil
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
|
||||
@@ -20,7 +20,9 @@ public struct SendButton: View {
|
||||
return colorScheme == .light ? .compound.iconOnSolidPrimary : .compound.iconPrimary
|
||||
}
|
||||
|
||||
private var gradient: Gradient { isEnabled ? .compound.action : .init(colors: [.clear]) }
|
||||
private var gradient: Gradient {
|
||||
isEnabled ? .compound.action : .init(colors: [.clear])
|
||||
}
|
||||
|
||||
/// Creates a send button that performs the provided action.
|
||||
public init(action: @escaping () -> Void) {
|
||||
|
||||
@@ -16,7 +16,9 @@ public extension Color {
|
||||
|
||||
public extension ShapeStyle where Self == Color {
|
||||
/// The colours used by Element as defined in Compound Design Tokens.
|
||||
static var compound: CompoundColors { Self.compound }
|
||||
static var compound: CompoundColors {
|
||||
Self.compound
|
||||
}
|
||||
}
|
||||
|
||||
/// The colours used by Element as defined in Compound Design Tokens.
|
||||
@@ -100,7 +102,9 @@ public class CompoundColors {
|
||||
|
||||
private extension UITraitCollection {
|
||||
/// Whether or not the trait collection contains a `userInterfaceStyle` of `.light`.
|
||||
var isLight: Bool { userInterfaceStyle == .light }
|
||||
var isLight: Bool {
|
||||
userInterfaceStyle == .light
|
||||
}
|
||||
}
|
||||
|
||||
public struct DecorativeColor: Equatable {
|
||||
|
||||
@@ -17,22 +17,30 @@ public extension Gradient {
|
||||
/// The gradients used by Element as defined in Compound Design Tokens.
|
||||
/// This struct only contains the gradients assembled from the individual colour stops.
|
||||
public struct CompoundGradients {
|
||||
// We need to use computed properties here so that the gradients include the
|
||||
// latest token overrides that have been applied since the struct was created.
|
||||
public var action: Gradient { .init(colors: [.compound.gradientActionStop1,
|
||||
.compound.gradientActionStop2,
|
||||
.compound.gradientActionStop3,
|
||||
.compound.gradientActionStop4]) }
|
||||
public var subtle: Gradient { .init(colors: [.compound.gradientSubtleStop1,
|
||||
.compound.gradientSubtleStop2,
|
||||
.compound.gradientSubtleStop3,
|
||||
.compound.gradientSubtleStop4,
|
||||
.compound.gradientSubtleStop5,
|
||||
.compound.gradientSubtleStop6]) }
|
||||
public var info: Gradient { .init(colors: [.compound.gradientInfoStop1,
|
||||
.compound.gradientInfoStop2,
|
||||
.compound.gradientInfoStop3,
|
||||
.compound.gradientInfoStop4,
|
||||
.compound.gradientInfoStop5,
|
||||
.compound.gradientInfoStop6]) }
|
||||
/// We need to use computed properties here so that the gradients include the
|
||||
/// latest token overrides that have been applied since the struct was created.
|
||||
public var action: Gradient {
|
||||
.init(colors: [.compound.gradientActionStop1,
|
||||
.compound.gradientActionStop2,
|
||||
.compound.gradientActionStop3,
|
||||
.compound.gradientActionStop4])
|
||||
}
|
||||
|
||||
public var subtle: Gradient {
|
||||
.init(colors: [.compound.gradientSubtleStop1,
|
||||
.compound.gradientSubtleStop2,
|
||||
.compound.gradientSubtleStop3,
|
||||
.compound.gradientSubtleStop4,
|
||||
.compound.gradientSubtleStop5,
|
||||
.compound.gradientSubtleStop6])
|
||||
}
|
||||
|
||||
public var info: Gradient {
|
||||
.init(colors: [.compound.gradientInfoStop1,
|
||||
.compound.gradientInfoStop2,
|
||||
.compound.gradientInfoStop3,
|
||||
.compound.gradientInfoStop4,
|
||||
.compound.gradientInfoStop5,
|
||||
.compound.gradientInfoStop6])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,5 +53,7 @@ public class CompoundUIColors {
|
||||
|
||||
private extension UITraitCollection {
|
||||
/// Whether or not the trait collection contains a `userInterfaceStyle` of `.light`.
|
||||
var isLight: Bool { userInterfaceStyle == .light }
|
||||
var isLight: Bool {
|
||||
userInterfaceStyle == .light
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@ struct ListInlinePicker<SelectedValue: Hashable>: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct ListInlinePicker_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View { Preview() }
|
||||
static var previews: some View {
|
||||
Preview()
|
||||
}
|
||||
|
||||
struct Preview: View {
|
||||
@State var selection = "Item 1"
|
||||
|
||||
@@ -154,7 +154,7 @@ public struct ListRow<Icon: View, DetailsIcon: View, CustomContent: View, Select
|
||||
|
||||
// MARK: - Initialisers
|
||||
|
||||
// Normal row with a details icon
|
||||
/// Normal row with a details icon
|
||||
public extension ListRow where CustomContent == EmptyView {
|
||||
init(label: ListRowLabel<Icon>,
|
||||
details: ListRowDetails<DetailsIcon>? = nil,
|
||||
@@ -173,7 +173,7 @@ public extension ListRow where CustomContent == EmptyView {
|
||||
}
|
||||
}
|
||||
|
||||
// Normal row without a details icon.
|
||||
/// Normal row without a details icon.
|
||||
public extension ListRow where DetailsIcon == EmptyView, CustomContent == EmptyView {
|
||||
init(label: ListRowLabel<Icon>,
|
||||
details: ListRowDetails<DetailsIcon>? = nil,
|
||||
@@ -192,7 +192,7 @@ 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 {
|
||||
init(kind: Kind<CustomContent, SelectionValue>) {
|
||||
label = ListRowLabel()
|
||||
@@ -449,7 +449,7 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder static var othersSection: some View {
|
||||
static var othersSection: some View {
|
||||
Section {
|
||||
ListRow(kind: .custom {
|
||||
Text("This is a custom row")
|
||||
|
||||
@@ -52,7 +52,10 @@ public struct ListRowAccessory: View {
|
||||
let kind: Kind
|
||||
|
||||
/// Negative padding added to prevent the accessory interfering with the row's padding.
|
||||
private var verticalPaddingFix: CGFloat { -4 }
|
||||
private var verticalPaddingFix: CGFloat {
|
||||
-4
|
||||
}
|
||||
|
||||
/// Absolute bodge until we have the circle icon in Compound.
|
||||
@ScaledMetric private var circleOverlayInsets = 5
|
||||
|
||||
|
||||
@@ -79,7 +79,9 @@ public struct ListRowLabel<Icon: View>: View {
|
||||
return role == .destructive ? .compound.textCriticalPrimary : .compound.textPrimary
|
||||
}
|
||||
|
||||
var titleLineLimit: Int? { layout == .avatar ? 1 : lineLimit }
|
||||
var titleLineLimit: Int? {
|
||||
layout == .avatar ? 1 : lineLimit
|
||||
}
|
||||
|
||||
var statusColor: Color {
|
||||
isEnabled ? .compound.textSecondary : .compound.textDisabled
|
||||
|
||||
@@ -38,7 +38,9 @@ public struct ListRowTrailingSection<Icon: View>: View {
|
||||
private var accessory: ListRowAccessory?
|
||||
|
||||
@ScaledMetric private var iconSize = 24
|
||||
private var hideAccessory: Bool { isWaiting && accessory?.kind == .unselected }
|
||||
private var hideAccessory: Bool {
|
||||
isWaiting && accessory?.kind == .unselected
|
||||
}
|
||||
|
||||
init(_ details: ListRowDetails<Icon>?, accessory: ListRowAccessory? = nil) {
|
||||
title = details?.title
|
||||
|
||||
@@ -12,7 +12,6 @@ public extension View {
|
||||
/// Styles a search bar text field using the Compound design tokens.
|
||||
/// This modifier is to be used in combination with `.searchable`.
|
||||
@MainActor
|
||||
@ViewBuilder
|
||||
func compoundSearchField() -> some View {
|
||||
introspect(.navigationStack, on: .supportedVersions, scope: .ancestor) { navigationController in
|
||||
// Uses the navigation stack as .searchField is unreliable when pushing the second search bar, during the create rooms flow.
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@testable import Compound
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import XCTest
|
||||
|
||||
@@ -17,7 +16,7 @@ final class DecorativeColorsTests: XCTestCase {
|
||||
let input: String
|
||||
private let webOutput: Int
|
||||
|
||||
// remember that web starts the index from 1 while we start from 0
|
||||
/// remember that web starts the index from 1 while we start from 0
|
||||
var output: Int {
|
||||
webOutput - 1
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import XCTest
|
||||
|
||||
final class FontSizeTests: XCTestCase {
|
||||
/// Test all system text styles to assert mapping between `Font` and `UIFont`.
|
||||
func testTextStyle() throws {
|
||||
func testTextStyle() {
|
||||
let caption2FontSize = FontSize.reflecting(.caption2)
|
||||
XCTAssertEqual(caption2FontSize?.value, 11)
|
||||
XCTAssertEqual(caption2FontSize?.style, .caption2)
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@testable import Compound
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
@MainActor
|
||||
|
||||
@@ -7,11 +7,10 @@
|
||||
//
|
||||
|
||||
import Combine
|
||||
import SwiftUI
|
||||
import XCTest
|
||||
|
||||
@testable import Compound
|
||||
@testable import SnapshotTesting
|
||||
import SwiftUI
|
||||
import XCTest
|
||||
|
||||
@MainActor
|
||||
class PreviewTests: XCTestCase {
|
||||
@@ -23,8 +22,8 @@ class PreviewTests: XCTestCase {
|
||||
private let deviceConfig: ViewImageConfig = .iPhoneX
|
||||
private let simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation
|
||||
private let requiredOSVersion = (major: 26, minor: 1)
|
||||
// The key is the name we will give to the snapshot
|
||||
// The value is the actual device that will be used to render the preview
|
||||
/// The key is the name we will give to the snapshot
|
||||
/// The value is the actual device that will be used to render the preview
|
||||
private let snapshotDevices: [SnapshotDevice] = [.init(name: "iPhone", device: "iPhone 17"),
|
||||
.init(name: "iPad", device: "iPad")]
|
||||
private var recordMode: SnapshotTestingConfiguration.Record = .missing
|
||||
@@ -130,8 +129,7 @@ class PreviewTests: XCTestCase {
|
||||
preferences: SnapshotPreferences) -> String? {
|
||||
let matchingView = isScreen ? AnyView(view) : AnyView(view
|
||||
.frame(width: device.size?.width)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
)
|
||||
.fixedSize(horizontal: false, vertical: true))
|
||||
|
||||
return withSnapshotTesting(record: recordMode) {
|
||||
verifySnapshot(of: matchingView,
|
||||
@@ -243,5 +241,7 @@ private extension Diffing where Value == UIImage {
|
||||
private extension UIEdgeInsets {
|
||||
/// A custom inset that prevents the snapshotting library from rendering the
|
||||
/// origin at (10000, 10000) which breaks some of our views such as MessageText.
|
||||
static var one: UIEdgeInsets { UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1) }
|
||||
static var one: UIEdgeInsets {
|
||||
UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user