Created
August 8, 2025 05:58
-
-
Save SoundBlaster/f7bec66526e6a25042afd0a7e1ab5e1b to your computer and use it in GitHub Desktop.
Test GPT-5 with SwiftUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prompt: "Write simple SwiftUI app. Return only code in markdown blocks." | |
import SwiftUI | |
@main | |
struct SimpleSwiftUIApp: App { | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
} | |
} | |
struct ContentView: View { | |
@State private var count = 0 | |
@State private var isOn = true | |
@State private var name: String = "" | |
var body: some View { | |
NavigationView { | |
VStack(spacing: 20) { | |
// Greeting | |
VStack(spacing: 8) { | |
Text("Hello\(name.isEmpty ? "" : ", \(name)")!") | |
.font(.largeTitle).bold() | |
Text("A tiny SwiftUI demo") | |
.foregroundStyle(.secondary) | |
} | |
// Counter | |
VStack(spacing: 12) { | |
Text("\(count)") | |
.font(.system(size: 56, weight: .bold, design: .rounded)) | |
.monospacedDigit() | |
.contentTransition(.numericText()) | |
.animation(.spring(), value: count) | |
HStack { | |
Button(role: .destructive) { | |
count = 0 | |
} label: { | |
Label("Reset", systemImage: "arrow.counterclockwise") | |
} | |
Spacer() | |
Button { | |
count -= 1 | |
} label: { | |
Label("Minus", systemImage: "minus.circle.fill") | |
} | |
Button { | |
count += 1 | |
} label: { | |
Label("Plus", systemImage: "plus.circle.fill") | |
} | |
.buttonStyle(.borderedProminent) | |
} | |
} | |
.padding() | |
.background(.thinMaterial) | |
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) | |
// Progress | |
VStack(alignment: .leading, spacing: 8) { | |
Text("Progress to next 10") | |
.font(.subheadline) | |
.foregroundStyle(.secondary) | |
ProgressView(value: Double(count % 10), total: 10) | |
Text("\(count % 10) / 10") | |
.font(.caption) | |
.monospacedDigit() | |
.foregroundStyle(.secondary) | |
} | |
// Controls | |
Form { | |
Section("Settings") { | |
Toggle("Fancy Mode", isOn: $isOn) | |
TextField("Your name", text: $name) | |
.textInputAutocapitalization(.words) | |
} | |
Section("About") { | |
Label("Built with SwiftUI", systemImage: "swift") | |
Label("State, Animation, Form", systemImage: "gearshape") | |
} | |
} | |
.frame(maxHeight: 280) | |
.scrollDisabled(true) | |
Spacer(minLength: 0) | |
} | |
.padding() | |
.navigationTitle("Simple App") | |
.preferredColorScheme(isOn ? nil : .light) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment