Skip to content

Commit

Permalink
Run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
calda committed Jan 3, 2025
1 parent ca9ee08 commit 9acaa6d
Show file tree
Hide file tree
Showing 85 changed files with 232 additions and 272 deletions.
12 changes: 6 additions & 6 deletions Example/Example/AnimationPreviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ struct AnimationPreviewView: View {

// MARK: Private

/// Used for remote animations only, when more than one URL is provided we loop over the urls every 2 seconds.
private let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect()
private let urls: [URL]

@State private var animationPlaying = true
@State private var sliderValue: AnimationProgressTime = 0
@State private var currentURLIndex: Int
@State private var renderingEngine: RenderingEngineOption = .automatic
@State private var loopMode: LottieLoopMode = .loop
@State private var renderingEngine = RenderingEngineOption.automatic
@State private var loopMode = LottieLoopMode.loop
@State private var playFromProgress: AnimationProgressTime = 0
@State private var playToProgress: AnimationProgressTime = 1
@State private var currentRenderingEngine: RenderingEngine?

/// Used for remote animations only, when more than one URL is provided we loop over the urls every 2 seconds.
private let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect()
private let urls: [URL]

private var playbackMode: LottiePlaybackMode {
if animationPlaying {
.playing(.fromProgress(playFromProgress, toProgress: playToProgress, loopMode: loopMode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ struct BezierPathKeyframe: Interpolatable {
/// that can have different counts / timing parameters
static func combining(
path: KeyframeGroup<BezierPath>,
cornerRadius: KeyframeGroup<LottieVector1D>?) throws
-> KeyframeGroup<BezierPathKeyframe>
cornerRadius: KeyframeGroup<LottieVector1D>?)
throws -> KeyframeGroup<BezierPathKeyframe>
{
guard
let cornerRadius,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ extension Stroke: StrokeShapeItem {

func copy(width: KeyframeGroup<LottieVector1D>) -> StrokeShapeItem {
// Type-erase the copy from `Stroke` to `StrokeShapeItem`
let copy: Stroke = copy(width: width)
return copy
copy(width: width)
}
}

Expand All @@ -35,8 +34,7 @@ extension GradientStroke: StrokeShapeItem {

func copy(width: KeyframeGroup<LottieVector1D>) -> StrokeShapeItem {
// Type-erase the copy from `GradientStroke` to `StrokeShapeItem`
let copy: GradientStroke = copy(width: width)
return copy
copy(width: width)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Private/CoreAnimation/CoreAnimationLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ extension CALayer {
var numberOfSublayersWithTimeRemapping = 0

for sublayer in sublayers ?? [] {
if
if
let preCompLayer = sublayer as? PreCompLayer,
preCompLayer.preCompLayer.timeRemapping != nil
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class GradientRenderLayer: CAGradientLayer {

/// The reference bounds within this layer that the gradient's
/// `startPoint` and `endPoint` should be calculated relative to
var gradientReferenceBounds: CGRect = .zero {
var gradientReferenceBounds = CGRect.zero {
didSet {
if oldValue != gradientReferenceBounds {
updateLayout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct IndexPathChangeset {
inserts.isEmpty && deletes.isEmpty && updates.isEmpty && moves.isEmpty
}

static func += (left: inout IndexPathChangeset, right: IndexPathChangeset) {
static func +=(left: inout IndexPathChangeset, right: IndexPathChangeset) {
left.inserts += right.inserts
left.deletes += right.deletes
left.updates += right.updates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct SwiftUIView<Content: ViewType, Storage>: MeasuringViewRepresentable,

var configurations: [Configuration] = []

var sizing: SwiftUIMeasurementContainerStrategy = .automatic
var sizing = SwiftUIMeasurementContainerStrategy.automatic

// MARK: Private

Expand Down
6 changes: 3 additions & 3 deletions Sources/Private/EmbeddedLibraries/LRUCache/LRUCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ let LRUCacheMemoryWarningNotification: NSNotification.Name =
#else

/// Notification that cache should be cleared
let LRUCacheMemoryWarningNotification: NSNotification.Name =
.init("LRUCacheMemoryWarningNotification")
let LRUCacheMemoryWarningNotification =
NSNotification.Name("LRUCacheMemoryWarningNotification")

#endif

Expand Down Expand Up @@ -99,7 +99,7 @@ final class LRUCache<Key: Hashable, Value> {
private var values: [Key: Container] = [:]
private unowned(unsafe) var head: Container?
private unowned(unsafe) var tail: Container?
private let lock: NSLock = .init()
private let lock = NSLock()
private var token: AnyObject?
private let notificationCenter: NotificationCenter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ extension Archive {
compressionMethod: CompressionMethod,
bufferSize: Int,
progress: Progress? = nil,
provider: Provider) throws -> (sizeWritten: Int64, crc32: CRC32)
provider: Provider)
throws -> (sizeWritten: Int64, crc32: CRC32)
{
var checksum = CRC32(0)
var sizeWritten = Int64(0)
Expand Down Expand Up @@ -266,7 +267,8 @@ extension Archive {
size: Int64,
bufferSize: Int,
progress: Progress? = nil,
provider: Provider) throws -> (sizeWritten: Int64, checksum: CRC32)
provider: Provider)
throws -> (sizeWritten: Int64, checksum: CRC32)
{
var position: Int64 = 0
var sizeWritten: Int64 = 0
Expand All @@ -287,7 +289,8 @@ extension Archive {
size: Int64,
bufferSize: Int,
progress: Progress? = nil,
provider: Provider) throws -> (sizeWritten: Int64, checksum: CRC32)
provider: Provider)
throws -> (sizeWritten: Int64, checksum: CRC32)
{
var sizeWritten: Int64 = 0
let consumer: Consumer = { data in sizeWritten += Int64(try Data.write(chunk: data, to: self.archiveFile)) }
Expand Down
30 changes: 15 additions & 15 deletions Sources/Private/EmbeddedLibraries/ZipFoundation/Archive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,6 @@ final class Archive: Sequence {
var zip64EndOfCentralDirectory: ZIP64EndOfCentralDirectory?
var preferredEncoding: String.Encoding?

var totalNumberOfEntriesInCentralDirectory: UInt64 {
zip64EndOfCentralDirectory?.record.totalNumberOfEntriesInCentralDirectory
?? UInt64(endOfCentralDirectoryRecord.totalNumberOfEntriesInCentralDirectory)
}

var sizeOfCentralDirectory: UInt64 {
zip64EndOfCentralDirectory?.record.sizeOfCentralDirectory
?? UInt64(endOfCentralDirectoryRecord.sizeOfCentralDirectory)
}

var offsetToStartOfCentralDirectory: UInt64 {
zip64EndOfCentralDirectory?.record.offsetToStartOfCentralDirectory
?? UInt64(endOfCentralDirectoryRecord.offsetToStartOfCentralDirectory)
}

#if swift(>=5.0)
var memoryFile: MemoryFile?

Expand Down Expand Up @@ -221,6 +206,21 @@ final class Archive: Sequence {
}
#endif

var totalNumberOfEntriesInCentralDirectory: UInt64 {
zip64EndOfCentralDirectory?.record.totalNumberOfEntriesInCentralDirectory
?? UInt64(endOfCentralDirectoryRecord.totalNumberOfEntriesInCentralDirectory)
}

var sizeOfCentralDirectory: UInt64 {
zip64EndOfCentralDirectory?.record.sizeOfCentralDirectory
?? UInt64(endOfCentralDirectoryRecord.sizeOfCentralDirectory)
}

var offsetToStartOfCentralDirectory: UInt64 {
zip64EndOfCentralDirectory?.record.offsetToStartOfCentralDirectory
?? UInt64(endOfCentralDirectoryRecord.offsetToStartOfCentralDirectory)
}

// MARK: - Helpers

static func scanForEndOfCentralDirectoryRecord(in file: FILEPointer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ extension Data {
guard let data = try? readChunk(of: T.size, from: file) else {
return nil
}
let structure = T(data: data, additionalDataProvider: { additionalDataSize -> Data in
return T(data: data, additionalDataProvider: { additionalDataSize -> Data in
try self.readChunk(of: additionalDataSize, from: file)
})
return structure
}

static func consumePart(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ struct Entry: Equatable {
return dataOffset
}

static func == (lhs: Entry, rhs: Entry) -> Bool {
static func ==(lhs: Entry, rhs: Entry) -> Bool {
lhs.path == rhs.path
&& lhs.localFileHeader.crc32 == rhs.localFileHeader.crc32
&& lhs.centralDirectoryStructure.effectiveRelativeOffsetOfLocalHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ extension FileManager {
#endif

let timeStamp = TimeInterval(modTimeSpec.tv_sec) + TimeInterval(modTimeSpec.tv_nsec) / 1000000000.0
let modDate = Date(timeIntervalSince1970: timeStamp)
return modDate
return Date(timeIntervalSince1970: timeStamp)
}

class func fileSizeForItem(at url: URL) throws -> Int64 {
Expand Down Expand Up @@ -308,7 +307,7 @@ extension Date {
// MARK: Internal

var fileModificationDateTime: (UInt16, UInt16) {
(self.fileModificationDate, self.fileModificationTime)
(fileModificationDate, fileModificationTime)
}

var fileModificationDate: UInt16 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ class CompositionLayer: CALayer, KeypathSearchable {
super.init()
anchorPoint = .zero
actions = [
"opacity" : NSNull(),
"transform" : NSNull(),
"bounds" : NSNull(),
"anchorPoint" : NSNull(),
"sublayerTransform" : NSNull(),
"shadowOpacity" : NSNull(),
"shadowOffset" : NSNull(),
"shadowColor" : NSNull(),
"shadowRadius" : NSNull(),
"opacity": NSNull(),
"transform": NSNull(),
"bounds": NSNull(),
"anchorPoint": NSNull(),
"sublayerTransform": NSNull(),
"shadowOpacity": NSNull(),
"shadowOffset": NSNull(),
"shadowColor": NSNull(),
"shadowRadius": NSNull(),
]

contentsLayer.anchorPoint = .zero
contentsLayer.bounds = CGRect(origin: .zero, size: size)
contentsLayer.actions = [
"opacity" : NSNull(),
"transform" : NSNull(),
"bounds" : NSNull(),
"anchorPoint" : NSNull(),
"sublayerTransform" : NSNull(),
"hidden" : NSNull(),
"opacity": NSNull(),
"transform": NSNull(),
"bounds": NSNull(),
"anchorPoint": NSNull(),
"sublayerTransform": NSNull(),
"hidden": NSNull(),
]
compositingFilter = layer.blendMode.filterName
addSublayer(contentsLayer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class ImageCompositionLayer: CompositionLayer {
}
}

var imageContentsGravity: CALayerContentsGravity = .resize {
var imageContentsGravity = CALayerContentsGravity.resize {
didSet {
contentsLayer.contentsGravity = imageContentsGravity
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private class MaskLayer: CALayer {
: .rgb(0, 1, 0)
maskLayer.fillRule = CAShapeLayerFillRule.evenOdd
actions = [
"opacity" : NSNull(),
"opacity": NSNull(),
]
}

Expand Down Expand Up @@ -168,9 +168,9 @@ private class MaskNodeProperties: NodePropertyMap {
shape = NodeProperty(provider: KeyframeInterpolator(keyframes: mask.shape.keyframes))
expansion = NodeProperty(provider: KeyframeInterpolator(keyframes: mask.expansion.keyframes))
propertyMap = [
PropertyName.opacity.rawValue : opacity,
"Shape" : shape,
"Expansion" : expansion,
PropertyName.opacity.rawValue: opacity,
"Shape": shape,
"Expansion": expansion,
]
properties = Array(propertyMap.values)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ final class PreCompositionLayer: CompositionLayer {
guard let remappingNode else {
return super.keypathProperties
}
return ["Time Remap" : remappingNode]
return ["Time Remap": remappingNode]
}

override func displayContentsWithFrame(frame: CGFloat, forceUpdates: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class SolidCompositionLayer: CompositionLayer {

override var keypathProperties: [String: AnyNodeProperty] {
guard let colorProperty else { return super.keypathProperties }
return [PropertyName.color.rawValue : colorProperty]
return [PropertyName.color.rawValue: colorProperty]
}

override func displayContentsWithFrame(frame: CGFloat, forceUpdates _: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension [LayerModel] {
-> [CompositionLayer]
{
var compositionLayers = [CompositionLayer]()
var layerMap = [Int : CompositionLayer]()
var layerMap = [Int: CompositionLayer]()

/// Organize the assets into a dictionary of [ID : ImageAsset]
var childLayers = [LayerModel]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,43 +217,6 @@ final class CoreTextRenderLayer: CALayer {
private var strokeFrameSetter: CTFramesetter?
private var needsContentUpdate = false

/// Draws Debug colors for the font alignment.
private func drawDebug(_ ctx: CGContext) {
if let font {
let ascent = CTFontGetAscent(font)
let descent = CTFontGetDescent(font)
let capHeight = CTFontGetCapHeight(font)
let leading = CTFontGetLeading(font)

// Ascent Red
ctx.setFillColor(CGColor(srgbRed: 1, green: 0, blue: 0, alpha: 0.5))
ctx.fill(CGRect(x: 0, y: 0, width: drawingRect.width, height: ascent))

// Descent Blue
ctx.setFillColor(CGColor(srgbRed: 0, green: 0, blue: 1, alpha: 0.5))
ctx.fill(CGRect(x: 0, y: ascent, width: drawingRect.width, height: descent))

// Leading Yellow
ctx.setFillColor(CGColor(srgbRed: 1, green: 1, blue: 0, alpha: 0.5))
ctx.fill(CGRect(x: 0, y: ascent + descent, width: drawingRect.width, height: leading))

// Cap height Green
ctx.setFillColor(CGColor(srgbRed: 0, green: 1, blue: 0, alpha: 0.5))
ctx.fill(CGRect(x: 0, y: ascent - capHeight, width: drawingRect.width, height: capHeight))

if drawingRect.height - ascent + descent + leading > 0 {
// Remainder
ctx.setFillColor(CGColor(srgbRed: 0, green: 1, blue: 1, alpha: 0.5))
ctx
.fill(CGRect(
x: 0,
y: ascent + descent + leading,
width: drawingRect.width,
height: drawingRect.height - ascent + descent + leading))
}
}
}

private func updateTextContent() {
guard needsContentUpdate else { return }
needsContentUpdate = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ final class LayerTransformProperties: NodePropertyMap, KeypathSearchable {
opacity = NodeProperty(provider: KeyframeInterpolator(keyframes: transform.opacity.keyframes))

var propertyMap: [String: AnyNodeProperty] = [
"Anchor Point" : anchor,
PropertyName.scale.rawValue : scale,
"Anchor Point": anchor,
PropertyName.scale.rawValue: scale,
PropertyName.rotation.rawValue: rotationZ,
"Rotation X" : rotationX,
"Rotation Y" : rotationY,
"Rotation Z" : rotationZ,
PropertyName.opacity.rawValue : opacity,
"Rotation X": rotationX,
"Rotation Y": rotationY,
"Rotation Z": rotationZ,
PropertyName.opacity.rawValue: opacity,
]

if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class RoundedCornersProperties: NodePropertyMap, KeypathSearchable {
init(roundedCorners: RoundedCorners) {
keypathName = roundedCorners.name
radius = NodeProperty(provider: KeyframeInterpolator(keyframes: roundedCorners.radius.keyframes))
keypathProperties = ["Radius" : radius]
keypathProperties = ["Radius": radius]
properties = Array(keypathProperties.values)
}

Expand Down
Loading

0 comments on commit 9acaa6d

Please sign in to comment.