Skip to content

Commit

Permalink
[NM-279] Empty pages aren't shown in nimble (#111)
Browse files Browse the repository at this point in the history
* [NM-279] Empty pages aren't shown in nimble

* rename PageDocument method 'onPageLoad' to 'onPageDidLoad'
  • Loading branch information
h1t authored May 8, 2020
1 parent 4449abd commit 18f5f5a
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public final class PageDocument: NimbleDocument, SVGDocumentProtocol {

public override func read(from url: URL, ofType typeName: String) throws {
adapter.load(url.path)
onPageDidLoad()
}

public override func data(ofType typeName: String) throws -> Data {
Expand All @@ -55,6 +56,15 @@ public final class PageDocument: NimbleDocument, SVGDocumentProtocol {
}
return "".data(using: .utf8)!
}

private func onPageDidLoad() {
if let size = adapter.page?.size {
if size.width == 0 || size.height == 0 {
size.width = 320
size.height = 480
}
}
}
}

extension PageDocument: Document {
Expand All @@ -78,11 +88,7 @@ extension PageDocument: CreatableDocument {
public static func createUntitledDocument() -> Document? {
let doc = PageDocument()
doc.adapter.loadTemplatePage()

if let size = doc.adapter.page?.size {
size.width = 320
size.height = 480
}
doc.onPageDidLoad()

return doc
}
Expand Down

0 comments on commit 18f5f5a

Please sign in to comment.