13
13
#import " PSPDFKitPlugin.h"
14
14
#import < WebKit/WebKit.h>
15
15
#import < PSPDFKit/PSPDFKit.h>
16
+ #import < PSPDFKitUI/PSPDFKitUI.h>
16
17
17
18
@interface PSPDFKitPlugin () <PSPDFViewControllerDelegate, PSPDFFlexibleToolbarContainerDelegate>
18
19
@@ -544,7 +545,7 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
544
545
545
546
@" PSPDFPageTransition" :
546
547
547
- @{@" scrollPerPage " : @(PSPDFPageTransitionScrollPerPage ),
548
+ @{@" scrollPerSpread " : @(PSPDFPageTransitionScrollPerSpread ),
548
549
@" scrollContinuous" : @(PSPDFPageTransitionScrollContinuous),
549
550
@" curl" : @(PSPDFPageTransitionCurl)},
550
551
@@ -571,18 +572,18 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
571
572
@" openSafari" : @(PSPDFLinkActionOpenSafari),
572
573
@" inlineBrowser" : @(PSPDFLinkActionInlineBrowser)},
573
574
574
- @" PSPDFHUDViewMode " :
575
+ @" PSPDFUserInterfaceViewMode " :
575
576
576
- @{@" always" : @(PSPDFHUDViewModeAlways ),
577
- @" automatic" : @(PSPDFHUDViewModeAutomatic ),
578
- @" automaticNoFirstLastPage" : @(PSPDFHUDViewModeAutomaticNoFirstLastPage ),
579
- @" never" : @(PSPDFHUDViewModeNever )},
577
+ @{@" always" : @(PSPDFUserInterfaceViewModeAlways ),
578
+ @" automatic" : @(PSPDFUserInterfaceViewModeAutomatic ),
579
+ @" automaticNoFirstLastPage" : @(PSPDFUserInterfaceViewModeAutomaticNoFirstLastPage ),
580
+ @" never" : @(PSPDFUserInterfaceViewModeNever )},
580
581
581
- @" PSPDFHUDViewAnimation " :
582
+ @" PSPDFUserInterfaceViewAnimation " :
582
583
583
- @{@" none" : @(PSPDFHUDViewAnimationNone ),
584
- @" fade" : @(PSPDFHUDViewAnimationFade ),
585
- @" slide" : @(PSPDFHUDViewAnimationSlide )},
584
+ @{@" none" : @(PSPDFUserInterfaceViewAnimationNone ),
585
+ @" fade" : @(PSPDFUserInterfaceViewAnimationFade ),
586
+ @" slide" : @(PSPDFUserInterfaceViewAnimationSlide )},
586
587
587
588
@" PSPDFThumbnailBarMode" :
588
589
@@ -654,25 +655,6 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
654
655
return enumsByType[type];
655
656
}
656
657
657
- // /// Status bar style. (old status will be restored regardless of the style chosen)
658
- // typedef NS_ENUM(NSInteger, PSPDFStatusBarStyleSetting) {
659
- // PSPDFStatusBarInherit, // Don't change status bar style, but show/hide statusbar on HUD events.
660
- // PSPDFStatusBarSmartBlack, // UIStatusBarStyleBlackOpaque on iPad, UIStatusBarStyleBlackTranslucent on iPhone.
661
- // PSPDFStatusBarSmartBlackHideOnIpad,// Similar to PSPDFStatusBarSmartBlack, but also hides statusBar on iPad.
662
- // PSPDFStatusBarBlackOpaque, // Opaque Black everywhere.
663
- // PSPDFStatusBarDefault, // Default statusbar (white on iPhone/black on iPad).
664
- // PSPDFStatusBarDisable, // Never show status bar.
665
- // };
666
-
667
- // // Customize how a single page should be displayed.
668
- // typedef NS_ENUM(NSInteger, PSPDFPageRenderingMode) {
669
- // PSPDFPageRenderingModeThumbnailThenFullPage, // Load cached page async.
670
- // PSPDFPageRenderingModeFullPage, // Load cached page async, no upscaled thumb.
671
- // PSPDFPageRenderingModeFullPageBlocking, // Load cached page directly.
672
- // PSPDFPageRenderingModeThumbnailThenRender, // Don't use cached page but thumb.
673
- // PSPDFPageRenderingModeRender // Don't use cached page nor thumb.
674
- // };
675
-
676
658
#pragma mark License Key
677
659
678
660
- (void )setLicenseKey : (CDVInvokedUrlCommand *)command {
@@ -768,7 +750,7 @@ - (void)setRenderAnnotationTypesForPSPDFDocumentWithJSON:(NSArray *)options
768
750
769
751
- (void )setPageTransitionForPSPDFViewControllerWithJSON : (NSString *)transition
770
752
{
771
- PSPDFPageTransition pageTransition = (PSPDFPageTransition) [self enumValueForKey: transition ofType: @" PSPDFPageTransition" withDefault: PSPDFPageTransitionScrollPerPage ];
753
+ PSPDFPageTransition pageTransition = (PSPDFPageTransition) [self enumValueForKey: transition ofType: @" PSPDFPageTransition" withDefault: PSPDFPageTransitionScrollPerSpread ];
772
754
[_pdfController updateConfigurationWithBuilder: ^(PSPDFConfigurationBuilder *builder) {
773
755
builder.pageTransition = pageTransition;
774
756
}];
@@ -846,35 +828,35 @@ - (NSString *)linkActionAsJSON
846
828
return [self enumKeyForValue: _pdfController.configuration.linkAction ofType: @" PSPDFLinkAction" ];
847
829
}
848
830
849
- - (void )setHUDViewModeForPSPDFViewControllerWithJSON : (NSString *)mode
831
+ - (void )setUserInterfaceViewModeForPSPDFViewControllerWithJSON : (NSString *)mode
850
832
{
851
- PSPDFHUDViewMode HUDViewMode = (PSPDFHUDViewMode ) [self enumValueForKey: mode ofType: @" PSPDFHUDViewMode " withDefault: PSPDFHUDViewModeAutomatic ];
833
+ PSPDFUserInterfaceViewMode userInterfaceViewMode = (PSPDFUserInterfaceViewMode ) [self enumValueForKey: mode ofType: @" PSPDFUserInterfaceViewMode " withDefault: PSPDFUserInterfaceViewModeAutomatic ];
852
834
[_pdfController updateConfigurationWithBuilder: ^(PSPDFConfigurationBuilder *builder) {
853
- builder.HUDViewMode = HUDViewMode ;
835
+ builder.userInterfaceViewMode = userInterfaceViewMode ;
854
836
}];
855
837
}
856
838
857
- - (NSString *)HUDViewModeAsJSON
839
+ - (NSString *)userInterfaceViewModeAsJSON
858
840
{
859
- return [self enumKeyForValue: _pdfController.configuration.HUDViewMode ofType: @" PSPDFHUDViewMode " ];
841
+ return [self enumKeyForValue: _pdfController.configuration.userInterfaceViewMode ofType: @" PSPDFUserInterfaceViewMode " ];
860
842
}
861
843
862
- - (void )setHUDViewAnimationForPSPDFViewControllerWithJSON : (NSString *)mode
844
+ - (void )setUserInterfaceViewAnimationForPSPDFViewControllerWithJSON : (NSString *)mode
863
845
{
864
- PSPDFHUDViewAnimation HUDViewAnimation = (PSPDFHUDViewAnimation ) [self enumValueForKey: mode ofType: @" HUDViewAnimation " withDefault: PSPDFHUDViewAnimationFade ];
846
+ PSPDFUserInterfaceViewAnimation userInterfaceViewAnimation = (PSPDFUserInterfaceViewAnimation ) [self enumValueForKey: mode ofType: @" UserInterfaceViewAnimation " withDefault: PSPDFUserInterfaceViewAnimationFade ];
865
847
[_pdfController updateConfigurationWithBuilder: ^(PSPDFConfigurationBuilder *builder) {
866
- builder.HUDViewAnimation = HUDViewAnimation ;
848
+ builder.userInterfaceViewAnimation = userInterfaceViewAnimation ;
867
849
}];
868
850
}
869
851
870
- - (NSString *)HUDViewAnimationAsJSON
852
+ - (NSString *)userInterfaceViewAnimationAsJSON
871
853
{
872
- return [self enumKeyForValue: _pdfController.configuration.HUDViewAnimation ofType: @" PSPDFHUDViewAnimation " ];
854
+ return [self enumKeyForValue: _pdfController.configuration.userInterfaceViewAnimation ofType: @" PSPDFUserInterfaceViewAnimation " ];
873
855
}
874
856
875
- - (void )setHUDVisibleAnimatedForPSPDFViewControllerWithJSON : (NSNumber *)visible
857
+ - (void )setUserInterfaceVisibleAnimatedForPSPDFViewControllerWithJSON : (NSNumber *)visible
876
858
{
877
- [_pdfController setHUDVisible : [visible boolValue ] animated: YES ];
859
+ [_pdfController setUserInterfaceVisible : [visible boolValue ] animated: YES ];
878
860
}
879
861
880
862
- (void )setPageAnimatedForPSPDFViewControllerWithJSON : (NSNumber *)page
@@ -1027,7 +1009,7 @@ - (void)present:(CDVInvokedUrlCommand *)command {
1027
1009
if (path) {
1028
1010
// configure document
1029
1011
NSURL *url = [self pdfFileURLWithPath: path];
1030
- _pdfDocument = [PSPDFDocument documentWithURL : url];
1012
+ _pdfDocument = [[ PSPDFDocument alloc ] initWithURL : url];
1031
1013
[self setOptions: newOptions forObject: _pdfDocument animated: NO ];
1032
1014
}
1033
1015
@@ -1097,7 +1079,7 @@ - (void)search:(CDVInvokedUrlCommand *)command
1097
1079
- (void )saveAnnotations : (CDVInvokedUrlCommand *)command
1098
1080
{
1099
1081
// Completion handler is called on the main queue
1100
- [_pdfController.document saveWithCompletionHandler: ^(NSError *error, NSArray <PSPDFAnnotation *> *savedAnnotations) {
1082
+ [_pdfController.document saveWithOptions: nil completionHandler: ^(NSError * _Nullable error, NSArray <__kindof PSPDFAnnotation *> * _Nonnull savedAnnotations) {
1101
1083
[self .commandDelegate sendPluginResult: [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: [self dictionaryWithError: error]] callbackId: command.callbackId];
1102
1084
}];
1103
1085
}
@@ -1229,15 +1211,15 @@ - (void)getPageCount:(CDVInvokedUrlCommand *)command
1229
1211
- (void )scrollToNextPage : (CDVInvokedUrlCommand *)command
1230
1212
{
1231
1213
BOOL animated = [[command argumentAtIndex: 0 withDefault: @NO ] boolValue ];
1232
- [_pdfController scrollToNextPageAnimated : animated];
1214
+ [_pdfController.documentViewController scrollToNextSpreadAnimated : animated];
1233
1215
[self .commandDelegate sendPluginResult: [CDVPluginResult resultWithStatus: CDVCommandStatus_OK]
1234
1216
callbackId: command.callbackId];
1235
1217
}
1236
1218
1237
1219
- (void )scrollToPreviousPage : (CDVInvokedUrlCommand *)command
1238
1220
{
1239
1221
BOOL animated = [[command argumentAtIndex: 0 withDefault: @NO ] boolValue ];
1240
- [_pdfController scrollToPreviousPageAnimated : animated];
1222
+ [_pdfController.documentViewController scrollToNextSpreadAnimated : animated];
1241
1223
[self .commandDelegate sendPluginResult: [CDVPluginResult resultWithStatus: CDVCommandStatus_OK]
1242
1224
callbackId: command.callbackId];
1243
1225
}
@@ -1324,31 +1306,6 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didBeginPageDragg
1324
1306
[self sendEventWithJSON: @" {type:'didBeginPageDragging'}" ];
1325
1307
}
1326
1308
1327
- - (void )pdfViewController : (PSPDFViewController *)pdfController didEndPageDragging : (UIScrollView *)scrollView willDecelerate : (BOOL )decelerate withVelocity : (CGPoint)velocity targetContentOffset : (inout CGPoint *)targetContentOffset
1328
- {
1329
- [self sendEventWithJSON: [NSString stringWithFormat: @" {type:'didBeginPageDragging',willDecelerate:'%@ ',velocity:'{%g ,%g }'}" , decelerate? @" true" : @" false" , velocity.x, velocity.y]];
1330
- }
1331
-
1332
- - (void )pdfViewController : (PSPDFViewController *)pdfController didEndPageScrollingAnimation : (UIScrollView *)scrollView
1333
- {
1334
- [self sendEventWithJSON: @" {type:'didEndPageScrollingAnimation'}" ];
1335
- }
1336
-
1337
- - (void )pdfViewController : (PSPDFViewController *)pdfController didBeginPageZooming : (UIScrollView *)scrollView
1338
- {
1339
- [self sendEventWithJSON: @" {type:'didBeginPageZooming'}" ];
1340
- }
1341
-
1342
- - (void )pdfViewController : (PSPDFViewController *)pdfController didEndPageZooming : (UIScrollView *)scrollView atScale : (CGFloat)scale
1343
- {
1344
- [self sendEventWithJSON: [NSString stringWithFormat: @" {type:'didEndPageZooming',scale:%g }" , scale]];
1345
- }
1346
-
1347
- // - (PSPDFDocument *)pdfViewController:(PSPDFViewController *)pdfController documentForRelativePath:(NSString *)relativePath
1348
- // {
1349
- //
1350
- // }
1351
-
1352
1309
- (BOOL )pdfViewController : (PSPDFViewController *)pdfController didTapOnPageView : (PSPDFPageView *)pageView atPoint : (CGPoint)viewPoint
1353
1310
{
1354
1311
// inverted because it's almost always YES (due to handling JS eval calls).
@@ -1377,76 +1334,6 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didSelectText:(NS
1377
1334
[self sendEventWithJSON: @{@" type" : @" didSelectText" , @" text" : text, @" rect" : PSPDFStringFromCGRect (rect)}];
1378
1335
}
1379
1336
1380
- // - (NSArray *)pdfViewController:(PSPDFViewController *)pdfController shouldShowMenuItems:(NSArray *)menuItems atSuggestedTargetRect:(CGRect)rect forSelectedText:(NSString *)selectedText inRect:(CGRect)textRect onPageView:(PSPDFPageView *)pageView
1381
- // {
1382
- //
1383
- // }
1384
-
1385
- // - (NSArray *)pdfViewController:(PSPDFViewController *)pdfController shouldShowMenuItems:(NSArray *)menuItems atSuggestedTargetRect:(CGRect)rect forSelectedImage:(PSPDFImageInfo *)selectedImage inRect:(CGRect)textRect onPageView:(PSPDFPageView *)pageView
1386
- // {
1387
- //
1388
- // }
1389
-
1390
- // - (NSArray *)pdfViewController:(PSPDFViewController *)pdfController shouldShowMenuItems:(NSArray *)menuItems atSuggestedTargetRect:(CGRect)rect forAnnotation:(PSPDFAnnotation *)annotation inRect:(CGRect)annotationRect onPageView:(PSPDFPageView *)pageView
1391
- // {
1392
- //
1393
- // }
1394
-
1395
- // - (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldDisplayAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView
1396
- // {
1397
- //
1398
- // }
1399
-
1400
- // - (BOOL)pdfViewController:(PSPDFViewController *)pdfController didTapOnAnnotation:(PSPDFAnnotation *)annotation annotationPoint:(CGPoint)annotationPoint annotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView pageView:(PSPDFPageView *)pageView viewPoint:(CGPoint)viewPoint
1401
- // {
1402
- //
1403
- // }
1404
-
1405
- // - (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldSelectAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView
1406
- // {
1407
- //
1408
- // }
1409
-
1410
- // - (void)pdfViewController:(PSPDFViewController *)pdfController didSelectAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView
1411
- // {
1412
- //
1413
- // }
1414
-
1415
- // - (UIView <PSPDFAnnotationViewProtocol> *)pdfViewController:(PSPDFViewController *)pdfController annotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView forAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView
1416
- // {
1417
- //
1418
- // }
1419
-
1420
- // - (void)pdfViewController:(PSPDFViewController *)pdfController willShowAnnotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView onPageView:(PSPDFPageView *)pageView
1421
- // {
1422
- //
1423
- // }
1424
-
1425
- // - (void)pdfViewController:(PSPDFViewController *)pdfController didShowAnnotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView onPageView:(PSPDFPageView *)pageView
1426
- // {
1427
- //
1428
- // }
1429
-
1430
- // - (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldShowController:(id)viewController embeddedInController:(id)controller animated:(BOOL)animated
1431
- // {
1432
- //
1433
- // }
1434
-
1435
- // - (void)pdfViewController:(PSPDFViewController *)pdfController didShowController:(id)viewController embeddedInController:(id)controller animated:(BOOL)animated
1436
- // {
1437
- //
1438
- // }
1439
-
1440
- // - (void)pdfViewController:(PSPDFViewController *)pdfController requestsUpdateForBarButtonItem:(UIBarButtonItem *)barButtonItem animated:(BOOL)animated
1441
- // {
1442
- //
1443
- // }
1444
-
1445
- // - (void)pdfViewController:(PSPDFViewController *)pdfController didChangeViewMode:(PSPDFViewMode)viewMode
1446
- // {
1447
- //
1448
- // }
1449
-
1450
1337
- (void )pdfViewControllerWillDismiss : (PSPDFViewController *)pdfController
1451
1338
{
1452
1339
[self sendEventWithJSON: @" {type:'willDismiss'}" ];
@@ -1463,34 +1350,24 @@ - (void)pdfViewControllerDidDismiss:(PSPDFViewController *)pdfController
1463
1350
[self sendEventWithJSON: @" {type:'didDismiss'}" ];
1464
1351
}
1465
1352
1466
- - (BOOL )pdfViewController : (PSPDFViewController *)pdfController shouldShowHUD : (BOOL )animated
1467
- {
1468
- return [self sendEventWithJSON: @{@" type" : @" shouldShowHUD" , @" animated" : @(animated)}];
1469
- }
1470
-
1471
- - (void )pdfViewController : (PSPDFViewController *)pdfController willShowHUD : (BOOL )animated
1472
- {
1473
- [self sendEventWithJSON: @{@" type" : @" willShowHUD" , @" animated" : @(animated)}];
1474
- }
1475
-
1476
- - (void )pdfViewController : (PSPDFViewController *)pdfController didShowHUD : (BOOL )animated
1353
+ - (BOOL )pdfViewController : (PSPDFViewController *)pdfController shouldShowUserInterface : (BOOL )animated
1477
1354
{
1478
- [self sendEventWithJSON: @{@" type" : @" didShowHUD " , @" animated" : @(animated)}];
1355
+ return [self sendEventWithJSON: @{@" type" : @" shouldShowUserInterface " , @" animated" : @(animated)}];
1479
1356
}
1480
1357
1481
- - (BOOL )pdfViewController : (PSPDFViewController *)pdfController shouldHideHUD : (BOOL )animated
1358
+ - (void )pdfViewController : (PSPDFViewController *)pdfController didShowUserInterface : (BOOL )animated
1482
1359
{
1483
- return [self sendEventWithJSON: @{@" type" : @" shouldHideHUD " , @" animated" : @(animated)}];
1360
+ [self sendEventWithJSON: @{@" type" : @" didShowUserInterface " , @" animated" : @(animated)}];
1484
1361
}
1485
1362
1486
- - (void )pdfViewController : (PSPDFViewController *)pdfController willHideHUD : (BOOL )animated
1363
+ - (BOOL )pdfViewController : (PSPDFViewController *)pdfController shouldHideUserInterface : (BOOL )animated
1487
1364
{
1488
- [self sendEventWithJSON: @{@" type" : @" willHideHUD " , @" animated" : @(animated)}];
1365
+ return [self sendEventWithJSON: @{@" type" : @" shouldHideUserInterface " , @" animated" : @(animated)}];
1489
1366
}
1490
1367
1491
- - (void )pdfViewController : (PSPDFViewController *)pdfController didHideHUD : (BOOL )animated
1368
+ - (void )pdfViewController : (PSPDFViewController *)pdfController didHideUserInterface : (BOOL )animated
1492
1369
{
1493
- [self sendEventWithJSON: @{@" type" : @" didHideHUD " , @" animated" : @(animated)}];
1370
+ [self sendEventWithJSON: @{@" type" : @" didHideUserInterface " , @" animated" : @(animated)}];
1494
1371
}
1495
1372
1496
1373
#pragma mark Annotation toolbar delegate methods
0 commit comments