markiv / SwiftUI-Shimmer

Shimmer is a super-light modifier that adds a shimmering effect to any SwiftUI View, for example, to show that an operation is in progress. It works well on light and dark modes, and across iOS, macOS, tvOS, watchOS and visionOS.
MIT License
1.13k stars 62 forks source link

Shimmer not working on XCode 15.0 beta with iOS 17.0 #11

Closed RakeshTatekonda609 closed 1 year ago

RakeshTatekonda609 commented 1 year ago

Shimmer animation is not working on XCode 15.0 beta with iOS 17.0

BlaT2512 commented 1 year ago

+1 no animation from it at all

aviwad commented 1 year ago

Same here.

Kyle-Ye commented 1 year ago

Some debug info I can provide:

If we do the following 3 things, We can see a normal LinearGradient animation.

If not, we can only see 2 strange phase state after some time.

Tested under Xcode 15 beta 2(15A5161b) with iOS 17 beta 2

AnimationBug.zip

I believe this a bug introduced upstream. And should be fixed by Apple's SwiftUI team before a RC release. I've filed a feedback - FB12428834 to Apple's Feedback system to do a follow-up on this.

markiv commented 1 year ago

Thanks for the feedback and the hints! @Kyle-Ye I tried the code you provided, thank you! Using the gradient as an overlay changes the appearance and behaviour considerably, though.

I was able to find a workaround solution by animating the gradient's start and end unit points, rather than its stop locations as before.

Please check this out, currently on this branch: https://github.com/markiv/SwiftUI-Shimmer/tree/iOS17-animate-start-end-points

I've tested this on iOS 15, 16 and 17 (Xcode 15 beta 6), plus also macOS, watchOS and visionOS. 😎

I also added the ability to override the default gradient and introduced a customisable "band size" (the size of the animated mask's "band").

Would love to get your feedback.

Thanks again. 🙏🏽

Kyle-Ye commented 1 year ago

I was able to find a workaround solution by animating the gradient's start and end unit points, rather than its stop locations as before.

Please check this out, currently on this branch: iOS17-animate-start-end-points

Yeah, it works for me. Thanks for the fixing.

Tested it under Xcode 15 beta 6 with iOS 17.

Kyle-Ye commented 6 months ago

I believe this a bug introduced upstream. And should be fixed by Apple's SwiftUI team before a RC release. I've filed a feedback - FB12428834 to Apple's Feedback system to do a follow-up on this.

Update on 2024/03/14:

Kyle-Ye commented 6 months ago

Update on 2024/03/26:

Here is the final reply from Apple (FB is closed):

After reviewing your feedback, we have some additional information for you, or some additional information, or action is necessary for this issue:

The use of .animation(_:) is deprecated and is also not recommended for this context.

In theory, you could use the new .animation(_:value:) and apply it to the content inside of Shimmer, however because the animation in question repeats forever, you run the risk of triggering multiple endless, overlapping animations.

We recommend using a withAnimation when phase is being set:

content
    .modifier(
        AnimatedMask(phase: phase)
    )
    .onAppear {
        withAnimation(animation) {
            phase = 0.8
        }
    }

When using the GestureMask and the rest of the expected traits in the provided sample project, this produces what seems to be the expected result.