|
| 1 | +// |
| 2 | +// HomeViewSkeleton.swift |
| 3 | +// RubyEvents |
| 4 | +// |
| 5 | +// Created by Marco Roth on 31.03.2025. |
| 6 | +// |
| 7 | + |
| 8 | +import SwiftUI |
| 9 | + |
| 10 | +struct HomeViewSkeleton: View { |
| 11 | + @State private var isAnimating = false |
| 12 | + |
| 13 | + var body: some View { |
| 14 | + GeometryReader { geometry in |
| 15 | + ScrollView() { |
| 16 | + RoundedRectangle(cornerRadius: 0) |
| 17 | + .fill(Color.gray.opacity(0.2)) |
| 18 | + .frame(maxWidth: .infinity) |
| 19 | + .frame(height: (geometry.size.height / 5) * 3.5) |
| 20 | + .opacity(isAnimating ? 1 : 0.2) |
| 21 | + .animation(Animation.easeInOut(duration: 1.5).repeatForever(autoreverses: true), value: isAnimating) |
| 22 | + |
| 23 | + VStack(spacing: 24) { |
| 24 | + ForEach(0..<2, id: \.self) { index in |
| 25 | + VStack(alignment: .leading, spacing: 12) { |
| 26 | + RoundedRectangle(cornerRadius: 4) |
| 27 | + .fill(Color.gray.opacity(0.2)) |
| 28 | + .frame(width: 150, height: 24) |
| 29 | + .padding(.horizontal) |
| 30 | + .opacity(isAnimating ? 0.5 : 0.5) |
| 31 | + .animation(Animation.easeInOut(duration: 1.5).repeatForever(autoreverses: true).delay(0.1 * Double(index)), value: isAnimating) |
| 32 | + |
| 33 | + HStack(spacing: 16) { |
| 34 | + ForEach(0..<4, id: \.self) { itemIndex in |
| 35 | + RoundedRectangle(cornerRadius: 8) |
| 36 | + .fill(Color.gray.opacity(0.2)) |
| 37 | + .frame(width: 200, height: 120) |
| 38 | + .opacity(isAnimating ? 1 : 0.5) |
| 39 | + .animation(Animation.easeInOut(duration: 1.5).repeatForever(autoreverses: true).delay(0.1 * Double(itemIndex)), value: isAnimating) |
| 40 | + } |
| 41 | + } |
| 42 | + .padding(.horizontal) |
| 43 | + |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + .padding(.top, 24) |
| 48 | + } |
| 49 | + .edgesIgnoringSafeArea(.top) |
| 50 | + } |
| 51 | + .onAppear { |
| 52 | + App.instance.tabBarController.hideNavigationBarFor(title: "Home") |
| 53 | + isAnimating = true |
| 54 | + } |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +#Preview { |
| 59 | + HomeViewSkeleton() |
| 60 | +} |
0 commit comments