Files
sizzletracker-android/ios/app/tests/screen_snapshots.swift
T
ReactorcoremeltdownandClaude Opus 5.5 29650b88d7 iOS milestone 3 groundwork: SizzleSession bridge, app shell with tabs, slot-backed editors, screen snapshots
SizzleSession owns the song, engine (192-frame chunks, try-lock on the audio
thread), samples and audio output; AppModel/RootView give the four tabs;
DeviceModel now works on toolbox slots too; make screen-snapshots renders the
app's tabs on the Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:15:28 +01:00

44 lines
1.8 KiB
Swift

// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Renders each app tab (with the demo song loaded) to PNG on the Mac, in an iPad
// portrait and landscape size: `make -C ios screen-snapshots` → build/screens/png/.
import AppKit
import SwiftUI
@main
struct ScreenSnapshots {
@MainActor static func main() {
Snapshot.active = true
setenv("SIZZLE_NO_AUDIO", "1", 1)
let args = CommandLine.arguments
let out = URL(fileURLWithPath: args.count > 1 ? args[1] : "png")
try? FileManager.default.createDirectory(at: out, withIntermediateDirectories: true)
if args.count > 2, let text = try? String(contentsOfFile: args[2]) {
try? SizzleSession.shared.loadProjectText(text)
}
let sizes: [(String, CGSize)] = [("portrait", CGSize(width: 768, height: 1024)), ("landscape", CGSize(width: 1024, height: 768))]
for tab in AppModel.Tab.allCases {
for (orientation, size) in sizes {
let app = AppModel()
app.tab = tab
let view = ScreenHarness(app: app).frame(width: size.width, height: size.height)
let r = ImageRenderer(content: view)
r.scale = 2
guard let img = r.cgImage else { print("FAIL \(tab)"); continue }
let name = "\(tab.rawValue)_\(tab)_\(orientation).png"
try? NSBitmapImageRep(cgImage: img).representation(using: .png, properties: [:])?
.write(to: out.appendingPathComponent(name))
print("wrote \(name)")
}
}
}
}
/// RootView's layout with a given AppModel (RootView owns its own).
private struct ScreenHarness: View {
@ObservedObject var app: AppModel
var body: some View { RootView(model: app) }
}