Skip to content

Commit

Permalink
SwiftFormat pass
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Oct 21, 2024
1 parent b2ab872 commit c63e133
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum OperationType: Int, Identifiable, CaseIterable {

var title: String {
switch self {
case .addOrReplaceTimecodeTrack:
case .addOrReplaceTimecodeTrack:
"Add or Replace"
case .removeTimecodeTrack:
"Remove"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/Timecode Math/Timecode Math/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI

extension Image {
func sizeForOperation() -> some View {
self.resizable()
resizable()
.frame(width: 30, height: 30)
}
}
3 changes: 1 addition & 2 deletions Examples/Timecode UI/Timecode UI/App/TimecodeUIApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/TimecodeKitCore/Fraction/Fraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Sources/TimecodeKitCore/Timecode/Components/Components.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
}
4 changes: 2 additions & 2 deletions Sources/TimecodeKitCore/Utilities/Outsourced/Integers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
4 changes: 2 additions & 2 deletions Sources/TimecodeKitCore/Utilities/URL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions Sources/TimecodeKitUI/SwiftUI/Shared/Shared Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -96,7 +96,7 @@ struct TimecodePastedAction {
return
}
}
#endif
#endif
}

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ extension TimecodeField {
.offset(x: shakeTrigger ? shakeIntensity : 0)
.focusable(interactions: [.edit])
.focused($focusedComponent, equals: component)

.onPasteCommandOfTimecode(
propertiesForString: timecodeProperties,
forwardTo: timecodePasted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions Sources/TimecodeKitUI/SwiftUI/TimecodeText/TimecodeText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Sources/TimecodeKitUI/TimecodeKitUI.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// TimecodeKitCore.swift
// TimecodeKitUI.swift
// TimecodeKit • https://github.com/orchetect/TimecodeKit
// © 2020-2024 Steffan Andrews • Licensed under MIT License
//
Expand Down
1 change: 0 additions & 1 deletion Sources/TimecodeKitUI/Utilities/KeyboardInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}
}

0 comments on commit c63e133

Please sign in to comment.