import SwiftUI /// Die Platzhalterfläche, solange ein Bild noch lädt. /// /// Ein wandernder Lichtschein statt eines Spinners: er zeigt die endgültige /// Form des Inhalts schon an, wodurch die Startseite beim Aufbauen nicht /// springt. public struct ShimmerPlaceholder: View { @State private var phase: CGFloat = -1 /// Bewegte Flächen sind für manche Menschen unangenehm; bei aktivierter /// Systemeinstellung bleibt der Platzhalter deshalb einfach ruhig stehen. @Environment(\.accessibilityReduceMotion) private var reduceMotion public init() {} public var body: some View { Rectangle() .fill(Color.flaroPlaceholder) .overlay { if !reduceMotion { GeometryReader { proxy in LinearGradient( colors: [.clear, Color.white.opacity(0.06), .clear], startPoint: .leading, endPoint: .trailing ) .frame(width: proxy.size.width * 0.6) .offset(x: phase * proxy.size.width * 1.6) } } } .clipped() .onAppear { guard !reduceMotion else { return } withAnimation(.linear(duration: 1.4).repeatForever(autoreverses: false)) { phase = 1 } } .accessibilityHidden(true) } }