From c63e1339aa2fca60533842a885ae45fe47d483a7 Mon Sep 17 00:00:00 2001 From: Steffan Andrews Date: Sun, 20 Oct 2024 22:12:33 -0700 Subject: [PATCH] SwiftFormat pass --- .../Movie Timecode/App/MovieTimecodeApp.swift | 3 +-- .../Movie Timecode/Model/OperationType.swift | 2 +- .../Timecode Math/Timecode Math/App/TimecodeMathApp.swift | 3 +-- .../Timecode Math/DoubleMathExpressionView.swift | 2 +- .../Timecode Math/TimecodeMathExpressionView.swift | 6 +++--- Examples/Timecode Math/Timecode Math/Utilities.swift | 2 +- Examples/Timecode UI/Timecode UI/App/TimecodeUIApp.swift | 3 +-- Sources/TimecodeKitCore/Fraction/Fraction.swift | 2 +- .../TimecodeKitCore/Timecode/Components/Components.swift | 6 +++--- .../TimecodeKitCore/Utilities/Outsourced/Integers.swift | 4 ++-- Sources/TimecodeKitCore/Utilities/URL.swift | 4 ++-- .../Attributed String/NSAttributedString.swift | 2 +- .../TimecodeKitUI/SwiftUI/Shared/Shared Environment.swift | 4 ++-- .../SwiftUI/Shared/Shared View Modifiers.swift | 4 ++-- .../TimecodeField/TimecodeField ComponentView.swift | 1 - .../SwiftUI/TimecodeField/TimecodeField Types.swift | 6 +++--- .../TimecodeKitUI/SwiftUI/TimecodeText/TimecodeText.swift | 7 +++---- Sources/TimecodeKitUI/TimecodeKitUI.swift | 2 +- Sources/TimecodeKitUI/Utilities/KeyboardInputView.swift | 1 - .../Timecode/Source/Timecode String Tests.swift | 1 - 20 files changed, 29 insertions(+), 36 deletions(-) diff --git a/Examples/Movie Timecode/Movie Timecode/App/MovieTimecodeApp.swift b/Examples/Movie Timecode/Movie Timecode/App/MovieTimecodeApp.swift index 2ebee53a..7db05ed3 100644 --- a/Examples/Movie Timecode/Movie Timecode/App/MovieTimecodeApp.swift +++ b/Examples/Movie Timecode/Movie Timecode/App/MovieTimecodeApp.swift @@ -19,8 +19,7 @@ struct MovieTimecodeApp: App { extension Scene { func windowModifiersForMacOS() -> some Scene { #if os(macOS) - self - .defaultSize(width: 680, height: 750) + defaultSize(width: 680, height: 750) .defaultPosition(.center) #else self diff --git a/Examples/Movie Timecode/Movie Timecode/Model/OperationType.swift b/Examples/Movie Timecode/Movie Timecode/Model/OperationType.swift index 77676f58..491ffd37 100644 --- a/Examples/Movie Timecode/Movie Timecode/Model/OperationType.swift +++ b/Examples/Movie Timecode/Movie Timecode/Model/OperationType.swift @@ -12,7 +12,7 @@ enum OperationType: Int, Identifiable, CaseIterable { var title: String { switch self { - case .addOrReplaceTimecodeTrack: + case .addOrReplaceTimecodeTrack: "Add or Replace" case .removeTimecodeTrack: "Remove" diff --git a/Examples/Timecode Math/Timecode Math/App/TimecodeMathApp.swift b/Examples/Timecode Math/Timecode Math/App/TimecodeMathApp.swift index 7d7195ec..af506a8f 100644 --- a/Examples/Timecode Math/Timecode Math/App/TimecodeMathApp.swift +++ b/Examples/Timecode Math/Timecode Math/App/TimecodeMathApp.swift @@ -19,8 +19,7 @@ struct TimecodeMathApp: App { extension Scene { func windowModifiersForMacOS() -> some Scene { #if os(macOS) - self - .defaultSize(width: 360, height: 530) + defaultSize(width: 360, height: 530) .windowResizability(.contentSize) .defaultPosition(.center) #else diff --git a/Examples/Timecode Math/Timecode Math/DoubleMathExpressionView.swift b/Examples/Timecode Math/Timecode Math/DoubleMathExpressionView.swift index 052cff66..dc5f4b8e 100644 --- a/Examples/Timecode Math/Timecode Math/DoubleMathExpressionView.swift +++ b/Examples/Timecode Math/Timecode Math/DoubleMathExpressionView.swift @@ -19,7 +19,7 @@ struct DoubleMathExpressionView: View { self.operation = operation self.rhs = rhs self.lhs = lhs - self.result = operation.result(lhs: lhs, rhs: rhs) + result = operation.result(lhs: lhs, rhs: rhs) } var body: some View { diff --git a/Examples/Timecode Math/Timecode Math/TimecodeMathExpressionView.swift b/Examples/Timecode Math/Timecode Math/TimecodeMathExpressionView.swift index 5c2bd049..e7effdb7 100644 --- a/Examples/Timecode Math/Timecode Math/TimecodeMathExpressionView.swift +++ b/Examples/Timecode Math/Timecode Math/TimecodeMathExpressionView.swift @@ -19,7 +19,7 @@ struct TimecodeMathExpressionView: View { self.operation = operation self.lhs = lhs self.rhs = rhs - self.result = operation.result(lhs: lhs, rhs: rhs) + result = operation.result(lhs: lhs, rhs: rhs) } var body: some View { @@ -71,9 +71,9 @@ extension TimecodeMathExpressionView { func result(lhs: Timecode, rhs: Timecode) -> Timecode { switch self { case .add: - return lhs + rhs + lhs + rhs case .subtract: - return lhs - rhs + lhs - rhs } } } diff --git a/Examples/Timecode Math/Timecode Math/Utilities.swift b/Examples/Timecode Math/Timecode Math/Utilities.swift index a579d566..d0a927ed 100644 --- a/Examples/Timecode Math/Timecode Math/Utilities.swift +++ b/Examples/Timecode Math/Timecode Math/Utilities.swift @@ -8,7 +8,7 @@ import SwiftUI extension Image { func sizeForOperation() -> some View { - self.resizable() + resizable() .frame(width: 30, height: 30) } } diff --git a/Examples/Timecode UI/Timecode UI/App/TimecodeUIApp.swift b/Examples/Timecode UI/Timecode UI/App/TimecodeUIApp.swift index 5710bac8..992f4375 100644 --- a/Examples/Timecode UI/Timecode UI/App/TimecodeUIApp.swift +++ b/Examples/Timecode UI/Timecode UI/App/TimecodeUIApp.swift @@ -22,8 +22,7 @@ struct TimecodeUIApp: App { extension Scene { func windowModifiersForMacOS() -> some Scene { #if os(macOS) - self - .defaultSize(width: 920, height: 950) + defaultSize(width: 920, height: 950) .defaultPosition(.center) #else self diff --git a/Sources/TimecodeKitCore/Fraction/Fraction.swift b/Sources/TimecodeKitCore/Fraction/Fraction.swift index bc3284ec..62ebb442 100644 --- a/Sources/TimecodeKitCore/Fraction/Fraction.swift +++ b/Sources/TimecodeKitCore/Fraction/Fraction.swift @@ -18,7 +18,7 @@ public struct Fraction { /// Returns `true` if the fraction is reduced to its simplest form and can not be reduced any /// further. public var isReduced: Bool { - if let _isReduced = _isReduced, _isReduced { return _isReduced } + if let _isReduced, _isReduced { return _isReduced } let reduced = reduced() return isIdentical(to: reduced) diff --git a/Sources/TimecodeKitCore/Timecode/Components/Components.swift b/Sources/TimecodeKitCore/Timecode/Components/Components.swift index 2da27e13..165d45b9 100644 --- a/Sources/TimecodeKitCore/Timecode/Components/Components.swift +++ b/Sources/TimecodeKitCore/Timecode/Components/Components.swift @@ -8,7 +8,7 @@ extension Timecode { /// Primitive struct describing timecode component values, agnostic of frame rate. /// /// In order to help facilitate defining a set of timecode component values, a simple struct is provided. - /// + /// /// This struct can be passed into many methods and initializers. /// /// ```swift @@ -312,7 +312,7 @@ extension Timecode.Components { /// Internal: /// Sets component values from an array of key/value pairs keyed by ``Timecode/Component``. - mutating func set(from array: [(component: Timecode.Component, value: Int)] ) { + mutating func set(from array: [(component: Timecode.Component, value: Int)]) { for (component, value) in array { switch component { case .days: days = value @@ -414,7 +414,7 @@ extension Timecode.Components { ) -> Bool { allSatisfy { (component: Timecode.Component, value: Int) in value.numberOfDigits <= - component.numberOfDigits(at: frameRate, base: base) + component.numberOfDigits(at: frameRate, base: base) } } } diff --git a/Sources/TimecodeKitCore/Utilities/Outsourced/Integers.swift b/Sources/TimecodeKitCore/Utilities/Outsourced/Integers.swift index 77676601..f95457db 100644 --- a/Sources/TimecodeKitCore/Utilities/Outsourced/Integers.swift +++ b/Sources/TimecodeKitCore/Utilities/Outsourced/Integers.swift @@ -23,9 +23,9 @@ extension BinaryInteger { @_disfavoredOverload package var numberOfDigits: Int { if self < 10 && self >= 0 || self > -10 && self < 0 { - return 1 + 1 } else { - return 1 + (self / 10).numberOfDigits + 1 + (self / 10).numberOfDigits } } } diff --git a/Sources/TimecodeKitCore/Utilities/URL.swift b/Sources/TimecodeKitCore/Utilities/URL.swift index bc400d0e..1a53faec 100644 --- a/Sources/TimecodeKitCore/Utilities/URL.swift +++ b/Sources/TimecodeKitCore/Utilities/URL.swift @@ -20,9 +20,9 @@ extension FileManager { @_disfavoredOverload package var temporaryDirectoryCompat: URL { if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) { - return temporaryDirectory + temporaryDirectory } else { - return URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true) + URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true) } } } diff --git a/Sources/TimecodeKitUI/Attributed String/NSAttributedString.swift b/Sources/TimecodeKitUI/Attributed String/NSAttributedString.swift index 5a790406..dc251caf 100644 --- a/Sources/TimecodeKitUI/Attributed String/NSAttributedString.swift +++ b/Sources/TimecodeKitUI/Attributed String/NSAttributedString.swift @@ -62,7 +62,7 @@ extension Timecode { /// /// ```swift /// let timecode = try Timecode(.string("01:20:10:15"), at: .fps24) - /// + /// /// // macOS (AppKit) /// timecode.nsAttributedString( /// invalidAttributes: [.foregroundColor: NSColor.red] diff --git a/Sources/TimecodeKitUI/SwiftUI/Shared/Shared Environment.swift b/Sources/TimecodeKitUI/SwiftUI/Shared/Shared Environment.swift index db8f94bd..8eea94e6 100644 --- a/Sources/TimecodeKitUI/SwiftUI/Shared/Shared Environment.swift +++ b/Sources/TimecodeKitUI/SwiftUI/Shared/Shared Environment.swift @@ -69,7 +69,7 @@ struct TimecodePastedAction { action(.success(timecode)) } -#if os(macOS) + #if os(macOS) @available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) @MainActor func callAsFunction( @@ -96,7 +96,7 @@ struct TimecodePastedAction { return } } -#endif + #endif } @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) diff --git a/Sources/TimecodeKitUI/SwiftUI/Shared/Shared View Modifiers.swift b/Sources/TimecodeKitUI/SwiftUI/Shared/Shared View Modifiers.swift index 11ab4e43..4b622aa0 100644 --- a/Sources/TimecodeKitUI/SwiftUI/Shared/Shared View Modifiers.swift +++ b/Sources/TimecodeKitUI/SwiftUI/Shared/Shared View Modifiers.swift @@ -242,7 +242,7 @@ extension View { extension View { /// Environment method used to propagate a user-pasted timecode up the view hierarchy. func onPastedTimecode(_ action: @escaping TimecodePastedAction.Action) -> some View { - self.environment(\.timecodePasted, TimecodePastedAction(action: action)) + environment(\.timecodePasted, TimecodePastedAction(action: action)) } } @@ -271,7 +271,7 @@ extension View { propertiesForString: Timecode.Properties, forwardTo block: sending @escaping @autoclosure () -> TimecodePastedAction? ) -> some View { - self.onPasteCommand(of: Timecode.pasteUTTypes) { itemProviders in + onPasteCommand(of: Timecode.pasteUTTypes) { itemProviders in Task { guard let block = block() else { return } await block( diff --git a/Sources/TimecodeKitUI/SwiftUI/TimecodeField/TimecodeField ComponentView.swift b/Sources/TimecodeKitUI/SwiftUI/TimecodeField/TimecodeField ComponentView.swift index 84bbdc2d..01ba6852 100644 --- a/Sources/TimecodeKitUI/SwiftUI/TimecodeField/TimecodeField ComponentView.swift +++ b/Sources/TimecodeKitUI/SwiftUI/TimecodeField/TimecodeField ComponentView.swift @@ -66,7 +66,6 @@ extension TimecodeField { .offset(x: shakeTrigger ? shakeIntensity : 0) .focusable(interactions: [.edit]) .focused($focusedComponent, equals: component) - .onPasteCommandOfTimecode( propertiesForString: timecodeProperties, forwardTo: timecodePasted diff --git a/Sources/TimecodeKitUI/SwiftUI/TimecodeField/TimecodeField Types.swift b/Sources/TimecodeKitUI/SwiftUI/TimecodeField/TimecodeField Types.swift index 8afe66f2..756fd1fa 100644 --- a/Sources/TimecodeKitUI/SwiftUI/TimecodeField/TimecodeField Types.swift +++ b/Sources/TimecodeKitUI/SwiftUI/TimecodeField/TimecodeField Types.swift @@ -59,11 +59,11 @@ extension TimecodeField.FieldAction: RawRepresentable { public var rawValue: String { switch self { - case .endEditing: + case .endEditing: "endEditing" - case .focusNextComponent: + case .focusNextComponent: "focusNextComponent" - case .resetComponentFocus(let component): + case let .resetComponentFocus(component): if let component { "resetComponentFocus-to-\(component)" } else { diff --git a/Sources/TimecodeKitUI/SwiftUI/TimecodeText/TimecodeText.swift b/Sources/TimecodeKitUI/SwiftUI/TimecodeText/TimecodeText.swift index 757fde0d..96804eeb 100644 --- a/Sources/TimecodeKitUI/SwiftUI/TimecodeText/TimecodeText.swift +++ b/Sources/TimecodeKitUI/SwiftUI/TimecodeText/TimecodeText.swift @@ -191,11 +191,10 @@ extension Timecode { let subframesText = String(format: "%0\(numberOfSubFramesDigits)ld", timecode.subFrames) - let baseSubFramesText: Text - if invalids.contains(.subFrames) { - baseSubFramesText = invalidModifiers(subframesText) + let baseSubFramesText: Text = if invalids.contains(.subFrames) { + invalidModifiers(subframesText) } else { - baseSubFramesText = Text(subframesText).conditionalForegroundStyle(subFramesStyle) + Text(subframesText).conditionalForegroundStyle(subFramesStyle) } output.append(baseSubFramesText.textScale(subFramesScale)) diff --git a/Sources/TimecodeKitUI/TimecodeKitUI.swift b/Sources/TimecodeKitUI/TimecodeKitUI.swift index 6c1ac1eb..a2857cef 100644 --- a/Sources/TimecodeKitUI/TimecodeKitUI.swift +++ b/Sources/TimecodeKitUI/TimecodeKitUI.swift @@ -1,5 +1,5 @@ // -// TimecodeKitCore.swift +// TimecodeKitUI.swift // TimecodeKit • https://github.com/orchetect/TimecodeKit // © 2020-2024 Steffan Andrews • Licensed under MIT License // diff --git a/Sources/TimecodeKitUI/Utilities/KeyboardInputView.swift b/Sources/TimecodeKitUI/Utilities/KeyboardInputView.swift index 78ff8509..9a2ad836 100644 --- a/Sources/TimecodeKitUI/Utilities/KeyboardInputView.swift +++ b/Sources/TimecodeKitUI/Utilities/KeyboardInputView.swift @@ -28,7 +28,6 @@ struct KeyboardInputView: View { .labelsHidden() .foregroundStyle(.clear) .tint(.clear) // hide text input caret - .onChange(of: text) { oldValue, newValue in // backspace if text.isEmpty { diff --git a/Tests/TimecodeKitCoreTests/Timecode/Source/Timecode String Tests.swift b/Tests/TimecodeKitCoreTests/Timecode/Source/Timecode String Tests.swift index e21c810b..3dbbb4ae 100644 --- a/Tests/TimecodeKitCoreTests/Timecode/Source/Timecode String Tests.swift +++ b/Tests/TimecodeKitCoreTests/Timecode/Source/Timecode String Tests.swift @@ -308,6 +308,5 @@ final class Timecode_Source_String_Tests: XCTestCase { try tc.set(.string("02:07:08:10.20")) XCTAssertEqual(tc.stringValueVerbose, "02:07:08:10.20 @ 23.976 fps") - } }