Skip to content

Commit

Permalink
Audio player for PDF book #57: Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Dec 10, 2019
1 parent 1efa9cf commit 03700ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ struct PDFKitViewRepresentable: NSViewRepresentable {
}
}

func makeCoordinator() -> PDFKitViewRepresentable.Coordinator {
func makeCoordinator() -> Coordinator {
Coordinator(self)
}

func makeNSView(context: Context) -> PDFView {
PDFKitViewRepresentable.pdfView
Self.pdfView
}

func updateNSView(_ uiView: PDFView, context: Context) {
if url == "" || PDFKitViewRepresentable.pdfView.document?.documentURL?.absoluteString == url { return }
if url == "" || Self.pdfView.document?.documentURL?.absoluteString == url { return }
if let url = URL(string: url) {
PDFKitViewRepresentable.pdfView.autoScales = true
PDFKitViewRepresentable.pdfView.document = PDFDocument(url: url)
PDFKitViewRepresentable.pdfView.delegate = context.coordinator
Self.pdfView.autoScales = true
Self.pdfView.document = PDFDocument(url: url)
Self.pdfView.delegate = context.coordinator
}
}

static func getSelectedText() -> String {
guard let selections = PDFKitViewRepresentable.pdfView.currentSelection?.selectionsByLine() else { return "" }
guard let selections = Self.pdfView.currentSelection?.selectionsByLine() else { return "" }

return selections
.map { selection in selection.string! }
Expand All @@ -60,26 +60,26 @@ struct PDFKitViewRepresentable: UIViewRepresentable {
}
}

func makeCoordinator() -> PDFKitViewRepresentable.Coordinator {
func makeCoordinator() -> Coordinator {
Coordinator(self)
}

func makeUIView(context: Context) -> PDFView {
PDFKitViewRepresentable.pdfView
Self.pdfView
}

func updateUIView(_ uiView: PDFView, context: Context) {
if PDFKitViewRepresentable.pdfView.document != nil { return }
if Self.pdfView.document != nil { return }
if let url = url {
PDFKitViewRepresentable.pdfView.autoresizingMask = [.flexibleWidth]
PDFKitViewRepresentable.pdfView.autoScales = true
PDFKitViewRepresentable.pdfView.document = PDFDocument(url: url)
PDFKitViewRepresentable.pdfView.delegate = context.coordinator
Self.pdfView.autoresizingMask = [.flexibleWidth]
Self.pdfView.autoScales = true
Self.pdfView.document = PDFDocument(url: url)
Self.pdfView.delegate = context.coordinator
}
}

static func getSelectedText() -> String {
guard let selections = PDFKitViewRepresentable.pdfView.currentSelection?.selectionsByLine() else { return "" }
guard let selections = Self.pdfView.currentSelection?.selectionsByLine() else { return "" }

return selections
.map { selection in selection.string! }
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslatorMac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>949</string>
<string>959</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.education</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslatorSafari/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1507</string>
<string>1525</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppleEventsUsageDescription</key>
Expand Down

0 comments on commit 03700ea

Please sign in to comment.