Skip to content

Instantly share code, notes, and snippets.

@SoundBlaster
Last active July 29, 2025 20:41
Show Gist options
  • Save SoundBlaster/efce088f3f9f3b72b82d13633d448952 to your computer and use it in GitHub Desktop.
Save SoundBlaster/efce088f3f9f3b72b82d13633d448952 to your computer and use it in GitHub Desktop.
Qwen3-30b-a3b-2507-4bit
// MIT Licence
//
// LLM: qwen/qwen3-30b-a3b-2507
//
// Software: LMStudio
//
// Prompt in 3 steps:
// 1. I want to built simple SwiftUI app in one file. Help
// 2. Please, return only code in the markdown markup. No comments, no detail text.
// Make this app more complex - add several buttons and functions for them.
// 3. So, make it as if You are a Senior iOS Developer and Architect. Make it as 10 of 10 point grade.
//
// Final response info: 43.37 tok/sec • 2183 tokens • 1.63s to first token • Stop reason: EOS Token Found
import SwiftUI
@main
struct AdvancedApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
@StateObject private var viewModel = AppViewModel()
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(viewModel)
.onOpenURL { url in
viewModel.handleDeepLink(url)
}
.onAppear {
viewModel.onAppLaunch()
}
}
}
}
class AppViewModel: ObservableObject {
@Published var count = 0
@Published var randomValue = 0
@Published var timerValue = 0
@Published var isDarkMode = false
@Published var isTimerRunning = false
@Published var alertMessage = ""
@Published var showAlertDialog = false
@Published var showTimerAlert = false
@Published var timerInterval: TimeInterval = 1.0
private var timer: Timer?
private var isTimerInitialized = false
private let randomGenerator = RandomNumberGenerator()
func onAppLaunch() {
isDarkMode = UserDefaults.standard.bool(forKey: "isDarkMode")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.randomValue = self.randomGenerator.generate(min: 0, max: 100)
}
}
func increment() {
count += 1
updateRandomValue()
}
func decrement() {
count -= 1
updateRandomValue()
}
func reset() {
count = 0
timerValue = 0
isTimerRunning = false
stopTimer()
}
func toggleDarkMode() {
isDarkMode.toggle()
UserDefaults.standard.set(isDarkMode, forKey: "isDarkMode")
UserDefaults.standard.synchronize()
}
func triggerRandom() {
randomValue = randomGenerator.generate(min: 0, max: 100)
alertMessage = "Random value updated: \(randomValue)"
showAlertDialog = true
}
func startTimer() {
guard !isTimerRunning else { return }
timerValue = 10
isTimerRunning = true
startTimer()
}
func stopTimer() {
timer?.invalidate()
timer = nil
isTimerRunning = false
}
private func startTimer() {
guard !isTimerInitialized else { return }
timer = Timer.scheduledTimer(withTimeInterval: timerInterval, repeats: true) { _ in
DispatchQueue.main.async {
if self.timerValue > 0 {
self.timerValue -= 1
} else {
self.stopTimer()
self.showTimerAlert = true
}
}
}
isTimerInitialized = true
}
private func updateRandomValue() {
if count % 5 == 0 && count > 0 {
randomValue = randomGenerator.generate(min: 0, max: 100)
}
}
func handleDeepLink(_ url: URL) {
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return }
if components.path == "/reset" {
reset()
}
}
}
private class RandomNumberGenerator {
func generate(min: Int, max: Int) -> Int {
Int.random(in: min...max)
}
}
struct ContentView: View {
@EnvironmentObject private var viewModel: AppViewModel
@State private var isPresentingSheet = false
@State private var sheetType: SheetType = .none
enum SheetType {
case help, settings
case none
}
var body: some View {
NavigationView {
ScrollView {
LazyVStack(spacing: 24) {
HeaderView()
CounterSection()
ButtonSection()
TimerSection()
FooterSection()
}
.padding(.horizontal)
.padding(.vertical, 12)
}
.navigationTitle("Advanced App")
.navigationBarTitleDisplayMode(.large)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: { isPresentingSheet = true }) {
Image(systemName: "ellipsis")
.font(.title2)
}
.sheet(isPresented: $isPresentingSheet) {
NavigationStack {
SheetView(sheetType: $sheetType)
.navigationTitle("Settings")
.navigationBarTitleDisplayMode(.inline)
}
}
}
}
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
viewModel.onAppLaunch()
}
.alert("Random Value Updated", isPresented: $viewModel.showAlertDialog) {
Button("OK") { }
} message: {
Text(viewModel.alertMessage)
}
.alert("Timer Finished", isPresented: $viewModel.showTimerAlert) {
Button("Close") { }
} message: {
Text("The 10-second timer has completed.")
}
}
}
struct HeaderView: View {
@EnvironmentObject private var viewModel: AppViewModel
var body: some View {
HStack {
Image(systemName: "sparkles")
.font(.title2)
.foregroundColor(.blue)
Text("Advanced SwiftUI Architecture")
.font(.title2)
.fontWeight(.semibold)
Spacer()
}
.padding(.horizontal)
.padding(.top, 12)
}
}
struct CounterSection: View {
@EnvironmentObject private var viewModel: AppViewModel
var body: some View {
VStack(alignment: .leading, spacing: 8) {
Text("Counter")
.font(.headline)
.foregroundColor(.primary)
HStack(spacing: 12) {
Button("▲ Increment") {
viewModel.increment()
}
.buttonStyle(.borderedProminent)
.tint(.blue)
Button("▼ Decrement") {
viewModel.decrement()
}
.buttonStyle(.bordered)
.tint(.red)
Button("🔄 Reset") {
viewModel.reset()
}
.buttonStyle(.bordered)
.tint(.orange)
}
HStack {
Text("Count: \(viewModel.count)")
.font(.title3)
.fontWeight(.bold)
Spacer()
Text("Random: \(viewModel.randomValue)")
.font(.caption)
.foregroundColor(.secondary)
}
}
.padding()
.background(Color(UIColor.systemBackground))
.cornerRadius(12)
.shadow(radius: 4)
}
}
struct ButtonSection: View {
@EnvironmentObject private var viewModel: AppViewModel
var body: some View {
VStack(alignment: .leading, spacing: 8) {
Text("Actions")
.font(.headline)
.foregroundColor(.primary)
HStack(spacing: 12) {
Button("🎲 Random") {
viewModel.triggerRandom()
}
.buttonStyle(.borderedProminent)
.tint(.green)
Button("🌙 Dark Mode") {
viewModel.toggleDarkMode()
}
.buttonStyle(.bordered)
.tint(.purple)
}
}
.padding()
.background(Color(UIColor.systemBackground))
.cornerRadius(12)
.shadow(radius: 4)
}
}
struct TimerSection: View {
@EnvironmentObject private var viewModel: AppViewModel
var body: some View {
VStack(alignment: .leading, spacing: 8) {
Text("Timer")
.font(.headline)
.foregroundColor(.primary)
HStack {
Text("Time: \(viewModel.timerValue)")
.font(.title3)
.fontWeight(.bold)
.foregroundColor(viewModel.isTimerRunning ? .green : .secondary)
Spacer()
Button(viewModel.isTimerRunning ? "⏸️ Stop" : "▶️ Start") {
if viewModel.isTimerRunning {
viewModel.stopTimer()
} else {
viewModel.startTimer()
}
}
.buttonStyle(.borderedProminent)
.tint(.teal)
}
}
.padding()
.background(Color(UIColor.systemBackground))
.cornerRadius(12)
.shadow(radius: 4)
}
}
struct FooterSection: View {
@EnvironmentObject private var viewModel: AppViewModel
var body: some View {
VStack {
Text("Built with SwiftUI — Enterprise Grade")
.font(.footnote)
.foregroundColor(.secondary)
.padding(.vertical, 4)
Text("Version 1.0.0")
.font(.caption)
.foregroundColor(.secondary)
}
.frame(maxWidth: .infinity)
.padding(.vertical, 8)
}
}
struct SheetView: View {
@Binding var sheetType: SheetType
@EnvironmentObject private var viewModel: AppViewModel
var body: some View {
List {
Section("App Settings") {
Button("Toggle Dark Mode") {
viewModel.toggleDarkMode()
}
.tint(.purple)
Button("Reset All") {
viewModel.reset()
}
.tint(.red)
}
Section("Help") {
Button("About This App") {
sheetType = .help
}
.tint(.blue)
}
Section("Deep Link") {
Button("Reset via URL") {
guard let url = URL(string: "app://reset") else { return }
UIApplication.shared.open(url)
}
.tint(.orange)
}
}
.navigationTitle("Settings")
.navigationBarTitleDisplayMode(.inline)
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Setup app-level configurations
if !UserDefaults.standard.bool(forKey: "hasLaunchedBefore") {
UserDefaults.standard.set(true, forKey: "hasLaunchedBefore")
UserDefaults.standard.synchronize()
}
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment