Skip to content

Commit b10fc8a

Browse files
authored
Run SwiftFormat (#502)
1 parent 11d9782 commit b10fc8a

File tree

16 files changed

+82
-62
lines changed

16 files changed

+82
-62
lines changed

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.0

.swiftformat

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SwiftFormat Configuration File
2+
# For documentation, see: https://github.com/nicklockwood/SwiftFormat/blob/main/Rules.md
3+
4+
--header ignore
5+
--indent tab
6+
--ifdef preserve
7+
--ranges preserve
8+
--extensionacl on-declarations
9+
--trailing-commas always
10+
--nil-init insert
11+
12+
# Disabled rules
13+
--disable blankLinesAroundMark
14+
--disable blankLinesBetweenScopes
15+
--disable docComments
16+
--disable redundantBackticks
17+
--disable redundantLetError
18+
--disable redundantRawValues
19+
--disable redundantSelf
20+
--disable redundantStaticSelf
21+
--disable redundantType
22+
--disable redundantTypedThrows
23+
--disable unusedArguments

Examples/Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import PackageDescription
44

55
let package = Package(
6-
name: "Examples",
7-
products: [],
8-
targets: []
6+
name: "Examples",
7+
products: [],
8+
targets: []
99
)

Examples/Showcase/Showcase/Controls.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import SwiftUI
22
import SwiftUIIntrospect
33

44
struct ControlsShowcase: View {
5-
65
@State private var textFieldValue = ""
76
@State private var toggleValue = false
87
@State private var sliderValue = 0.0
@@ -166,6 +165,5 @@ struct ControlsShowcase: View {
166165
#endif
167166
}
168167
}
169-
170168
}
171169
}

Examples/Showcase/Showcase/List.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ struct ListShowcase: View {
3131
.modifier { list in
3232
if #available(iOS 16, macOS 13, *) {
3333
list.background {
34-
if receiverListFound {
35-
Color(.cyan)
36-
}
34+
if receiverListFound {
35+
Color(.cyan)
3736
}
38-
#if !os(tvOS)
39-
.scrollContentBackground(.hidden)
40-
#endif
37+
}
38+
#if !os(tvOS)
39+
.scrollContentBackground(.hidden)
40+
#endif
4141
} else {
4242
list
4343
}
@@ -104,6 +104,5 @@ struct ListShowcase: View {
104104
}
105105
}
106106
}
107-
108107
}
109108
}

Sources/Introspect.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ extension View {
5050
/// ```
5151
@MainActor
5252
public func introspect<SwiftUIViewType: IntrospectableViewType, PlatformSpecificEntity: PlatformEntity>(
53-
_ viewType: SwiftUIViewType,
54-
on platforms: (PlatformViewVersionPredicate<SwiftUIViewType, PlatformSpecificEntity>)...,
55-
scope: IntrospectionScope? = nil,
56-
customize: @escaping (PlatformSpecificEntity) -> Void
53+
_ viewType: SwiftUIViewType,
54+
on platforms: PlatformViewVersionPredicate<SwiftUIViewType, PlatformSpecificEntity>...,
55+
scope: IntrospectionScope? = nil,
56+
customize: @escaping (PlatformSpecificEntity) -> Void
5757
) -> some View {
5858
self.modifier(IntrospectModifier(viewType, platforms: platforms, scope: scope, customize: customize))
5959
}

Sources/IntrospectionView.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ fileprivate enum IntrospectionStore {
88
static var shared: [IntrospectionViewID: Pair] = [:]
99

1010
struct Pair {
11-
weak var controller: IntrospectionPlatformViewController?
12-
weak var anchor: IntrospectionAnchorPlatformViewController?
11+
weak var controller: IntrospectionPlatformViewController? = nil
12+
weak var anchor: IntrospectionAnchorPlatformViewController? = nil
1313
}
1414
}
1515

@@ -88,7 +88,7 @@ struct IntrospectionView<Target: PlatformEntity>: PlatformViewControllerRepresen
8888
#endif
8989

9090
final class TargetCache {
91-
weak var target: Target?
91+
weak var target: Target? = nil
9292
}
9393

9494
@Binding
@@ -113,15 +113,14 @@ struct IntrospectionView<Target: PlatformEntity>: PlatformViewControllerRepresen
113113
}
114114

115115
func makePlatformViewController(context: Context) -> IntrospectionPlatformViewController {
116-
let controller = IntrospectionPlatformViewController(id: id) { controller in
116+
IntrospectionPlatformViewController(id: id) { controller in
117117
guard let target = selector(controller) else {
118118
return
119119
}
120120
context.coordinator.target = target
121121
customize(target)
122122
controller.handler = nil
123123
}
124-
return controller
125124
}
126125

127126
func updatePlatformViewController(_ controller: IntrospectionPlatformViewController, context: Context) {

Sources/PlatformVersion.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension PlatformVersion {
2323
public var isCurrentOrPast: Bool {
2424
condition == .current || condition == .past
2525
}
26-
26+
2727
@_spi(Internals)
2828
public var condition: PlatformVersionCondition? { nil }
2929
}
@@ -206,7 +206,7 @@ extension tvOSVersion {
206206
return nil
207207
#endif
208208
}
209-
209+
210210
public static let v17 = tvOSVersion {
211211
#if os(tvOS)
212212
if #available(tvOS 18, *) {

Sources/PlatformView.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ public protocol PlatformViewControllerRepresentable: _PlatformViewControllerRepr
3636
}
3737

3838
@_spi(Internals)
39-
public extension PlatformViewControllerRepresentable {
39+
extension PlatformViewControllerRepresentable {
4040
#if canImport(UIKit)
41-
func makeUIViewController(context: Context) -> ViewController {
41+
public func makeUIViewController(context: Context) -> ViewController {
4242
makePlatformViewController(context: context)
4343
}
44-
func updateUIViewController(_ controller: ViewController, context: Context) {
44+
public func updateUIViewController(_ controller: ViewController, context: Context) {
4545
updatePlatformViewController(controller, context: context)
4646
}
47-
static func dismantleUIViewController(_ controller: ViewController, coordinator: Coordinator) {
47+
public static func dismantleUIViewController(_ controller: ViewController, coordinator: Coordinator) {
4848
dismantlePlatformViewController(controller, coordinator: coordinator)
4949
}
5050
#elseif canImport(AppKit)
51-
func makeNSViewController(context: Context) -> ViewController {
51+
public func makeNSViewController(context: Context) -> ViewController {
5252
makePlatformViewController(context: context)
5353
}
54-
func updateNSViewController(_ controller: ViewController, context: Context) {
54+
public func updateNSViewController(_ controller: ViewController, context: Context) {
5555
updatePlatformViewController(controller, context: context)
5656
}
57-
static func dismantleNSViewController(_ controller: ViewController, coordinator: Coordinator) {
57+
public static func dismantleNSViewController(_ controller: ViewController, coordinator: Coordinator) {
5858
dismantlePlatformViewController(controller, coordinator: coordinator)
5959
}
6060
#endif

Sources/PlatformViewVersion.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public struct PlatformViewVersionPredicate<SwiftUIViewType: IntrospectableViewTy
1616
}
1717
}
1818

19-
public static func iOS(_ versions: (iOSViewVersion<SwiftUIViewType, PlatformSpecificEntity>)...) -> Self {
19+
public static func iOS(_ versions: iOSViewVersion<SwiftUIViewType, PlatformSpecificEntity>...) -> Self {
2020
Self(versions, matches: \.isCurrent)
2121
}
2222

@@ -25,7 +25,7 @@ public struct PlatformViewVersionPredicate<SwiftUIViewType: IntrospectableViewTy
2525
Self([versions.lowerBound], matches: \.isCurrentOrPast)
2626
}
2727

28-
public static func tvOS(_ versions: (tvOSViewVersion<SwiftUIViewType, PlatformSpecificEntity>)...) -> Self {
28+
public static func tvOS(_ versions: tvOSViewVersion<SwiftUIViewType, PlatformSpecificEntity>...) -> Self {
2929
Self(versions, matches: \.isCurrent)
3030
}
3131

@@ -34,7 +34,7 @@ public struct PlatformViewVersionPredicate<SwiftUIViewType: IntrospectableViewTy
3434
Self([versions.lowerBound], matches: \.isCurrentOrPast)
3535
}
3636

37-
public static func macOS(_ versions: (macOSViewVersion<SwiftUIViewType, PlatformSpecificEntity>)...) -> Self {
37+
public static func macOS(_ versions: macOSViewVersion<SwiftUIViewType, PlatformSpecificEntity>...) -> Self {
3838
Self(versions, matches: \.isCurrent)
3939
}
4040

@@ -43,7 +43,7 @@ public struct PlatformViewVersionPredicate<SwiftUIViewType: IntrospectableViewTy
4343
Self([versions.lowerBound], matches: \.isCurrentOrPast)
4444
}
4545

46-
public static func visionOS(_ versions: (visionOSViewVersion<SwiftUIViewType, PlatformSpecificEntity>)...) -> Self {
46+
public static func visionOS(_ versions: visionOSViewVersion<SwiftUIViewType, PlatformSpecificEntity>...) -> Self {
4747
Self(versions, matches: \.isCurrent)
4848
}
4949

@@ -89,19 +89,19 @@ public enum PlatformViewVersion<Version: PlatformVersion, SwiftUIViewType: Intro
8989
}
9090

9191
private var version: Version? {
92-
if case .available(let version, _) = self {
93-
return version
92+
if case let .available(version, _) = self {
93+
version
9494
} else {
95-
return nil
95+
nil
9696
}
9797
}
9898

9999
@MainActor
100100
fileprivate var selector: IntrospectionSelector<PlatformSpecificEntity>? {
101-
if case .available(_, let selector) = self {
102-
return selector
101+
if case let .available(_, selector) = self {
102+
selector
103103
} else {
104-
return nil
104+
nil
105105
}
106106
}
107107

@@ -117,11 +117,11 @@ public enum PlatformViewVersion<Version: PlatformVersion, SwiftUIViewType: Intro
117117
// This conformance isn't meant to be used directly by the user,
118118
// it's only to satisfy requirements for forming ranges (e.g. `.v15...`).
119119
extension PlatformViewVersion: Comparable {
120-
nonisolated public static func == (lhs: Self, rhs: Self) -> Bool {
120+
public nonisolated static func == (lhs: Self, rhs: Self) -> Bool {
121121
true
122122
}
123123

124-
nonisolated public static func < (lhs: Self, rhs: Self) -> Bool {
124+
public nonisolated static func < (lhs: Self, rhs: Self) -> Bool {
125125
true
126126
}
127127
}

0 commit comments

Comments
 (0)