Files
Pulse/Sources/PulseUI/Views/PDFRepresentedView.swift
2022-08-13 17:40:50 -04:00

41 lines
856 B
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The MIT License (MIT)
//
// Copyright (c) 20202022 Alexander Grebenyuk (github.com/kean).
import SwiftUI
#if os(iOS)
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