|
@@ -41,6 +41,8 @@ class PDFLNativeViewFactory: NSObject, FlutterPlatformViewFactory {
|
|
|
|
|
|
class FLNativeView: NSObject, FlutterPlatformView {
|
|
|
private var _view: UIView
|
|
|
+ private var _pdfView:CPDFView
|
|
|
+ private var _pdfDocument:CPDFDocument
|
|
|
init(
|
|
|
frame: CGRect,
|
|
|
viewIdentifier viewId: Int64,
|
|
@@ -51,12 +53,15 @@ class FLNativeView: NSObject, FlutterPlatformView {
|
|
|
|
|
|
let document = arguments["document"];
|
|
|
let configuration = arguments["configuration"] as! [String: AnyObject];
|
|
|
-
|
|
|
- print("test------>\(document)")
|
|
|
|
|
|
_view = UIView()
|
|
|
+ _pdfView = CPDFView(frame:CGRectMake(0, 0, UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height))
|
|
|
+ let encodeString = document?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
|
|
|
+ let fileURL = URL(string:encodeString ?? "")
|
|
|
+ _pdfDocument = CPDFDocument(url: fileURL!)
|
|
|
super.init()
|
|
|
// iOS views can be created here
|
|
|
+
|
|
|
createNativeView(view: _view)
|
|
|
|
|
|
}
|
|
@@ -64,11 +69,11 @@ class FLNativeView: NSObject, FlutterPlatformView {
|
|
|
func view() -> UIView {
|
|
|
return _view
|
|
|
}
|
|
|
+
|
|
|
|
|
|
func createNativeView(view _view: UIView){
|
|
|
- let document = CPDFDocument(url: document)
|
|
|
- let pdfview = CPDFView(frame: _view.frame)
|
|
|
- pdfview.document = document
|
|
|
- _view.addSubview(pdfview)
|
|
|
+
|
|
|
+ _view.addSubview(_pdfView)
|
|
|
+ _pdfView.document = _pdfDocument
|
|
|
}
|
|
|
}
|