Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix old format incompatibility #37

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Screenshot Framer Tests/ScreenshotFramerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ScreenshotFramerTests: XCTestCase {

let layerState = LayerState(title: "First Operation",
layers: [LayoutableObject(type: .background, title: "Background", frame: CGRect(x: 0, y: 0, width: 800, height: 1200), file: "")],
outputConfig: OutputConfig(output: "", fromImageNumber: 1, toImageNumber: 5))
outputConfig: OutputConfig(transparent: false, output: "", fromImageNumber: 1, toImageNumber: 5))
self.layerStateHistory.append(layerState)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ final class ContentViewController: NSViewController, NSMenuItemValidation {
self.scrollView.documentView = self.layoutController.layoutHierarchy(layers: self.lastLayerState.layers)
self.layoutWarningButton.isHidden = self.layoutController.layoutErrors.isEmpty

self.transparencyCheckbox.state = self.lastLayerState.outputConfig.transparent ? .on : .off
self.transparencyCheckbox.state = (self.lastLayerState.outputConfig.transparent ?? false) ? .on : .off
self.textFieldOutput.stringValue = self.lastLayerState.outputConfig.output
self.textFieldFromImageNumber.integerValue = self.lastLayerState.outputConfig.fromImageNumber
self.textFieldToImageNumber.integerValue = self.lastLayerState.outputConfig.toImageNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class ExportController {
guard let url = self.fileController.outputURL(for: self.lastLayerState, viewState: viewState) else { return [.noOutputFile] }

try? fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: nil)
if let data = view.pngData(transparent: self.lastLayerState.outputConfig.transparent) {
if let data = view.pngData(transparent: self.lastLayerState.outputConfig.transparent ?? false) {
try? data.write(to: url, options: .atomic)
}

Expand Down Expand Up @@ -97,7 +97,7 @@ final class ExportController {
guard let url = self.fileController.outputURL(for: self.lastLayerState, viewState: viewStateController.viewState) else { return [.noOutputFile] }

try? fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: nil)
if let data = view.pngData(transparent: self.lastLayerState.outputConfig.transparent) {
if let data = view.pngData(transparent: self.lastLayerState.outputConfig.transparent ?? false) {
try? data.write(to: url, options: .atomic)
}

Expand Down Expand Up @@ -138,7 +138,7 @@ final class ExportController {
let tempURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("Preview \(name).png")

do {
try view.pngData(transparent: self.lastLayerState.outputConfig.transparent)?.write(to: tempURL)
try view.pngData(transparent: self.lastLayerState.outputConfig.transparent ?? false)?.write(to: tempURL)
} catch {
let alert = NSAlert(error: error)
alert.runModal()
Expand Down Expand Up @@ -175,7 +175,7 @@ final class ExportController {
let tempURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("Preview Languages of \(name).png")

do {
try view.pngData(transparent: self.lastLayerState.outputConfig.transparent)?.write(to: tempURL)
try view.pngData(transparent: self.lastLayerState.outputConfig.transparent ?? false)?.write(to: tempURL)
} catch {
let alert = NSAlert(error: error)
alert.runModal()
Expand Down
2 changes: 1 addition & 1 deletion Screenshot Framer/Model/OutputConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct OutputConfig: Codable {

// MARK: - Properties

let transparent: Bool
let transparent: Bool?
let output: String
let fromImageNumber: Int
let toImageNumber: Int
Expand Down