From 34bbb40393696565d6a8effcdbbd06601d78e9bc Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 10 Jan 2024 11:55:21 +0100 Subject: [PATCH 1/2] iOS 17 Animation fixed --- Sources/SkeletonUI/Modifiers/SkeletonModifier.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift b/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift index 6d321c6..21945eb 100644 --- a/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift +++ b/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift @@ -3,6 +3,7 @@ import Combine @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public struct SkeletonModifier: ViewModifier { + @State private var phase: CGFloat = 0 let shape: ShapeType let animation: AnimationType let appearance: AppearanceType @@ -10,8 +11,11 @@ public struct SkeletonModifier: ViewModifier { public func body(content: Content) -> some View { content - .modifier(SkeletonAnimatableModifier(CGFloat(integerLiteral: Int(truncating: animate as NSNumber)), appearance).animation(animation.type)) + .modifier(SkeletonAnimatableModifier(phase, appearance)) .clipShape(SkeletonShape(shape)) - .onAppear { animate.toggle() } + .animation(animation.type, value: phase) + .onAppear { + phase = 1 + } } } From af650a816ae867239ff9e9b77b933b185eec1a76 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 10 Jan 2024 12:12:10 +0100 Subject: [PATCH 2/2] Removed @State phase + Minor adjustments in Skeleton Modifier --- Sources/SkeletonUI/Modifiers/SkeletonModifier.swift | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift b/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift index 21945eb..c588d02 100644 --- a/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift +++ b/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift @@ -3,7 +3,6 @@ import Combine @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public struct SkeletonModifier: ViewModifier { - @State private var phase: CGFloat = 0 let shape: ShapeType let animation: AnimationType let appearance: AppearanceType @@ -11,11 +10,9 @@ public struct SkeletonModifier: ViewModifier { public func body(content: Content) -> some View { content - .modifier(SkeletonAnimatableModifier(phase, appearance)) + .modifier(SkeletonAnimatableModifier(animate ? 1 : 0, appearance)) .clipShape(SkeletonShape(shape)) - .animation(animation.type, value: phase) - .onAppear { - phase = 1 - } + .animation(animation.type, value: animate) + .onAppear { animate.toggle() } } }