| import SwiftUI | |
| struct ContentView: View { | |
| @State var start = Date() | |
| var body: some View { | |
| TimelineView(.animation) { context in | |
| let time = context.date.timeIntervalSince(start) / 120 | |
| let rotation = 0.8 + 0.2 * abs((cos(.pi * time) + 1.0) / 2.0) | |
| Canvas { context, size in |
| import SwiftUI | |
| // MARK: - Model | |
| @MainActor | |
| @Observable | |
| final class Model { | |
| var rotations: [[Int]] | |
| init(row: Int, column: Int) { | |
| rotations = (0..<row).map { _ in |
| import SwiftUI | |
| struct ContentView: View { | |
| @StateObject private var viewModel = RectsViewModel() | |
| var body: some View { | |
| GeometryReader { geometry in | |
| TimelineView(.animation) { timeline in | |
| Canvas {context, size in | |
| let rects = viewModel.rects |
| import SwiftUI | |
| #Preview { | |
| @Previewable @State var value: Double = 3.0 | |
| VStack { | |
| SampleView() | |
| .environment(\.dynamicTypeSize, .allCases[Int(value)]) | |
| .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing) | |
| .contentTransition(.numericText()) | |
| Text("\(DynamicTypeSize.allCases[Int(value)])") |
| import SwiftUI | |
| struct ContentView: View { | |
| @Environment(\.colorScheme) var scheme | |
| private let date = Date() | |
| private let colors = [Color.green, .pink, .blue, .orange, .purple] | |
| private let titles = ["NEON", "GLOW", "LIGHT", "SHINE", "BRIGHT"] | |
| var body: some View { | |
| TimelineView(.animation) { context in |
| import SwiftUI | |
| // MARK: - RinganimationScreen | |
| /// A screen that displays three animated concentric progress rings. | |
| /// Each ring rotates at a different speed and animates continuously using `TimelineView`. | |
| struct RinganimationScreen: View { | |
| let startTime: Date = .now | |
| var body: some View { |
| import SwiftUI | |
| struct Card: Identifiable, Hashable { | |
| let id = UUID() | |
| let creditID = UUID() | |
| let colors: [Color] | |
| let name: String | |
| let number: String | |
| } |
| import RealityKit | |
| import SwiftUI | |
| struct PointLightsInsideContainerView: View { | |
| @State private var rootEntity: Entity? | |
| @State private var timer: Timer? | |
| @State private var spherePositions: [String: SIMD3<Float>] = [:] | |
| @State private var sphereTargetPositions: [String: SIMD3<Float>] = [:] | |
| @State private var rotationAngle: Float = 0 | |
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack { | |
| TextSampleView(style: .foreground) | |
| TextSampleView(style: .mint) | |
| TextSampleView(style: linearGradient) | |
| } | |
| .font(.largeTitle) |