London Escorts sunderland escorts 1v1.lol unblocked yohoho 76 https://www.symbaloo.com/mix/yohoho?lang=EN yohoho https://www.symbaloo.com/mix/agariounblockedpvp https://yohoho-io.app/ https://www.symbaloo.com/mix/agariounblockedschool1?lang=EN
7.6 C
New York
Saturday, February 1, 2025

Swift UI shimmer modifier now not works on IOS 17


Whats up Ive been utilizing the identical shimmer modifier for some time now. I only recently up to date to the brand new IOS and the shimmer modifier now not works. I made certain nothing in my code was depreciated. Im not sure as to approach it now not features, I assume it is because of new updates in the way in which IOS animates issues. Id admire some perception. Thanks.

import SwiftUI

public struct Shimmer: ViewModifier {
    let animation: Animation
    @State non-public var section: CGFloat = 0

    public init(animation: Animation = Self.defaultAnimation) {
        self.animation = animation
    }

    public static let defaultAnimation = Animation.linear(period: 1.5).repeatForever(autoreverses: false)

    public init(period: Double = 1.5, bounce: Bool = false, delay: Double = 0) {
        self.animation = .linear(period: period)
            .repeatForever(autoreverses: bounce)
            .delay(delay)
    }

    public func physique(content material: Content material) -> some View {
        content material
            .modifier(
                AnimatedMask(section: section).animation(animation)
            )
            .onAppear { section = 0.8 }
    }

    struct AnimatedMask: AnimatableModifier {
        var section: CGFloat = 0

        var animatableData: CGFloat {
            get { section }
            set { section = newValue }
        }

        func physique(content material: Content material) -> some View {
            content material
                .masks(GradientMask(section: section).scaleEffect(4))
        }
    }

    struct GradientMask: View {
        let section: CGFloat
        let centerColor = Shade.black
        let edgeColor = Shade.black.opacity(0.3)
        @Surroundings(.layoutDirection) non-public var layoutDirection

        var physique: some View {
            let isRightToLeft = layoutDirection == .rightToLeft
            LinearGradient(
                gradient: Gradient(stops: [
                    .init(color: edgeColor, location: phase),
                    .init(color: centerColor, location: phase + 0.1),
                    .init(color: edgeColor, location: phase + 0.2)
                ]),
                startPoint: isRightToLeft ? .bottomTrailing : .topLeading,
                endPoint: isRightToLeft ? .topLeading : .bottomTrailing
            )
        }
    }
}

public extension View {
    @ViewBuilder func shimmering(
        energetic: Bool = true, period: Double = 1.5, bounce: Bool = false, delay: Double = 0
    ) -> some View {
        if energetic {
            self.modifier(Shimmer(period: period, bounce: bounce, delay: delay))
        } else {
            self
        }
    }
    
    @ViewBuilder func shimmering(energetic: Bool = true, animation: Animation = Shimmer.defaultAnimation) -> some View {
        if energetic {
            self.modifier(Shimmer(animation: animation))
        } else {
            self
        }
    }
}

Related Articles

Social Media Auto Publish Powered By : XYZScripts.com