32 lines
1.0 KiB
Swift
32 lines
1.0 KiB
Swift
#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
|