示例工程 37-animation

37-animation/Sources/Ch37App/App.swift

swift · 0.8 KB

import Ch37Kit
import SwiftUI
 
@main
struct Ch37App: App {
    @State private var progress = 0.25
 
    var body: some Scene {
        WindowGroup("动画") {
            VStack(spacing: 20) {
                AnimationBoard()
                ExpandingCard()
                ProgressBar(progress: progress)
                    .frame(width: 300)
                    .animation(.easeInOut(duration: 0.6), value: progress)
                HStack {
                    Button("25%") { progress = 0.25 }
                    Button("72%") { progress = 0.72 }
                    Button("100%") { progress = 1 }
                }
                .buttonStyle(.bordered)
            }
            .padding(24)
            .frame(minWidth: 420, minHeight: 520)
        }
        .windowResizability(.contentSize)
    }
}