// // FLNativeViewFactory.m // compdfkit_flutter // // Created by kdanmobile_2 on 2023/7/25. // #import "FLNativeView.h" #import @implementation FLNativeViewFactory { NSObject* _messenger; } - (instancetype)initWithMessenger:(NSObject *)messenger { if (self = [super init]) { _messenger = messenger; } return self; } #pragma mark - FlutterPlatformViewFactory - (NSObject *)createWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id)args { return [[FLNativeView alloc] initWithFrame:frame viewIndentifier:viewId argument:args binaryMessenger:_messenger]; } @end @implementation FLNativeView { UIView *_view; CPDFView *_pdfView; } - (instancetype)initWithFrame:(CGRect)frame viewIndentifier:(int64_t)viewId argument:(id _Nullable)args binaryMessenger:(NSObject *)messenger { self = [super init]; if (self) { NSString *documentFolder = [NSHomeDirectory() stringByAppendingFormat:@"/%@/%@", @"Documents",@"Samples"]; NSString *filePath = [NSString stringWithFormat:@"%@/developer_guide_ios.pdf", documentFolder]; CPDFDocument *document = [[CPDFDocument alloc] initWithURL:[NSURL fileURLWithPath:filePath]]; _pdfView = [[CPDFView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; _pdfView.document = document; _view = [[UIView alloc] init]; [_view addSubview:_pdfView]; } return self; } - (UIView *)view { return _view; } @end