feat: wire list view models into AppModel, add strings, list helpers and debug snapshot mode
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#if DEBUG
|
||||
import AppKit
|
||||
import SstUI
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
enum Snapshot {
|
||||
static func run(prefix: String) {
|
||||
_ = NSApplication.shared
|
||||
SnapshotMode.isActive = true
|
||||
let model = AppModel(preview: true)
|
||||
for section in AppModel.Section.allCases {
|
||||
model.section = section
|
||||
let view = HStack(spacing: 0) {
|
||||
MainWindow().environment(\.colorScheme, .light)
|
||||
MainWindow().environment(\.colorScheme, .dark)
|
||||
}
|
||||
.environmentObject(model)
|
||||
.environmentObject(model.settings)
|
||||
.frame(width: Layout.windowDefaultWidth * 2, height: Layout.windowDefaultHeight)
|
||||
|
||||
let renderer = ImageRenderer(content: view)
|
||||
renderer.scale = 1
|
||||
if let tiff = renderer.nsImage?.tiffRepresentation,
|
||||
let png = NSBitmapImageRep(data: tiff)?.representation(using: .png, properties: [:]) {
|
||||
try? png.write(to: URL(fileURLWithPath: "\(prefix)-\(section.rawValue).png"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user