1313#import " PSPDFKitPlugin.h"
1414#import < WebKit/WebKit.h>
1515#import < PSPDFKit/PSPDFKit.h>
16+ #import < PSPDFKitUI/PSPDFKitUI.h>
1617
1718@interface PSPDFKitPlugin () <PSPDFViewControllerDelegate, PSPDFFlexibleToolbarContainerDelegate>
1819
@@ -544,7 +545,7 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
544545
545546 @" PSPDFPageTransition" :
546547
547- @{@" scrollPerPage " : @(PSPDFPageTransitionScrollPerPage ),
548+ @{@" scrollPerSpread " : @(PSPDFPageTransitionScrollPerSpread ),
548549 @" scrollContinuous" : @(PSPDFPageTransitionScrollContinuous),
549550 @" curl" : @(PSPDFPageTransitionCurl)},
550551
@@ -571,18 +572,18 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
571572 @" openSafari" : @(PSPDFLinkActionOpenSafari),
572573 @" inlineBrowser" : @(PSPDFLinkActionInlineBrowser)},
573574
574- @" PSPDFHUDViewMode " :
575+ @" PSPDFUserInterfaceViewMode " :
575576
576- @{@" always" : @(PSPDFHUDViewModeAlways ),
577- @" automatic" : @(PSPDFHUDViewModeAutomatic ),
578- @" automaticNoFirstLastPage" : @(PSPDFHUDViewModeAutomaticNoFirstLastPage ),
579- @" never" : @(PSPDFHUDViewModeNever )},
577+ @{@" always" : @(PSPDFUserInterfaceViewModeAlways ),
578+ @" automatic" : @(PSPDFUserInterfaceViewModeAutomatic ),
579+ @" automaticNoFirstLastPage" : @(PSPDFUserInterfaceViewModeAutomaticNoFirstLastPage ),
580+ @" never" : @(PSPDFUserInterfaceViewModeNever )},
580581
581- @" PSPDFHUDViewAnimation " :
582+ @" PSPDFUserInterfaceViewAnimation " :
582583
583- @{@" none" : @(PSPDFHUDViewAnimationNone ),
584- @" fade" : @(PSPDFHUDViewAnimationFade ),
585- @" slide" : @(PSPDFHUDViewAnimationSlide )},
584+ @{@" none" : @(PSPDFUserInterfaceViewAnimationNone ),
585+ @" fade" : @(PSPDFUserInterfaceViewAnimationFade ),
586+ @" slide" : @(PSPDFUserInterfaceViewAnimationSlide )},
586587
587588 @" PSPDFThumbnailBarMode" :
588589
@@ -654,25 +655,6 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
654655 return enumsByType[type];
655656}
656657
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-
676658#pragma mark License Key
677659
678660- (void )setLicenseKey : (CDVInvokedUrlCommand *)command {
@@ -768,7 +750,7 @@ - (void)setRenderAnnotationTypesForPSPDFDocumentWithJSON:(NSArray *)options
768750
769751- (void )setPageTransitionForPSPDFViewControllerWithJSON : (NSString *)transition
770752{
771- PSPDFPageTransition pageTransition = (PSPDFPageTransition) [self enumValueForKey: transition ofType: @" PSPDFPageTransition" withDefault: PSPDFPageTransitionScrollPerPage ];
753+ PSPDFPageTransition pageTransition = (PSPDFPageTransition) [self enumValueForKey: transition ofType: @" PSPDFPageTransition" withDefault: PSPDFPageTransitionScrollPerSpread ];
772754 [_pdfController updateConfigurationWithBuilder: ^(PSPDFConfigurationBuilder *builder) {
773755 builder.pageTransition = pageTransition;
774756 }];
@@ -846,35 +828,35 @@ - (NSString *)linkActionAsJSON
846828 return [self enumKeyForValue: _pdfController.configuration.linkAction ofType: @" PSPDFLinkAction" ];
847829}
848830
849- - (void )setHUDViewModeForPSPDFViewControllerWithJSON : (NSString *)mode
831+ - (void )setUserInterfaceViewModeForPSPDFViewControllerWithJSON : (NSString *)mode
850832{
851- PSPDFHUDViewMode HUDViewMode = (PSPDFHUDViewMode ) [self enumValueForKey: mode ofType: @" PSPDFHUDViewMode " withDefault: PSPDFHUDViewModeAutomatic ];
833+ PSPDFUserInterfaceViewMode userInterfaceViewMode = (PSPDFUserInterfaceViewMode ) [self enumValueForKey: mode ofType: @" PSPDFUserInterfaceViewMode " withDefault: PSPDFUserInterfaceViewModeAutomatic ];
852834 [_pdfController updateConfigurationWithBuilder: ^(PSPDFConfigurationBuilder *builder) {
853- builder.HUDViewMode = HUDViewMode ;
835+ builder.userInterfaceViewMode = userInterfaceViewMode ;
854836 }];
855837}
856838
857- - (NSString *)HUDViewModeAsJSON
839+ - (NSString *)userInterfaceViewModeAsJSON
858840{
859- return [self enumKeyForValue: _pdfController.configuration.HUDViewMode ofType: @" PSPDFHUDViewMode " ];
841+ return [self enumKeyForValue: _pdfController.configuration.userInterfaceViewMode ofType: @" PSPDFUserInterfaceViewMode " ];
860842}
861843
862- - (void )setHUDViewAnimationForPSPDFViewControllerWithJSON : (NSString *)mode
844+ - (void )setUserInterfaceViewAnimationForPSPDFViewControllerWithJSON : (NSString *)mode
863845{
864- PSPDFHUDViewAnimation HUDViewAnimation = (PSPDFHUDViewAnimation ) [self enumValueForKey: mode ofType: @" HUDViewAnimation " withDefault: PSPDFHUDViewAnimationFade ];
846+ PSPDFUserInterfaceViewAnimation userInterfaceViewAnimation = (PSPDFUserInterfaceViewAnimation ) [self enumValueForKey: mode ofType: @" UserInterfaceViewAnimation " withDefault: PSPDFUserInterfaceViewAnimationFade ];
865847 [_pdfController updateConfigurationWithBuilder: ^(PSPDFConfigurationBuilder *builder) {
866- builder.HUDViewAnimation = HUDViewAnimation ;
848+ builder.userInterfaceViewAnimation = userInterfaceViewAnimation ;
867849 }];
868850}
869851
870- - (NSString *)HUDViewAnimationAsJSON
852+ - (NSString *)userInterfaceViewAnimationAsJSON
871853{
872- return [self enumKeyForValue: _pdfController.configuration.HUDViewAnimation ofType: @" PSPDFHUDViewAnimation " ];
854+ return [self enumKeyForValue: _pdfController.configuration.userInterfaceViewAnimation ofType: @" PSPDFUserInterfaceViewAnimation " ];
873855}
874856
875- - (void )setHUDVisibleAnimatedForPSPDFViewControllerWithJSON : (NSNumber *)visible
857+ - (void )setUserInterfaceVisibleAnimatedForPSPDFViewControllerWithJSON : (NSNumber *)visible
876858{
877- [_pdfController setHUDVisible : [visible boolValue ] animated: YES ];
859+ [_pdfController setUserInterfaceVisible : [visible boolValue ] animated: YES ];
878860}
879861
880862- (void )setPageAnimatedForPSPDFViewControllerWithJSON : (NSNumber *)page
@@ -1027,7 +1009,7 @@ - (void)present:(CDVInvokedUrlCommand *)command {
10271009 if (path) {
10281010 // configure document
10291011 NSURL *url = [self pdfFileURLWithPath: path];
1030- _pdfDocument = [PSPDFDocument documentWithURL : url];
1012+ _pdfDocument = [[ PSPDFDocument alloc ] initWithURL : url];
10311013 [self setOptions: newOptions forObject: _pdfDocument animated: NO ];
10321014 }
10331015
@@ -1097,7 +1079,7 @@ - (void)search:(CDVInvokedUrlCommand *)command
10971079- (void )saveAnnotations : (CDVInvokedUrlCommand *)command
10981080{
10991081 // 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) {
11011083 [self .commandDelegate sendPluginResult: [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: [self dictionaryWithError: error]] callbackId: command.callbackId];
11021084 }];
11031085}
@@ -1229,15 +1211,15 @@ - (void)getPageCount:(CDVInvokedUrlCommand *)command
12291211- (void )scrollToNextPage : (CDVInvokedUrlCommand *)command
12301212{
12311213 BOOL animated = [[command argumentAtIndex: 0 withDefault: @NO ] boolValue ];
1232- [_pdfController scrollToNextPageAnimated : animated];
1214+ [_pdfController.documentViewController scrollToNextSpreadAnimated : animated];
12331215 [self .commandDelegate sendPluginResult: [CDVPluginResult resultWithStatus: CDVCommandStatus_OK]
12341216 callbackId: command.callbackId];
12351217}
12361218
12371219- (void )scrollToPreviousPage : (CDVInvokedUrlCommand *)command
12381220{
12391221 BOOL animated = [[command argumentAtIndex: 0 withDefault: @NO ] boolValue ];
1240- [_pdfController scrollToPreviousPageAnimated : animated];
1222+ [_pdfController.documentViewController scrollToNextSpreadAnimated : animated];
12411223 [self .commandDelegate sendPluginResult: [CDVPluginResult resultWithStatus: CDVCommandStatus_OK]
12421224 callbackId: command.callbackId];
12431225}
@@ -1324,31 +1306,6 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didBeginPageDragg
13241306 [self sendEventWithJSON: @" {type:'didBeginPageDragging'}" ];
13251307}
13261308
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-
13521309- (BOOL )pdfViewController : (PSPDFViewController *)pdfController didTapOnPageView : (PSPDFPageView *)pageView atPoint : (CGPoint)viewPoint
13531310{
13541311 // inverted because it's almost always YES (due to handling JS eval calls).
@@ -1377,76 +1334,6 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didSelectText:(NS
13771334 [self sendEventWithJSON: @{@" type" : @" didSelectText" , @" text" : text, @" rect" : PSPDFStringFromCGRect (rect)}];
13781335}
13791336
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-
14501337- (void )pdfViewControllerWillDismiss : (PSPDFViewController *)pdfController
14511338{
14521339 [self sendEventWithJSON: @" {type:'willDismiss'}" ];
@@ -1463,34 +1350,24 @@ - (void)pdfViewControllerDidDismiss:(PSPDFViewController *)pdfController
14631350 [self sendEventWithJSON: @" {type:'didDismiss'}" ];
14641351}
14651352
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
14771354{
1478- [self sendEventWithJSON: @{@" type" : @" didShowHUD " , @" animated" : @(animated)}];
1355+ return [self sendEventWithJSON: @{@" type" : @" shouldShowUserInterface " , @" animated" : @(animated)}];
14791356}
14801357
1481- - (BOOL )pdfViewController : (PSPDFViewController *)pdfController shouldHideHUD : (BOOL )animated
1358+ - (void )pdfViewController : (PSPDFViewController *)pdfController didShowUserInterface : (BOOL )animated
14821359{
1483- return [self sendEventWithJSON: @{@" type" : @" shouldHideHUD " , @" animated" : @(animated)}];
1360+ [self sendEventWithJSON: @{@" type" : @" didShowUserInterface " , @" animated" : @(animated)}];
14841361}
14851362
1486- - (void )pdfViewController : (PSPDFViewController *)pdfController willHideHUD : (BOOL )animated
1363+ - (BOOL )pdfViewController : (PSPDFViewController *)pdfController shouldHideUserInterface : (BOOL )animated
14871364{
1488- [self sendEventWithJSON: @{@" type" : @" willHideHUD " , @" animated" : @(animated)}];
1365+ return [self sendEventWithJSON: @{@" type" : @" shouldHideUserInterface " , @" animated" : @(animated)}];
14891366}
14901367
1491- - (void )pdfViewController : (PSPDFViewController *)pdfController didHideHUD : (BOOL )animated
1368+ - (void )pdfViewController : (PSPDFViewController *)pdfController didHideUserInterface : (BOOL )animated
14921369{
1493- [self sendEventWithJSON: @{@" type" : @" didHideHUD " , @" animated" : @(animated)}];
1370+ [self sendEventWithJSON: @{@" type" : @" didHideUserInterface " , @" animated" : @(animated)}];
14941371}
14951372
14961373#pragma mark Annotation toolbar delegate methods
0 commit comments