Skip to content

Commit 9cc4605

Browse files
committed
Implement new and old arch on iOS
1 parent e28185f commit 9cc4605

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

ReactNativePdfRenderer.podspec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ require 'json'
33
packageJson = JSON.parse(File.read('package.json'))
44
version = packageJson["version"]
55
repository = packageJson["repository"]["url"]
6+
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
67

78
Pod::Spec.new do |s|
89
s.name = "ReactNativePdfRenderer"
@@ -19,5 +20,9 @@ Pod::Spec.new do |s|
1920

2021
s.frameworks = 'PDFKit'
2122

22-
install_modules_dependencies(s)
23+
if fabric_enabled
24+
install_modules_dependencies(s)
25+
else
26+
s.dependency "React-Core"
27+
end
2328
end

ios/ReactNativePdfRendererLibrary/RNPDFView.mm

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@ @implementation RNPDFView
2929

3030
-(void) setParams:(NSDictionary*) params {
3131
NSString *source = [params objectForKey:@"source"];
32+
NSString *maxZoomString = [params objectForKey:@"maxZoom"];
33+
NSString *singlePageString = [params objectForKey:@"singlePage"];
3234

33-
float maxZoom = [params objectForKey:@"maxZoom"] != nil
34-
? [[params objectForKey:@"maxZoom"] floatValue]
35-
: 0;
36-
37-
BOOL singlePage = [params objectForKey:@"singlePage"] != nil
38-
? [[params objectForKey:@"singlePage"] boolValue]
39-
: NO;
40-
41-
if ([params objectForKey:@"source"] != nil) {
35+
if (source != nil) {
36+
float maxZoom = maxZoomString != nil ? [maxZoomString floatValue] : 0;
37+
BOOL singlePage = singlePageString != nil ? [singlePageString boolValue] : NO;
38+
4239
if (![source hasPrefix:@"file://"]) {
4340
source = [NSString stringWithFormat:@"%@%@", @"file://", source];
4441
}

ios/ReactNativePdfRendererLibrary/RNPdfRendererModule.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ - (UIView *)view
4646
return view;
4747
}
4848

49+
- (void)dealloc
50+
{
51+
if (observerAdded) {
52+
observerAdded = NO;
53+
[NSNotificationCenter.defaultCenter removeObserver:self name:PDFViewPageChangedNotification object:nil];
54+
}
55+
}
56+
4957
- (void)handlePageChange:(NSNotification*) notification {
5058
if ([RNPDFView class] != [notification.object class]) {
5159
return;

0 commit comments

Comments
 (0)