mirror of
https://github.com/kean/Pulse.git
synced 2026-05-30 21:07:33 +00:00
41 lines
870 B
Swift
41 lines
870 B
Swift
// The MIT License (MIT)
|
|
//
|
|
// Copyright (c) 2020-2024 Alexander Grebenyuk (github.com/kean).
|
|
|
|
import SwiftUI
|
|
|
|
#if os(iOS) || os(visionOS)
|
|
import PDFKit
|
|
|
|
struct PDFKitRepresentedView: UIViewRepresentable {
|
|
let document: PDFDocument
|
|
|
|
func makeUIView(context: Context) -> PDFView {
|
|
let pdfView = PDFView()
|
|
pdfView.document = document
|
|
return pdfView
|
|
}
|
|
|
|
func updateUIView(_ view: PDFView, context: Context) {
|
|
// Do nothing
|
|
}
|
|
}
|
|
#elseif os(macOS)
|
|
import PDFKit
|
|
|
|
struct PDFKitRepresentedView: NSViewRepresentable {
|
|
let document: PDFDocument
|
|
|
|
func makeNSView(context: Context) -> PDFView {
|
|
let pdfView = PDFView()
|
|
pdfView.document = document
|
|
pdfView.autoScales = true
|
|
return pdfView
|
|
}
|
|
|
|
func updateNSView(_ view: PDFView, context: Context) {
|
|
// Do nothing
|
|
}
|
|
}
|
|
#endif
|