Run SwiftFormat.

This commit is contained in:
Doug
2026-05-27 14:38:50 +01:00
committed by Doug
parent 5138e05e47
commit fa67713726
573 changed files with 2426 additions and 2426 deletions
@@ -18,7 +18,7 @@ struct CompoundInspectorApp: App {
private var isDark: Bool {
colorScheme == .dark
}
private var preferredColorScheme: ColorScheme? {
ProcessInfo.processInfo.isMacCatalystApp ? colorScheme : nil
}
@@ -81,7 +81,7 @@ struct CompoundInspectorApp: App {
Image(systemName: "textformat.size")
}
#endif
Button(action: HyperionManager.sharedInstance().togglePluginDrawer) {
Image(systemName: "ruler")
}
+2 -2
View File
@@ -51,7 +51,7 @@ enum Screen: Hashable, View {
case .gradients: GradientsScreen()
case .fonts: FontsScreen()
case .icons: IconsScreen()
case .list: ListScreen()
case .sizes: EmptyView()
case .labels: EmptyView()
@@ -59,7 +59,7 @@ enum Screen: Hashable, View {
case .textFields: EmptyView()
case .bigIcon: BigIconScreen()
case .titleAndIcon: TitleAndIconScreen()
case .actionSheet: ActionSheetScreen()
case .alert: AlertScreen()
case .contextMenu: ContextMenuScreen()
@@ -69,7 +69,7 @@ public struct CompoundButtonStyle: ButtonStyle {
case .toolbarIcon: 3
}
}
private var verticalPadding: CGFloat {
if kind == .textLink {
return 0
@@ -103,7 +103,7 @@ public struct CompoundButtonStyle: ButtonStyle {
private var isUnderlined: Bool {
kind == .textLink && accessibilityShowButtonShapes
}
public func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
.font(font)
@@ -147,7 +147,7 @@ public struct CompoundButtonStyle: ButtonStyle {
EmptyView()
}
}
private var contentShape: AnyShape {
switch kind {
case .super, .primary, .secondary, .tertiary:
@@ -156,7 +156,7 @@ public struct CompoundButtonStyle: ButtonStyle {
return AnyShape(Rectangle())
}
}
private func fillColor(configuration: Self.Configuration) -> Color {
guard isEnabled else { return .compound.bgActionPrimaryDisabled }
if configuration.role == .destructive {
@@ -61,7 +61,7 @@ public class CompoundColors {
}
// MARK: - Decorative Colors
// Used to determine the background and text colors of avatars, usernames etc.
let decorativeColors: [DecorativeColor]
@@ -25,7 +25,7 @@ public struct CompoundGradients {
.compound.gradientActionStop3,
.compound.gradientActionStop4])
}
public var subtle: Gradient {
.init(colors: [.compound.gradientSubtleStop1,
.compound.gradientSubtleStop2,
@@ -34,7 +34,7 @@ public struct CompoundGradients {
.compound.gradientSubtleStop5,
.compound.gradientSubtleStop6])
}
public var info: Gradient {
.init(colors: [.compound.gradientInfoStop1, .compound.gradientInfoStop2])
}
@@ -49,7 +49,7 @@ public final nonisolated class CompoundUIColors {
public var _bgCodeBlock: UIColor {
CompoundUIColors.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
@@ -21,7 +21,7 @@ struct ListInlinePicker<SelectedValue: Hashable>: View {
kind: .selection(isSelected: !isWaiting ? selection == item.tag : false) {
var transaction = Transaction()
transaction.disablesAnimations = true
withTransaction(transaction) {
selection = item.tag
}
@@ -145,7 +145,7 @@ public struct ListRow<Icon: View, DetailsIcon: View, CustomContent: View, Select
.tint(.compound.iconAccentTertiary)
.foregroundStyle(isEnabled ? .compound.textPrimary : .compound.textDisabled)
.listRowInsets(ListRowPadding.textFieldInsets)
case .custom(let content):
content()
}
@@ -55,7 +55,7 @@ public struct ListRowAccessory: View {
private var verticalPaddingFix: CGFloat {
-4
}
/// Absolute bodge until we have the circle icon in Compound.
@ScaledMetric private var circleOverlayInsets = 5
@@ -78,7 +78,7 @@ public struct ListRowLabel<Icon: View>: View {
guard isEnabled else { return .compound.textDisabled }
return role == .destructive ? .compound.textCriticalPrimary : .compound.textPrimary
}
var titleLineLimit: Int? {
layout == .avatar ? 1 : lineLimit
}
@@ -90,7 +90,7 @@ public struct ListRowLabel<Icon: View>: View {
var descriptionColor: Color {
isEnabled ? .compound.textSecondary : .compound.textDisabled
}
var descriptionLineLimit: Int? {
guard layout == .avatar else { return lineLimit }
return role != .error ? 1 : lineLimit
@@ -30,7 +30,7 @@ private struct ListRowDetailsLabelStyle: LabelStyle {
/// This consists of both the `ListRowDetails` and the `ListRowAccessory`.
public struct ListRowTrailingSection<Icon: View>: View {
@Environment(\.isEnabled) private var isEnabled
private var title: String?
private var icon: Icon?
private var counter: Int?
@@ -11,7 +11,7 @@ import SwiftUI
struct SnapshotPrecisionPreferenceKey: PreferenceKey {
static var defaultValue: Float = 1.0
static func reduce(value: inout Float, nextValue: () -> Float) {
value = nextValue()
}
@@ -19,7 +19,7 @@ struct SnapshotPrecisionPreferenceKey: PreferenceKey {
struct SnapshotPerceptualPrecisionPreferenceKey: PreferenceKey {
static var defaultValue: Float = 0.98
static func reduce(value: inout Float, nextValue: () -> Float) {
value = nextValue()
}
@@ -77,7 +77,7 @@ struct SearchStyle_Previews: PreviewProvider, TestablePreview {
Text("Settings")
.compoundListSectionHeader()
}
Section {
ListRow(label: .plain(title: "Some setting"),
kind: .toggle(.constant(true)))
@@ -26,12 +26,12 @@ struct PreviewTests {
private let snapshotDevices: [SnapshotDevice] = [.init(name: "iPhone", device: "iPhone 17"),
.init(name: "iPad", device: "iPad")]
private var recordMode: SnapshotTestingConfiguration.Record = .missing
init() {
if ProcessInfo().environment["RECORD_FAILURES"].map(Bool.init) == true {
recordMode = .failed
}
checkEnvironments()
UIView.setAnimationsEnabled(false)
}
@@ -44,7 +44,7 @@ struct PreviewTests {
fatalError("\(deviceModel ?? "Unknown") is the wrong one. Switch to using \(simulatorDevice) for these tests.")
}
}
let osVersion = ProcessInfo().operatingSystemVersion
guard osVersion.majorVersion == requiredOSVersion.major, osVersion.minorVersion == requiredOSVersion.minor else {
fatalError("Switch to iOS \(requiredOSVersion) for these tests.")
@@ -55,7 +55,7 @@ struct PreviewTests {
}
// MARK: - Snapshots
func assertSnapshots(matching preview: _Preview, testName: String = #function, step: Int) async throws {
let preferences = SnapshotPreferences()
@@ -107,15 +107,15 @@ struct PreviewTests {
}
return languageCode + "-" + regionCode
}
private var languageCode: String {
Locale.current.language.languageCode?.identifier ?? ""
}
private var regionCode: String {
Locale.current.language.region?.identifier ?? ""
}
private func assertSnapshots(matching view: AnyView,
name: String?,
isScreen: Bool,
@@ -177,7 +177,7 @@ private extension Snapshotting where Value: SwiftUI.View, Format == UIImage {
layout: SwiftUISnapshotLayout = .sizeThatFits,
traits: UITraitCollection = .init()) -> Snapshotting {
let config: ViewImageConfig
switch layout {
#if os(iOS) || os(tvOS)
case let .device(config: deviceConfig):
@@ -191,21 +191,21 @@ private extension Snapshotting where Value: SwiftUI.View, Format == UIImage {
// Make sure to use the workaround safe area insets.
config = .init(safeArea: .one, size: size, traits: traits)
}
return SimplySnapshotting<UIImage>(pathExtension: "png", diffing: .prefireImage(preferences: preferences, scale: traits.displayScale))
.asyncPullback { @MainActor view in
var config = config
let controller: UIViewController
if config.size != nil {
controller = UIHostingController(rootView: view)
} else {
let hostingController = UIHostingController(rootView: view)
let maxSize = CGSize.zero
config.size = hostingController.sizeThatFits(in: maxSize)
controller = hostingController
}