From b4686fe6d51e5e95541843b0df1f9795d0510b80 Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Tue, 26 Jun 2018 17:39:08 +0100 Subject: [PATCH 01/17] feat: updated UI to match design --- PDFReader.xcodeproj/project.pbxproj | 20 +- .../AppIcon.appiconset/Contents.json | 5 + .../buttonBack64.imageset/Contents.json | 23 +++ .../buttonBack64.imageset/buttonBack64.png | Bin 0 -> 427 bytes .../buttonBack64.imageset/buttonBack64@2x.png | Bin 0 -> 817 bytes .../buttonBack64.imageset/buttonBack64@3x.png | Bin 0 -> 1629 bytes PDFReader/Demo/Base.lproj/Main.storyboard | 23 ++- .../Demo/ExamplePDFs/Inventions Prelims.pdf | Bin 0 -> 11894844 bytes PDFReader/Demo/ExamplePDFs/book1.pdf | Bin 0 -> 3381418 bytes PDFReader/Demo/StartViewController.swift | 12 +- Sources/Assets/PDFReader.storyboard | 124 ++++++++++-- Sources/Classes/PDFDocument.swift | 2 +- Sources/Classes/PDFViewController.swift | 180 +++++++++++++----- Sources/Classes/PDFViewUIProperties.swift | 53 ++++++ 14 files changed, 355 insertions(+), 87 deletions(-) create mode 100644 PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/Contents.json create mode 100644 PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64.png create mode 100644 PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64@2x.png create mode 100644 PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64@3x.png create mode 100644 PDFReader/Demo/ExamplePDFs/Inventions Prelims.pdf create mode 100644 PDFReader/Demo/ExamplePDFs/book1.pdf create mode 100644 Sources/Classes/PDFViewUIProperties.swift diff --git a/PDFReader.xcodeproj/project.pbxproj b/PDFReader.xcodeproj/project.pbxproj index 4c4496d..4e3b3ae 100644 --- a/PDFReader.xcodeproj/project.pbxproj +++ b/PDFReader.xcodeproj/project.pbxproj @@ -26,6 +26,9 @@ 146D371F1DAB7EDF004EEFA5 /* StartViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 146D371E1DAB7EDF004EEFA5 /* StartViewController.swift */; }; 146D37231DAB7F0F004EEFA5 /* apple.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 146D37211DAB7F0F004EEFA5 /* apple.pdf */; }; 146D37241DAB7F0F004EEFA5 /* mongodb.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 146D37221DAB7F0F004EEFA5 /* mongodb.pdf */; }; + BA5FF58520E23D1200F8BBC0 /* book1.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BA5FF58420E23D1200F8BBC0 /* book1.pdf */; }; + BA5FF58720E23E7200F8BBC0 /* Inventions Prelims.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BA5FF58620E23E7200F8BBC0 /* Inventions Prelims.pdf */; }; + BA5FF58920E26F4500F8BBC0 /* PDFViewUIProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA5FF58820E26F4500F8BBC0 /* PDFViewUIProperties.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -71,9 +74,12 @@ 146D37151DAB7E23004EEFA5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 146D37181DAB7E23004EEFA5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 146D371A1DAB7E23004EEFA5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 146D371E1DAB7EDF004EEFA5 /* StartViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartViewController.swift; sourceTree = ""; }; + 146D371E1DAB7EDF004EEFA5 /* StartViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartViewController.swift; sourceTree = ""; wrapsLines = 0; }; 146D37211DAB7F0F004EEFA5 /* apple.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = apple.pdf; sourceTree = ""; }; 146D37221DAB7F0F004EEFA5 /* mongodb.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = mongodb.pdf; sourceTree = ""; }; + BA5FF58420E23D1200F8BBC0 /* book1.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = book1.pdf; sourceTree = ""; }; + BA5FF58620E23E7200F8BBC0 /* Inventions Prelims.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = "Inventions Prelims.pdf"; sourceTree = ""; }; + BA5FF58820E26F4500F8BBC0 /* PDFViewUIProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDFViewUIProperties.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -149,6 +155,7 @@ 14083FEB1D4A956E00909913 /* PDFThumbnailCell.swift */, 14083FEC1D4A956E00909913 /* PDFThumbnailCollectionViewController.swift */, 14083FED1D4A956E00909913 /* PDFViewController.swift */, + BA5FF58820E26F4500F8BBC0 /* PDFViewUIProperties.swift */, 14083FEE1D4A956E00909913 /* TiledView.swift */, ); path = Classes; @@ -173,7 +180,9 @@ isa = PBXGroup; children = ( 146B852E1E30633A005F427E /* javaScript.pdf */, + BA5FF58420E23D1200F8BBC0 /* book1.pdf */, 146D37211DAB7F0F004EEFA5 /* apple.pdf */, + BA5FF58620E23E7200F8BBC0 /* Inventions Prelims.pdf */, 146D37221DAB7F0F004EEFA5 /* mongodb.pdf */, ); path = ExamplePDFs; @@ -286,10 +295,12 @@ files = ( 146D37191DAB7E23004EEFA5 /* LaunchScreen.storyboard in Resources */, 146D37161DAB7E23004EEFA5 /* Assets.xcassets in Resources */, + BA5FF58520E23D1200F8BBC0 /* book1.pdf in Resources */, 146D37141DAB7E23004EEFA5 /* Main.storyboard in Resources */, 146B85301E306460005F427E /* javaScript.pdf in Resources */, 146D37241DAB7F0F004EEFA5 /* mongodb.pdf in Resources */, 146D37231DAB7F0F004EEFA5 /* apple.pdf in Resources */, + BA5FF58720E23E7200F8BBC0 /* Inventions Prelims.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -304,6 +315,7 @@ 14083FF11D4A956E00909913 /* PDFPageCollectionViewCell.swift in Sources */, 14083FF01D4A956E00909913 /* PDFDocument.swift in Sources */, 14083FF51D4A956E00909913 /* PDFViewController.swift in Sources */, + BA5FF58920E26F4500F8BBC0 /* PDFViewUIProperties.swift in Sources */, 14083FF41D4A956E00909913 /* PDFThumbnailCollectionViewController.swift in Sources */, 14083FF31D4A956E00909913 /* PDFThumbnailCell.swift in Sources */, 14083FF61D4A956E00909913 /* TiledView.swift in Sources */, @@ -516,7 +528,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/PDFReader/Demo/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mytrus.Demo; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -524,6 +536,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -538,13 +551,14 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/PDFReader/Demo/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mytrus.Demo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; diff --git a/PDFReader/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json b/PDFReader/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json index 1d060ed..d8db8d6 100644 --- a/PDFReader/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/PDFReader/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -84,6 +84,11 @@ "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/Contents.json b/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/Contents.json new file mode 100644 index 0000000..baa2620 --- /dev/null +++ b/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "buttonBack64.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "buttonBack64@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "buttonBack64@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64.png b/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64.png new file mode 100644 index 0000000000000000000000000000000000000000..df8814e26688332ef0669a9f740e04bf29994d54 GIT binary patch literal 427 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%zQ$1ZALn;{G zUN`h&b`&}G@#axce}OlbSRFSADQdKc$Q_oxvC~ZMfZLiPmi|P=ri}tYw=zh>-AW^upv zR-gPsySmoDbM}R1FJ%b&@qXQIZpC{s`{mAs@lL%Q{#0c8n!m#Tp1#=hByRtGUB(BZ zc8)ukE85E0Kk&WhS|D(b*Fkj;cSBG`F~imm%NV*Io@EF*JextI-Je1FWnj_K^Y6CJ z-+u4c&3id}&YleZV-%8Wc6?#i;msEhyPi9^Cd=0?@#*~oEDE*0p)AG>p)A1+t}Mk2 zrYzzNsx0OVqAcMItSsdW`7E3a{w$IV`Yn&j8%1(%mVT}I5NCdN%YK`=TNWR`ocjCP y%E?R~jzUgbMb#Geb(c0>>_+oBi2I@c0KaJS8{4gm9&QANK7*&LpUXO@geCyw#HfY< literal 0 HcmV?d00001 diff --git a/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64@2x.png b/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..38c6d4ea5ae9703b98a75e907d73216e8b6d4543 GIT binary patch literal 817 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-HD>V0!K8;uuoF z`1W>umT;g%`$OY{J2=-btcq!j^Xqg}Pp^`B;|5?e0#SlWe6T{P}r_ zp4YP)|GY~{PR8fo=Pog+HcRu@<;c; zkJTR!&t>Ydm$46FIQGB(j{&1Z{qG-&Oa}kneO%3d;K%Rd>#Z0b%ggP*#n2OPRyUPV zVt>t_S3v2%$JT2xJicH5Ckx2g@$vI!wfe*pvzOnG*A;tNye~;TeoNr(`)~W_Z+kOy zGXH|iU8}#|apMm8c>kauv-OgnzNCLPIaZA|R>D=+foDV9nGa)X4CSML>~>QHEo|Hx8BnfdgqQ zzFG6?_gMZ8`*CG)-Hj*uyww_aPsgXnUs_XpGq$VDwEoVY$`$Khzouq-a)@Z$U-Iac VigH$$8ZZwqc)I$ztaD0e0suBNFx3D6 literal 0 HcmV?d00001 diff --git a/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64@3x.png b/PDFReader/Demo/Assets.xcassets/buttonBack64.imageset/buttonBack64@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..c8dc35c8dc903092457fcae1966c018a9c411a00 GIT binary patch literal 1629 zcmdUw`&ZI;7{@H7`(0DaA4`*~RRersYht z%o<*jR#`c38QwB4h|5M=p2Bn~YBjYokg^gT;@F?j5AWyw{`Ga9=REH$e?QN~_+@wi zz+!JNw*Z5;|1bDE!weV_8XF8s2=L^BswdyS1K>N7w;N~Y5lE$U%3dBwG}egRg9s*b zkb_%VA%Dr;T}XZ3v!~SU#O%b-{gM7up3I}yh0^(un|Icux5F$iFL)n@)#`pmDI6Y5 z7N|ESM_uF_90VT8g)0fhO+LXF!gGsaM3V%*1ZwR!akc}!}w zyhl~Ss982Qp;ordC(Vq;Ekqoj=nCxenGG*3Hf3#lQn@KL`504|Y&|qv7E?ICFr^+# zpLe}_LZ@b`bFq{sE|LUS-PZn=zJrQ&s)F=M#=Np^=6*OE)LZpb?NMqPSS;(Xmb&EF z!z9);AzF}nV(rwW_Oe$CANpGueg(&hC=_7gmGFa;ZfqMD$cr))nL27k4(M#OR7GpE z<2NaM!HUjo_ml-4eAen{&@>%WVRRLn|cNudF)@0v$j|${5K? z|EWxnL`3f;u0AQyu1T-1Uy9C+$0Rd#F(DnUL^STT%8IO4d2F}9Aa+Fq{Th2NuE2zi z2)BgFN`EJY+JL*QR?SxW9A;n}f|d_0#71fD*&{VKfe_7_8_;ixyczPSbkcjKZMBoMGr&{7U%`z-CEC%9-#=FTaU5g&Zcuke}>g|$4a@w0 zbpA|GkX@H-M4b|;Z4lGn#y|t{!KM1oLYn9R!nI` zh@BOREdalnz}ek9dKiNM2P|}(L&s6zpW!qK%Y|VkK7EE>htr zOC2MdkQ=nEJ8VF~P=?t2b9*e7PYL#GLjHOCXN3hy?#~I&;M?@r^5Ayt2d*PDmr2L* zjeI|MaS?j)3m$k@%q>4nIi2Lc10r_@wg$uUBGY#?uvwB8ok4+Ju2lkCN*`@W+A{fh zH5HsM^!=KJC~lDqmncxvu!2v-g#hqt{`gPCv=o`b6qC0)u*na8j}q9+C$=}kQd&JH z8_P$6=J!y~t|OtrBP*2|V))I=RhXK~k*U^rPPYhVpNsJdqSBtO24h<{v+$gd2#7Wr zaspASQ_(Hdz5Fi!)ff|eB-d8FMzkZpIa4|pY|VYvTO|i literal 0 HcmV?d00001 diff --git a/PDFReader/Demo/Base.lproj/Main.storyboard b/PDFReader/Demo/Base.lproj/Main.storyboard index 420f7b8..a2a538a 100644 --- a/PDFReader/Demo/Base.lproj/Main.storyboard +++ b/PDFReader/Demo/Base.lproj/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -22,10 +22,10 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - - + + + - + + + + + + + + + + + + - + - + - + @@ -90,14 +176,16 @@ - - + + - + + + diff --git a/Sources/Classes/PDFDocument.swift b/Sources/Classes/PDFDocument.swift index 878366c..32bfc3e 100755 --- a/Sources/Classes/PDFDocument.swift +++ b/Sources/Classes/PDFDocument.swift @@ -108,7 +108,7 @@ public struct PDFDocument { var images = [UIImage]() var pagesCompleted = 0 for pageNumber in 0.. PDFViewController { +// public class func createNew(with document: PDFDocument, title: String? = nil, actionButtonImage: UIImage? = nil, actionStyle: ActionStyle?, isThumbnailsEnabled: Bool = true, startPageIndex: Int = 0) -> PDFViewController { +// let storyboard = UIStoryboard(name: "PDFReader", bundle: Bundle(for: PDFViewController.self)) +// let controller = storyboard.instantiateInitialViewController() as! PDFViewController +// controller.document = document +// controller.actionStyle = actionStyle +// +// if let title = title { +// controller.title = title +// } else { +// controller.title = document.fileName +// } +// +// if startPageIndex >= 0 && startPageIndex < document.pageCount { +// controller.currentPageIndex = startPageIndex +// } else { +// controller.currentPageIndex = 0 +// } +// +//// controller.backButtonImage = backButtonImage +// +// if actionStyle != nil { +// if let actionButtonImage = actionButtonImage { +// controller.actionButton = UIBarButtonItem(image: actionButtonImage, style: .plain, target: controller, action: #selector(actionButtonPressed)) +// } else { +// controller.actionButton = UIBarButtonItem(barButtonSystemItem: .action, target: controller, action: #selector(actionButtonPressed)) +// } +// } else { +// controller.actionButton = nil +// } +// controller.isThumbnailsEnabled = isThumbnailsEnabled +// return controller +// } + + public class func createNew(with document: PDFDocument, properties: PDFViewUIProperties) -> PDFViewController { let storyboard = UIStoryboard(name: "PDFReader", bundle: Bundle(for: PDFViewController.self)) let controller = storyboard.instantiateInitialViewController() as! PDFViewController controller.document = document - controller.actionStyle = actionStyle - - if let title = title { - controller.title = title - } else { - controller.title = document.fileName - } + controller.uiProperties = properties - if startPageIndex >= 0 && startPageIndex < document.pageCount { - controller.currentPageIndex = startPageIndex - } else { - controller.currentPageIndex = 0 - } - - controller.backButton = backButton - - if let actionButtonImage = actionButtonImage { - controller.actionButton = UIBarButtonItem(image: actionButtonImage, style: .plain, target: controller, action: #selector(actionButtonPressed)) - } else { - controller.actionButton = UIBarButtonItem(barButtonSystemItem: .action, target: controller, action: #selector(actionButtonPressed)) - } - controller.isThumbnailsEnabled = isThumbnailsEnabled return controller } } @@ -64,9 +77,33 @@ public final class PDFViewController: UIViewController { case customAction(() -> ()) } + /// View representing the navigation bar + @IBOutlet public var navigationView: UIView! + + /// button for returning to previous view + @IBOutlet public var backButton: UIButton! + + /// Label for title + @IBOutlet public var titleLabel: UILabel! + + /// Label for subtitle + @IBOutlet public var subtitleLabel: UILabel! + + /// Line view in the navigation view + @IBOutlet public var lineView: UIView! + + /// Line view above the thumbnails + @IBOutlet public var lineViewSeparatingThumbnails: UIView! + /// Collection veiw where all the pdf pages are rendered @IBOutlet public var collectionView: UICollectionView! + /// Height of the navigation view (used to hide/show) + @IBOutlet private var navigationViewHeight: NSLayoutConstraint! + + /// Distance between the top of navigation view with top of page (used to hide/show) + @IBOutlet private var navigationViewTop: NSLayoutConstraint! + /// Height of the thumbnail bar (used to hide/show) @IBOutlet private var thumbnailCollectionControllerHeight: NSLayoutConstraint! @@ -79,7 +116,7 @@ public final class PDFViewController: UIViewController { /// PDF document that should be displayed private var document: PDFDocument! - private var actionStyle = ActionStyle.print + private var actionStyle: ActionStyle? /// Image used to override the default action button image private var actionButtonImage: UIImage? @@ -93,15 +130,15 @@ public final class PDFViewController: UIViewController { /// UIBarButtonItem used to override the default action button private var actionButton: UIBarButtonItem? - /// Backbutton used to override the default back button - private var backButton: UIBarButtonItem? - /// Background color to apply to the collectionView. - public var backgroundColor: UIColor? = .lightGray { + public var backgroundColor: UIColor? = .lightGray /*{ didSet { collectionView?.backgroundColor = backgroundColor } - } + }*/ + +// ///Back button image +// private var backButtonImage: UIImage? /// Whether or not the thumbnails bar should be enabled private var isThumbnailsEnabled = true { @@ -127,16 +164,19 @@ public final class PDFViewController: UIViewController { } } + /// UI values + private var uiProperties: PDFViewUIProperties? + override public func viewDidLoad() { super.viewDidLoad() - - collectionView.backgroundColor = backgroundColor + + view.backgroundColor = .red//backgroundColor//.lightGray + collectionView.backgroundColor = .cyan//.clear//backgroundColor collectionView.register(PDFPageCollectionViewCell.self, forCellWithReuseIdentifier: "page") navigationItem.rightBarButtonItem = actionButton - if let backItem = backButton { - navigationItem.leftBarButtonItem = backItem - } + + navigationItem.hidesBackButton = true let numberOfPages = CGFloat(document.pageCount) let cellSpacing = CGFloat(2.0) @@ -144,6 +184,36 @@ public final class PDFViewController: UIViewController { let thumbnailWidth = (numberOfPages * PDFThumbnailCell.cellSize.width) + totalSpacing let width = min(thumbnailWidth, view.bounds.width) thumbnailCollectionControllerWidth.constant = width + + lineViewSeparatingThumbnails.backgroundColor = backgroundColor + + if let properties = uiProperties { + if let title = properties.title { + titleLabel.text = title + if let font = properties.titleFont { + titleLabel.font = font + } + } else { + titleLabel.text = "" + } + if let subtitle = properties.subtitle { + subtitleLabel.text = subtitle + if let font = properties.subtitleFont { + subtitleLabel.font = font + } + } else { + subtitleLabel.text = "" + } + + backButton.setImage(properties.backButtonImage, for: .normal) + backButton.setTitle((properties.backButtonImage != nil ? "" : "Back"), for: .normal) + + isThumbnailsEnabled = properties.isThumbnailsEnabled + + if let lineViewColor = properties.lineViewColor { + lineView.backgroundColor = lineViewColor + } + } } public override func viewDidLayoutSubviews() { @@ -184,15 +254,22 @@ public final class PDFViewController: UIViewController { super.viewWillTransition(to: size, with: coordinator) } + ///Back button tapped + @IBAction func backButtonTapped() { + navigationController?.popViewController(animated: true) + } + /// Takes an appropriate action based on the current action style @objc func actionButtonPressed() { - switch actionStyle { - case .print: - print() - case .activitySheet: - presentActivitySheet() - case .customAction(let customAction): - customAction() + if let actionStyle = actionStyle { + switch actionStyle { + case .print: + print() + case .activitySheet: + presentActivitySheet() + case .customAction(let customAction): + customAction() + } } } @@ -235,6 +312,7 @@ extension PDFViewController: UICollectionViewDataSource { public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "page", for: indexPath) as! PDFPageCollectionViewCell + cell.setup(indexPath.row, collectionViewBounds: collectionView.bounds, document: document, pageCollectionViewCellDelegate: self) return cell } @@ -244,27 +322,27 @@ extension PDFViewController: PDFPageCollectionViewCellDelegate { /// Toggles the hiding/showing of the thumbnail controller /// /// - parameter shouldHide: whether or not the controller should hide the thumbnail controller - private func hideThumbnailController(_ shouldHide: Bool) { - self.thumbnailCollectionControllerBottom.constant = shouldHide ? -thumbnailCollectionControllerHeight.constant : 0 - } +// private func hideThumbnailController(_ shouldHide: Bool) { +// self.thumbnailCollectionControllerBottom.constant = shouldHide ? -thumbnailCollectionControllerHeight.constant : 0 +// } func handleSingleTap(_ cell: PDFPageCollectionViewCell, pdfPageView: PDFPageView) { - var shouldHide: Bool { - guard let isNavigationBarHidden = navigationController?.isNavigationBarHidden else { - return false - } - return !isNavigationBarHidden + if navigationViewTop.constant < CGFloat(0.0) { + navigationViewTop.constant = CGFloat(0.0) + thumbnailCollectionControllerBottom.constant = CGFloat(0.0) + } else { + navigationViewTop.constant = -navigationViewHeight.constant + thumbnailCollectionControllerBottom.constant = -thumbnailCollectionControllerHeight.constant } UIView.animate(withDuration: 0.25) { - self.hideThumbnailController(shouldHide) - self.navigationController?.setNavigationBarHidden(shouldHide, animated: true) + self.view.layoutIfNeeded() } } } extension PDFViewController: UICollectionViewDelegateFlowLayout { public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize(width: collectionView.frame.width - 1, height: collectionView.frame.height) + return CGSize(width: collectionView.frame.width, height: collectionView.frame.height) } } diff --git a/Sources/Classes/PDFViewUIProperties.swift b/Sources/Classes/PDFViewUIProperties.swift new file mode 100644 index 0000000..ffa5aa9 --- /dev/null +++ b/Sources/Classes/PDFViewUIProperties.swift @@ -0,0 +1,53 @@ +// +// PDFViewUIProperties.swift +// PDFReader +// +// Created by Vrushali Wani on 26/06/2018. +// Copyright © 2018 mytrus. All rights reserved. +// + +import Foundation + +public struct PDFViewUIProperties { + /// Title for the pdf + public var title: String? + + /// font for the title label + public var titleFont: UIFont? + + /// subtitle for the pdf + public var subtitle: String? + + /// font for the subtitle label + public var subtitleFont: UIFont? + + /// image for back button + public var backButtonImage: UIImage? + + /// Whether or not the thumbnails bar should be enabled + public var isThumbnailsEnabled: Bool + + /// Color of the line view + public var lineViewColor: UIColor? + + /** + Returns newly initialised PDFViewUIProperties + + - title: Title for the pdf + - titleFont: font for the title label + - subtitle: subtitle for the pdf + - subtitleFont: font for the subtitle label + - backButtonImage: image for back button + - isThumbnailsEnabled: whether or not the thumbnails bar should be enabled + - lineViewColor: color for the line view + */ + public init?(title: String?, titleFont: UIFont?, subtitle: String?, subtitleFont: UIFont?, backButtonImage: UIImage?, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor?) { + self.title = title + self.titleFont = titleFont + self.subtitle = subtitle + self.subtitleFont = subtitleFont + self.backButtonImage = backButtonImage + self.isThumbnailsEnabled = isThumbnailsEnabled + self.lineViewColor = lineViewColor + } +} From db2e5c37a39f591091070f4616247531ae47e612 Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Wed, 27 Jun 2018 10:22:33 +0100 Subject: [PATCH 02/17] refactor: disabled prefetching on collection, added unwrapping cells before using them, tidy up --- Sources/Assets/PDFReader.storyboard | 24 +++++++++---------- ...PDFThumbnailCollectionViewController.swift | 24 ++++++++++--------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Sources/Assets/PDFReader.storyboard b/Sources/Assets/PDFReader.storyboard index 5c90d81..a7396b8 100644 --- a/Sources/Assets/PDFReader.storyboard +++ b/Sources/Assets/PDFReader.storyboard @@ -21,7 +21,7 @@ - + @@ -37,7 +37,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -165,26 +165,26 @@ - - + + - + - - + + - + - + @@ -207,7 +207,7 @@ - + diff --git a/Sources/Classes/PDFThumbnailCollectionViewController.swift b/Sources/Classes/PDFThumbnailCollectionViewController.swift index 9badc45..eefa1a6 100644 --- a/Sources/Classes/PDFThumbnailCollectionViewController.swift +++ b/Sources/Classes/PDFThumbnailCollectionViewController.swift @@ -45,12 +45,14 @@ internal final class PDFThumbnailCollectionViewController: UICollectionViewContr override func viewDidLoad() { super.viewDidLoad() - DispatchQueue.global(qos: .background).async { - self.document.allPageImages(callback: { (images) in - DispatchQueue.main.async { - self.pageImages = images - } - }) + DispatchQueue.global(qos: .background).async { [weak self] in + if let document = self?.document { + document.allPageImages(callback: { (images) in + DispatchQueue.main.async { + self?.pageImages = images + } + }) + } } } @@ -59,11 +61,11 @@ internal final class PDFThumbnailCollectionViewController: UICollectionViewContr } override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! PDFThumbnailCell - - cell.imageView?.image = pageImages?[indexPath.row] - cell.alpha = currentPageIndex == indexPath.row ? 1 : 0.2 - + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) + if let thumbnailCell = cell as? PDFThumbnailCell { + thumbnailCell.imageView?.image = pageImages?[indexPath.row] + thumbnailCell.alpha = currentPageIndex == indexPath.row ? 1 : 0.2 + } return cell } From c5525ded5aa20739130cd07809f063c878aacded Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Wed, 27 Jun 2018 10:26:10 +0100 Subject: [PATCH 03/17] feat: unwrapping cells before using them chore: removed unused methods, tidy up --- Sources/Classes/PDFViewController.swift | 74 ++++------------------- Sources/Classes/PDFViewUIProperties.swift | 1 + 2 files changed, 12 insertions(+), 63 deletions(-) mode change 100755 => 100644 Sources/Classes/PDFViewController.swift diff --git a/Sources/Classes/PDFViewController.swift b/Sources/Classes/PDFViewController.swift old mode 100755 new mode 100644 index 8568370..ce5db60 --- a/Sources/Classes/PDFViewController.swift +++ b/Sources/Classes/PDFViewController.swift @@ -11,48 +11,8 @@ extension PDFViewController { /// Initializes a new `PDFViewController` /// /// - parameter document: PDF document to be displayed - /// - parameter title: title that displays on the navigation bar on the PDFViewController; - /// if nil, uses document's filename - /// - parameter actionButtonImage: image of the action button; if nil, uses the default action system item image - /// - parameter actionStyle: sytle of the action button - /// - parameter backButton: button to override the default controller back button - /// - parameter isThumbnailsEnabled: whether or not the thumbnails bar should be enabled - /// - parameter startPageIndex: page index to start on load, defaults to 0; if out of bounds, set to 0 - /// + /// - parameter properties: PDFViewUIProperties comprising of values to and theme the UI components /// - returns: a `PDFViewController` -// public class func createNew(with document: PDFDocument, title: String? = nil, actionButtonImage: UIImage? = nil, actionStyle: ActionStyle?, isThumbnailsEnabled: Bool = true, startPageIndex: Int = 0) -> PDFViewController { -// let storyboard = UIStoryboard(name: "PDFReader", bundle: Bundle(for: PDFViewController.self)) -// let controller = storyboard.instantiateInitialViewController() as! PDFViewController -// controller.document = document -// controller.actionStyle = actionStyle -// -// if let title = title { -// controller.title = title -// } else { -// controller.title = document.fileName -// } -// -// if startPageIndex >= 0 && startPageIndex < document.pageCount { -// controller.currentPageIndex = startPageIndex -// } else { -// controller.currentPageIndex = 0 -// } -// -//// controller.backButtonImage = backButtonImage -// -// if actionStyle != nil { -// if let actionButtonImage = actionButtonImage { -// controller.actionButton = UIBarButtonItem(image: actionButtonImage, style: .plain, target: controller, action: #selector(actionButtonPressed)) -// } else { -// controller.actionButton = UIBarButtonItem(barButtonSystemItem: .action, target: controller, action: #selector(actionButtonPressed)) -// } -// } else { -// controller.actionButton = nil -// } -// controller.isThumbnailsEnabled = isThumbnailsEnabled -// return controller -// } - public class func createNew(with document: PDFDocument, properties: PDFViewUIProperties) -> PDFViewController { let storyboard = UIStoryboard(name: "PDFReader", bundle: Bundle(for: PDFViewController.self)) let controller = storyboard.instantiateInitialViewController() as! PDFViewController @@ -131,14 +91,7 @@ public final class PDFViewController: UIViewController { private var actionButton: UIBarButtonItem? /// Background color to apply to the collectionView. - public var backgroundColor: UIColor? = .lightGray /*{ - didSet { - collectionView?.backgroundColor = backgroundColor - } - }*/ - -// ///Back button image -// private var backButtonImage: UIImage? + public var backgroundColor: UIColor? = .lightGray /// Whether or not the thumbnails bar should be enabled private var isThumbnailsEnabled = true { @@ -170,12 +123,12 @@ public final class PDFViewController: UIViewController { override public func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .red//backgroundColor//.lightGray - collectionView.backgroundColor = .cyan//.clear//backgroundColor + view.backgroundColor = backgroundColor + collectionView.backgroundColor = backgroundColor collectionView.register(PDFPageCollectionViewCell.self, forCellWithReuseIdentifier: "page") navigationItem.rightBarButtonItem = actionButton - + navigationItem.hidesBackButton = true let numberOfPages = CGFloat(document.pageCount) @@ -247,8 +200,8 @@ public final class PDFViewController: UIViewController { let currentIndexPath = IndexPath(row: self.currentPageIndex, section: 0) self.collectionView.reloadItems(at: [currentIndexPath]) self.collectionView.scrollToItem(at: currentIndexPath, at: .centeredHorizontally, animated: false) - }) { context in - self.thumbnailCollectionController?.currentPageIndex = self.currentPageIndex + }) { context in + self.thumbnailCollectionController?.currentPageIndex = self.currentPageIndex } super.viewWillTransition(to: size, with: coordinator) @@ -311,20 +264,15 @@ extension PDFViewController: UICollectionViewDataSource { } public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "page", for: indexPath) as! PDFPageCollectionViewCell - - cell.setup(indexPath.row, collectionViewBounds: collectionView.bounds, document: document, pageCollectionViewCellDelegate: self) + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "page", for: indexPath) + if let pageCell = cell as? PDFPageCollectionViewCell { + pageCell.setup(indexPath.row, collectionViewBounds: collectionView.bounds, document: document, pageCollectionViewCellDelegate: self) + } return cell } } extension PDFViewController: PDFPageCollectionViewCellDelegate { - /// Toggles the hiding/showing of the thumbnail controller - /// - /// - parameter shouldHide: whether or not the controller should hide the thumbnail controller -// private func hideThumbnailController(_ shouldHide: Bool) { -// self.thumbnailCollectionControllerBottom.constant = shouldHide ? -thumbnailCollectionControllerHeight.constant : 0 -// } func handleSingleTap(_ cell: PDFPageCollectionViewCell, pdfPageView: PDFPageView) { if navigationViewTop.constant < CGFloat(0.0) { diff --git a/Sources/Classes/PDFViewUIProperties.swift b/Sources/Classes/PDFViewUIProperties.swift index ffa5aa9..c46e385 100644 --- a/Sources/Classes/PDFViewUIProperties.swift +++ b/Sources/Classes/PDFViewUIProperties.swift @@ -40,6 +40,7 @@ public struct PDFViewUIProperties { - backButtonImage: image for back button - isThumbnailsEnabled: whether or not the thumbnails bar should be enabled - lineViewColor: color for the line view + returns: a `PDFViewUIProperties` */ public init?(title: String?, titleFont: UIFont?, subtitle: String?, subtitleFont: UIFont?, backButtonImage: UIImage?, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor?) { self.title = title From 8059307a8a0244a173fcfe0fa13d64f156a6e225 Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Wed, 27 Jun 2018 10:28:34 +0100 Subject: [PATCH 04/17] fix: high cpu usage for iOS 9 --- Sources/Classes/PDFViewController.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Sources/Classes/PDFViewController.swift b/Sources/Classes/PDFViewController.swift index ce5db60..e1e9eb4 100644 --- a/Sources/Classes/PDFViewController.swift +++ b/Sources/Classes/PDFViewController.swift @@ -169,11 +169,6 @@ public final class PDFViewController: UIViewController { } } - public override func viewDidLayoutSubviews() { - super.viewDidLayoutSubviews() - didSelectIndexPath(IndexPath(row: currentPageIndex, section: 0)) - } - override public var prefersStatusBarHidden: Bool { return navigationController?.isNavigationBarHidden == true } From 46c7c397bfd932b270821bd6fbd641c1c71f0df5 Mon Sep 17 00:00:00 2001 From: Karim Sallam Date: Wed, 27 Jun 2018 11:17:58 +0100 Subject: [PATCH 05/17] fix: missing file --- PDFReader.xcodeproj/project.pbxproj | 32 +++++++++---------------- Sources/Classes/PDFViewController.swift | 2 +- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/PDFReader.xcodeproj/project.pbxproj b/PDFReader.xcodeproj/project.pbxproj index 4e3b3ae..3237922 100644 --- a/PDFReader.xcodeproj/project.pbxproj +++ b/PDFReader.xcodeproj/project.pbxproj @@ -26,9 +26,7 @@ 146D371F1DAB7EDF004EEFA5 /* StartViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 146D371E1DAB7EDF004EEFA5 /* StartViewController.swift */; }; 146D37231DAB7F0F004EEFA5 /* apple.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 146D37211DAB7F0F004EEFA5 /* apple.pdf */; }; 146D37241DAB7F0F004EEFA5 /* mongodb.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 146D37221DAB7F0F004EEFA5 /* mongodb.pdf */; }; - BA5FF58520E23D1200F8BBC0 /* book1.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BA5FF58420E23D1200F8BBC0 /* book1.pdf */; }; - BA5FF58720E23E7200F8BBC0 /* Inventions Prelims.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BA5FF58620E23E7200F8BBC0 /* Inventions Prelims.pdf */; }; - BA5FF58920E26F4500F8BBC0 /* PDFViewUIProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA5FF58820E26F4500F8BBC0 /* PDFViewUIProperties.swift */; }; + 8A044B8D20E39A05009D6A29 /* PDFViewUIProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A044B8C20E39A01009D6A29 /* PDFViewUIProperties.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -74,12 +72,10 @@ 146D37151DAB7E23004EEFA5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 146D37181DAB7E23004EEFA5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 146D371A1DAB7E23004EEFA5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 146D371E1DAB7EDF004EEFA5 /* StartViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartViewController.swift; sourceTree = ""; wrapsLines = 0; }; + 146D371E1DAB7EDF004EEFA5 /* StartViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartViewController.swift; sourceTree = ""; }; 146D37211DAB7F0F004EEFA5 /* apple.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = apple.pdf; sourceTree = ""; }; 146D37221DAB7F0F004EEFA5 /* mongodb.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = mongodb.pdf; sourceTree = ""; }; - BA5FF58420E23D1200F8BBC0 /* book1.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = book1.pdf; sourceTree = ""; }; - BA5FF58620E23E7200F8BBC0 /* Inventions Prelims.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = "Inventions Prelims.pdf"; sourceTree = ""; }; - BA5FF58820E26F4500F8BBC0 /* PDFViewUIProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDFViewUIProperties.swift; sourceTree = ""; }; + 8A044B8C20E39A01009D6A29 /* PDFViewUIProperties.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFViewUIProperties.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -149,13 +145,13 @@ 14083FE71D4A956E00909913 /* Classes */ = { isa = PBXGroup; children = ( + 8A044B8C20E39A01009D6A29 /* PDFViewUIProperties.swift */, 14083FE81D4A956E00909913 /* PDFDocument.swift */, 14083FE91D4A956E00909913 /* PDFPageCollectionViewCell.swift */, 14083FEA1D4A956E00909913 /* PDFPageView.swift */, 14083FEB1D4A956E00909913 /* PDFThumbnailCell.swift */, 14083FEC1D4A956E00909913 /* PDFThumbnailCollectionViewController.swift */, 14083FED1D4A956E00909913 /* PDFViewController.swift */, - BA5FF58820E26F4500F8BBC0 /* PDFViewUIProperties.swift */, 14083FEE1D4A956E00909913 /* TiledView.swift */, ); path = Classes; @@ -180,9 +176,7 @@ isa = PBXGroup; children = ( 146B852E1E30633A005F427E /* javaScript.pdf */, - BA5FF58420E23D1200F8BBC0 /* book1.pdf */, 146D37211DAB7F0F004EEFA5 /* apple.pdf */, - BA5FF58620E23E7200F8BBC0 /* Inventions Prelims.pdf */, 146D37221DAB7F0F004EEFA5 /* mongodb.pdf */, ); path = ExamplePDFs; @@ -251,11 +245,13 @@ TargetAttributes = { 14083FD81D4A953900909913 = { CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = YXKHJYMJA6; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; 146D370B1DAB7E23004EEFA5 = { CreatedOnToolsVersion = 8.0; + DevelopmentTeam = YXKHJYMJA6; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; @@ -295,12 +291,10 @@ files = ( 146D37191DAB7E23004EEFA5 /* LaunchScreen.storyboard in Resources */, 146D37161DAB7E23004EEFA5 /* Assets.xcassets in Resources */, - BA5FF58520E23D1200F8BBC0 /* book1.pdf in Resources */, 146D37141DAB7E23004EEFA5 /* Main.storyboard in Resources */, 146B85301E306460005F427E /* javaScript.pdf in Resources */, 146D37241DAB7F0F004EEFA5 /* mongodb.pdf in Resources */, 146D37231DAB7F0F004EEFA5 /* apple.pdf in Resources */, - BA5FF58720E23E7200F8BBC0 /* Inventions Prelims.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -315,7 +309,7 @@ 14083FF11D4A956E00909913 /* PDFPageCollectionViewCell.swift in Sources */, 14083FF01D4A956E00909913 /* PDFDocument.swift in Sources */, 14083FF51D4A956E00909913 /* PDFViewController.swift in Sources */, - BA5FF58920E26F4500F8BBC0 /* PDFViewUIProperties.swift in Sources */, + 8A044B8D20E39A05009D6A29 /* PDFViewUIProperties.swift in Sources */, 14083FF41D4A956E00909913 /* PDFThumbnailCollectionViewController.swift in Sources */, 14083FF31D4A956E00909913 /* PDFThumbnailCell.swift in Sources */, 14083FF61D4A956E00909913 /* TiledView.swift in Sources */, @@ -474,10 +468,9 @@ 14083FE21D4A953900909913 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = YXKHJYMJA6; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -497,10 +490,9 @@ 14083FE31D4A953900909913 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = YXKHJYMJA6; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -526,7 +518,7 @@ CLANG_WARN_SUSPICIOUS_MOVES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = YXKHJYMJA6; INFOPLIST_FILE = "$(SRCROOT)/PDFReader/Demo/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -536,7 +528,6 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -549,7 +540,7 @@ CLANG_WARN_SUSPICIOUS_MOVES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = YXKHJYMJA6; INFOPLIST_FILE = "$(SRCROOT)/PDFReader/Demo/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -558,7 +549,6 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; diff --git a/Sources/Classes/PDFViewController.swift b/Sources/Classes/PDFViewController.swift index e1e9eb4..2e805a6 100644 --- a/Sources/Classes/PDFViewController.swift +++ b/Sources/Classes/PDFViewController.swift @@ -127,7 +127,7 @@ public final class PDFViewController: UIViewController { collectionView.backgroundColor = backgroundColor collectionView.register(PDFPageCollectionViewCell.self, forCellWithReuseIdentifier: "page") - navigationItem.rightBarButtonItem = actionButton +// navigationItem.rightBarButtonItem = actionButton navigationItem.hidesBackButton = true From 8056713e692a5027f904a769d9ce0b56f12311b3 Mon Sep 17 00:00:00 2001 From: Karim Sallam Date: Wed, 27 Jun 2018 11:23:58 +0100 Subject: [PATCH 06/17] fix: made PDFViewUIProperties init not optional --- Sources/Classes/PDFViewUIProperties.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Classes/PDFViewUIProperties.swift b/Sources/Classes/PDFViewUIProperties.swift index c46e385..96b855a 100644 --- a/Sources/Classes/PDFViewUIProperties.swift +++ b/Sources/Classes/PDFViewUIProperties.swift @@ -42,7 +42,7 @@ public struct PDFViewUIProperties { - lineViewColor: color for the line view returns: a `PDFViewUIProperties` */ - public init?(title: String?, titleFont: UIFont?, subtitle: String?, subtitleFont: UIFont?, backButtonImage: UIImage?, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor?) { + public init(title: String?, titleFont: UIFont?, subtitle: String?, subtitleFont: UIFont?, backButtonImage: UIImage?, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor?) { self.title = title self.titleFont = titleFont self.subtitle = subtitle From 5f83de7142564d4b6bb0f8347a33bb81ae30485e Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Wed, 27 Jun 2018 13:59:03 +0100 Subject: [PATCH 07/17] fix: section insets for thumbnails collection view, PDFViewUIProperties init not optional --- PDFReader/Demo/StartViewController.swift | 10 +++++----- Sources/Assets/PDFReader.storyboard | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/PDFReader/Demo/StartViewController.swift b/PDFReader/Demo/StartViewController.swift index 549e1ab..dd4f1f1 100644 --- a/PDFReader/Demo/StartViewController.swift +++ b/PDFReader/Demo/StartViewController.swift @@ -63,10 +63,10 @@ internal final class StartViewController: UIViewController { /// /// Add `thumbnailsEnabled:false` to `createNew` to not load the thumbnails in the controller. private func showDocument(_ document: PDFDocument) { - if let properties = PDFViewUIProperties(title: "PDF", titleFont: UIFont(name: "Verdana", size: 16.0), subtitle: "subtitle", subtitleFont: UIFont(name: "Veradana", size: 13.0), backButtonImage: #imageLiteral(resourceName: "buttonBack64"), isThumbnailsEnabled: true, lineViewColor: .red) { - let controller = PDFViewController.createNew(with: document, properties: properties) - controller.backgroundColor = UIColor(red: 133 / 255, green: 132 / 255, blue: 138 / 255, alpha: 1.0) - navigationController?.pushViewController(controller, animated: true) - } + let properties = PDFViewUIProperties(title: "PDF", titleFont: UIFont(name: "Verdana", size: 16.0), subtitle: "subtitle", subtitleFont: UIFont(name: "Veradana", size: 13.0), backButtonImage: #imageLiteral(resourceName: "buttonBack64"), isThumbnailsEnabled: true, lineViewColor: .red) + let controller = PDFViewController.createNew(with: document, properties: properties) + controller.backgroundColor = UIColor(red: 133 / 255, green: 132 / 255, blue: 138 / 255, alpha: 1.0) + navigationController?.pushViewController(controller, animated: true) + } } diff --git a/Sources/Assets/PDFReader.storyboard b/Sources/Assets/PDFReader.storyboard index a7396b8..9b4c1cc 100644 --- a/Sources/Assets/PDFReader.storyboard +++ b/Sources/Assets/PDFReader.storyboard @@ -170,21 +170,21 @@ - + - + - + - + - + From efe5432996efc7fa57d8b64dc5a07aa23a72a18b Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Fri, 29 Jun 2018 15:13:07 +0100 Subject: [PATCH 08/17] fix: thumbnail border, empty thumbnails, content insets and UI fixes --- PDFReader.xcodeproj/project.pbxproj | 4 ++ PDFReader/Demo/StartViewController.swift | 8 ++-- Sources/Assets/PDFReader.storyboard | 31 +++++++------- Sources/Classes/PDFThumbnailCell.swift | 2 +- ...PDFThumbnailCollectionViewController.swift | 41 +++++++++++++++---- .../Classes/PDFThumbnailUIProperties.swift | 29 +++++++++++++ Sources/Classes/PDFViewController.swift | 31 +++++++++++--- 7 files changed, 111 insertions(+), 35 deletions(-) create mode 100644 Sources/Classes/PDFThumbnailUIProperties.swift diff --git a/PDFReader.xcodeproj/project.pbxproj b/PDFReader.xcodeproj/project.pbxproj index 3237922..c2c9dd1 100644 --- a/PDFReader.xcodeproj/project.pbxproj +++ b/PDFReader.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 146D37231DAB7F0F004EEFA5 /* apple.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 146D37211DAB7F0F004EEFA5 /* apple.pdf */; }; 146D37241DAB7F0F004EEFA5 /* mongodb.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 146D37221DAB7F0F004EEFA5 /* mongodb.pdf */; }; 8A044B8D20E39A05009D6A29 /* PDFViewUIProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A044B8C20E39A01009D6A29 /* PDFViewUIProperties.swift */; }; + BA24CD4A20E64A3100A24190 /* PDFThumbnailUIProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA24CD4920E64A3100A24190 /* PDFThumbnailUIProperties.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -76,6 +77,7 @@ 146D37211DAB7F0F004EEFA5 /* apple.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = apple.pdf; sourceTree = ""; }; 146D37221DAB7F0F004EEFA5 /* mongodb.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = mongodb.pdf; sourceTree = ""; }; 8A044B8C20E39A01009D6A29 /* PDFViewUIProperties.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFViewUIProperties.swift; sourceTree = ""; }; + BA24CD4920E64A3100A24190 /* PDFThumbnailUIProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDFThumbnailUIProperties.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -153,6 +155,7 @@ 14083FEC1D4A956E00909913 /* PDFThumbnailCollectionViewController.swift */, 14083FED1D4A956E00909913 /* PDFViewController.swift */, 14083FEE1D4A956E00909913 /* TiledView.swift */, + BA24CD4920E64A3100A24190 /* PDFThumbnailUIProperties.swift */, ); path = Classes; sourceTree = ""; @@ -312,6 +315,7 @@ 8A044B8D20E39A05009D6A29 /* PDFViewUIProperties.swift in Sources */, 14083FF41D4A956E00909913 /* PDFThumbnailCollectionViewController.swift in Sources */, 14083FF31D4A956E00909913 /* PDFThumbnailCell.swift in Sources */, + BA24CD4A20E64A3100A24190 /* PDFThumbnailUIProperties.swift in Sources */, 14083FF61D4A956E00909913 /* TiledView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/PDFReader/Demo/StartViewController.swift b/PDFReader/Demo/StartViewController.swift index dd4f1f1..8043412 100644 --- a/PDFReader/Demo/StartViewController.swift +++ b/PDFReader/Demo/StartViewController.swift @@ -13,7 +13,7 @@ import PDFReader internal final class StartViewController: UIViewController { /// Displays a smaller sized PDF document @IBAction private func showSmallPDFDocument() { - let smallPDFDocumentName = "Inventions Prelims" + let smallPDFDocumentName = "apple" if let doc = document(smallPDFDocumentName) { showDocument(doc) } else { @@ -61,10 +61,10 @@ internal final class StartViewController: UIViewController { /// /// - parameter document: document to present /// - /// Add `thumbnailsEnabled:false` to `createNew` to not load the thumbnails in the controller. private func showDocument(_ document: PDFDocument) { - let properties = PDFViewUIProperties(title: "PDF", titleFont: UIFont(name: "Verdana", size: 16.0), subtitle: "subtitle", subtitleFont: UIFont(name: "Veradana", size: 13.0), backButtonImage: #imageLiteral(resourceName: "buttonBack64"), isThumbnailsEnabled: true, lineViewColor: .red) - let controller = PDFViewController.createNew(with: document, properties: properties) + let pdfViewProperties = PDFViewUIProperties(title: "PDF", titleFont: UIFont(name: "Verdana", size: 16.0), subtitle: "subtitle", subtitleFont: UIFont(name: "Veradana", size: 13.0), backButtonImage: #imageLiteral(resourceName: "buttonBack64"), isThumbnailsEnabled: true, lineViewColor: .red) + let thumbnailUIProperties = PDFThumbnailUIProperties(activeThumbnailBorderColor: .black, inactiveThumbnailBorderColor: .lightGray) + let controller = PDFViewController.createNew(with: document, pdfViewProperties: pdfViewProperties, thumbnailUIProperties: thumbnailUIProperties) controller.backgroundColor = UIColor(red: 133 / 255, green: 132 / 255, blue: 138 / 255, alpha: 1.0) navigationController?.pushViewController(controller, animated: true) diff --git a/Sources/Assets/PDFReader.storyboard b/Sources/Assets/PDFReader.storyboard index 9b4c1cc..3832368 100644 --- a/Sources/Assets/PDFReader.storyboard +++ b/Sources/Assets/PDFReader.storyboard @@ -22,13 +22,13 @@ - + - + - + @@ -128,12 +128,12 @@ - + - + @@ -169,31 +169,32 @@ - - + + - + - + - + - - + + - - + + + @@ -207,7 +208,7 @@ - + diff --git a/Sources/Classes/PDFThumbnailCell.swift b/Sources/Classes/PDFThumbnailCell.swift index 3d007cc..12465d0 100644 --- a/Sources/Classes/PDFThumbnailCell.swift +++ b/Sources/Classes/PDFThumbnailCell.swift @@ -11,7 +11,7 @@ import UIKit /// An individual thumbnail in the collection view internal final class PDFThumbnailCell: UICollectionViewCell { /// Preferred size of each cell - static let cellSize = CGSize(width: 24, height: 44) + static let cellSize = CGSize(width: 18, height: 22) @IBOutlet var imageView: UIImageView? } diff --git a/Sources/Classes/PDFThumbnailCollectionViewController.swift b/Sources/Classes/PDFThumbnailCollectionViewController.swift index eefa1a6..eb72133 100644 --- a/Sources/Classes/PDFThumbnailCollectionViewController.swift +++ b/Sources/Classes/PDFThumbnailCollectionViewController.swift @@ -15,7 +15,7 @@ protocol PDFThumbnailControllerDelegate: class { } /// Bottom collection of thumbnails that the user can interact with -internal final class PDFThumbnailCollectionViewController: UICollectionViewController { +internal final class PDFThumbnailCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout { /// Current document being displayed var document: PDFDocument! @@ -23,11 +23,11 @@ internal final class PDFThumbnailCollectionViewController: UICollectionViewContr var currentPageIndex: Int = 0 { didSet { guard let collectionView = collectionView else { return } - guard let pageImages = pageImages else { return } - guard pageImages.count > 0 else { return } - let curentPageIndexPath = IndexPath(row: currentPageIndex, section: 0) - if !collectionView.indexPathsForVisibleItems.contains(curentPageIndexPath) { - collectionView.scrollToItem(at: curentPageIndexPath, at: .centeredHorizontally, animated: true) + if currentPageIndex < collectionView.numberOfItems(inSection: 0) { + let curentPageIndexPath = IndexPath(row: currentPageIndex, section: 0) + if !collectionView.indexPathsForVisibleItems.contains(curentPageIndexPath) { + collectionView.scrollToItem(at: curentPageIndexPath, at: .centeredHorizontally, animated: true) + } } collectionView.reloadData() } @@ -43,6 +43,9 @@ internal final class PDFThumbnailCollectionViewController: UICollectionViewContr } } + /// UI properties + var uiProperties: PDFThumbnailUIProperties? + override func viewDidLoad() { super.viewDidLoad() DispatchQueue.global(qos: .background).async { [weak self] in @@ -57,23 +60,43 @@ internal final class PDFThumbnailCollectionViewController: UICollectionViewContr } override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return pageImages?.count ?? 0 + return self.document.pageCount } override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) if let thumbnailCell = cell as? PDFThumbnailCell { thumbnailCell.imageView?.image = pageImages?[indexPath.row] - thumbnailCell.alpha = currentPageIndex == indexPath.row ? 1 : 0.2 } + + if let activeBorderColor = uiProperties?.activeThumbnailBorderColor, + let inactiveBorderColor = uiProperties?.inactiveThumbnailBorderColor { // if border colors are available, apply them + let borderColor = currentPageIndex == indexPath.row ? activeBorderColor : inactiveBorderColor + cell.layer.borderColor = borderColor.cgColor + cell.layer.borderWidth = 1.0 + } else { // else change the alpha + cell.alpha = currentPageIndex == indexPath.row ? 1 : 0.2 + } + return cell } - @objc func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize { + @objc func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return PDFThumbnailCell.cellSize } override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { delegate?.didSelectIndexPath(indexPath) } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return 2.0 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + if collectionView.bounds.width >= UIScreen.main.bounds.width { + return UIEdgeInsets(top: 0, left: 6, bottom: 0, right: 6) + } + return UIEdgeInsets.zero + } } diff --git a/Sources/Classes/PDFThumbnailUIProperties.swift b/Sources/Classes/PDFThumbnailUIProperties.swift new file mode 100644 index 0000000..4c716e3 --- /dev/null +++ b/Sources/Classes/PDFThumbnailUIProperties.swift @@ -0,0 +1,29 @@ +// +// PDFThumbnailUIProperties.swift +// PDFReader +// +// Created by Vrushali Wani on 29/06/2018. +// Copyright © 2018 mytrus. All rights reserved. +// + +import Foundation + +public struct PDFThumbnailUIProperties { + /// Border color for thumbnail for visible page (active) + public var activeThumbnailBorderColor: UIColor? + + /// Border color for thumbnails for invisible pages (inactive) + public var inactiveThumbnailBorderColor: UIColor? + + /** + Returns newly initialised PDFThumbnailUIProperties + + - activeThumbnailBorderColor: border color for thumbnail for visible page (active) + - inactiveThumbnailBorderColor: border color for thumbnails for invisible pages (inactive) + returns: a `PDFThumbnailUIProperties` + */ + public init(activeThumbnailBorderColor: UIColor?, inactiveThumbnailBorderColor: UIColor?) { + self.activeThumbnailBorderColor = activeThumbnailBorderColor + self.inactiveThumbnailBorderColor = inactiveThumbnailBorderColor + } +} diff --git a/Sources/Classes/PDFViewController.swift b/Sources/Classes/PDFViewController.swift index 2e805a6..6ac8525 100644 --- a/Sources/Classes/PDFViewController.swift +++ b/Sources/Classes/PDFViewController.swift @@ -10,14 +10,16 @@ import UIKit extension PDFViewController { /// Initializes a new `PDFViewController` /// - /// - parameter document: PDF document to be displayed - /// - parameter properties: PDFViewUIProperties comprising of values to and theme the UI components + /// - parameter document: PDF document to be displayed + /// - parameter pdfViewProperties: PDFViewUIProperties comprising values and theme for UI components + /// - parameter thumbnailUIProperties: PDFThumbnailUIProperties comprising theme for UI components /// - returns: a `PDFViewController` - public class func createNew(with document: PDFDocument, properties: PDFViewUIProperties) -> PDFViewController { + public class func createNew(with document: PDFDocument, pdfViewProperties: PDFViewUIProperties, thumbnailUIProperties: PDFThumbnailUIProperties) -> PDFViewController { let storyboard = UIStoryboard(name: "PDFReader", bundle: Bundle(for: PDFViewController.self)) let controller = storyboard.instantiateInitialViewController() as! PDFViewController controller.document = document - controller.uiProperties = properties + controller.uiProperties = pdfViewProperties + controller.thumbnailUIProperties = thumbnailUIProperties return controller } @@ -120,6 +122,9 @@ public final class PDFViewController: UIViewController { /// UI values private var uiProperties: PDFViewUIProperties? + ///Thumbnail UI properties + private var thumbnailUIProperties: PDFThumbnailUIProperties? + override public func viewDidLoad() { super.viewDidLoad() @@ -138,8 +143,6 @@ public final class PDFViewController: UIViewController { let width = min(thumbnailWidth, view.bounds.width) thumbnailCollectionControllerWidth.constant = width - lineViewSeparatingThumbnails.backgroundColor = backgroundColor - if let properties = uiProperties { if let title = properties.title { titleLabel.text = title @@ -165,10 +168,15 @@ public final class PDFViewController: UIViewController { if let lineViewColor = properties.lineViewColor { lineView.backgroundColor = lineViewColor + lineViewSeparatingThumbnails.backgroundColor = lineViewColor } } } + public override func didReceiveMemoryWarning() { + navigationController?.popViewController(animated: true) + } + override public var prefersStatusBarHidden: Bool { return navigationController?.isNavigationBarHidden == true } @@ -185,6 +193,7 @@ public final class PDFViewController: UIViewController { if let controller = segue.destination as? PDFThumbnailCollectionViewController { thumbnailCollectionController = controller controller.document = document + controller.uiProperties = thumbnailUIProperties controller.delegate = self controller.currentPageIndex = currentPageIndex } @@ -303,4 +312,14 @@ extension PDFViewController: UIScrollViewDelegate { thumbnailCollectionController?.currentPageIndex = currentPageIndex } } + + public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { + if navigationViewTop.constant != -navigationViewHeight.constant { + navigationViewTop.constant = -navigationViewHeight.constant + thumbnailCollectionControllerBottom.constant = -thumbnailCollectionControllerHeight.constant + } + UIView.animate(withDuration: 0.25) { + self.view.layoutIfNeeded() + } + } } From 40561f9f69b0bad9ab7e82ae85dcc2a932d6ef24 Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Mon, 2 Jul 2018 10:50:10 +0100 Subject: [PATCH 09/17] chore: removed 'final' from PDFViewController --- PDFReader/Demo/StartViewController.swift | 1 - Sources/Classes/PDFViewController.swift | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/PDFReader/Demo/StartViewController.swift b/PDFReader/Demo/StartViewController.swift index 8043412..aa24dbe 100644 --- a/PDFReader/Demo/StartViewController.swift +++ b/PDFReader/Demo/StartViewController.swift @@ -67,6 +67,5 @@ internal final class StartViewController: UIViewController { let controller = PDFViewController.createNew(with: document, pdfViewProperties: pdfViewProperties, thumbnailUIProperties: thumbnailUIProperties) controller.backgroundColor = UIColor(red: 133 / 255, green: 132 / 255, blue: 138 / 255, alpha: 1.0) navigationController?.pushViewController(controller, animated: true) - } } diff --git a/Sources/Classes/PDFViewController.swift b/Sources/Classes/PDFViewController.swift index 6ac8525..3f100cd 100644 --- a/Sources/Classes/PDFViewController.swift +++ b/Sources/Classes/PDFViewController.swift @@ -26,7 +26,7 @@ extension PDFViewController { } /// Controller that is able to interact and navigate through pages of a `PDFDocument` -public final class PDFViewController: UIViewController { +public class PDFViewController: UIViewController { /// Action button style public enum ActionStyle { /// Brings up a print modal allowing user to print current PDF From 4552392e75219afe0540dc36ff2b5e883a557345 Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Mon, 2 Jul 2018 11:30:32 +0100 Subject: [PATCH 10/17] feat: added guid of product --- PDFReader/Demo/StartViewController.swift | 2 +- Sources/Classes/PDFViewUIProperties.swift | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/PDFReader/Demo/StartViewController.swift b/PDFReader/Demo/StartViewController.swift index aa24dbe..2967e45 100644 --- a/PDFReader/Demo/StartViewController.swift +++ b/PDFReader/Demo/StartViewController.swift @@ -62,7 +62,7 @@ internal final class StartViewController: UIViewController { /// - parameter document: document to present /// private func showDocument(_ document: PDFDocument) { - let pdfViewProperties = PDFViewUIProperties(title: "PDF", titleFont: UIFont(name: "Verdana", size: 16.0), subtitle: "subtitle", subtitleFont: UIFont(name: "Veradana", size: 13.0), backButtonImage: #imageLiteral(resourceName: "buttonBack64"), isThumbnailsEnabled: true, lineViewColor: .red) + let pdfViewProperties = PDFViewUIProperties(guid: "123", title: "PDF", titleFont: UIFont(name: "Verdana", size: 16.0), subtitle: "subtitle", subtitleFont: UIFont(name: "Veradana", size: 13.0), backButtonImage: #imageLiteral(resourceName: "buttonBack64"), isThumbnailsEnabled: true, lineViewColor: .red) let thumbnailUIProperties = PDFThumbnailUIProperties(activeThumbnailBorderColor: .black, inactiveThumbnailBorderColor: .lightGray) let controller = PDFViewController.createNew(with: document, pdfViewProperties: pdfViewProperties, thumbnailUIProperties: thumbnailUIProperties) controller.backgroundColor = UIColor(red: 133 / 255, green: 132 / 255, blue: 138 / 255, alpha: 1.0) diff --git a/Sources/Classes/PDFViewUIProperties.swift b/Sources/Classes/PDFViewUIProperties.swift index 96b855a..ec0e757 100644 --- a/Sources/Classes/PDFViewUIProperties.swift +++ b/Sources/Classes/PDFViewUIProperties.swift @@ -30,9 +30,12 @@ public struct PDFViewUIProperties { /// Color of the line view public var lineViewColor: UIColor? + /// Guid + public var guid: String + /** Returns newly initialised PDFViewUIProperties - + - guid: Guid of product - title: Title for the pdf - titleFont: font for the title label - subtitle: subtitle for the pdf @@ -42,7 +45,8 @@ public struct PDFViewUIProperties { - lineViewColor: color for the line view returns: a `PDFViewUIProperties` */ - public init(title: String?, titleFont: UIFont?, subtitle: String?, subtitleFont: UIFont?, backButtonImage: UIImage?, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor?) { + public init(guid: String, title: String?, titleFont: UIFont?, subtitle: String?, subtitleFont: UIFont?, backButtonImage: UIImage?, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor?) { + self.guid = guid self.title = title self.titleFont = titleFont self.subtitle = subtitle From ac69fadd9edd2b6ab641daae2002ee0787148fd9 Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Mon, 2 Jul 2018 11:38:59 +0100 Subject: [PATCH 11/17] feat: public access to uiProperties --- Sources/Classes/PDFViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Classes/PDFViewController.swift b/Sources/Classes/PDFViewController.swift index 3f100cd..7e5b26a 100644 --- a/Sources/Classes/PDFViewController.swift +++ b/Sources/Classes/PDFViewController.swift @@ -120,7 +120,7 @@ public class PDFViewController: UIViewController { } /// UI values - private var uiProperties: PDFViewUIProperties? + public var uiProperties: PDFViewUIProperties? ///Thumbnail UI properties private var thumbnailUIProperties: PDFThumbnailUIProperties? From 38cf0d8396b234f260db87ca844d800a1d0fceb5 Mon Sep 17 00:00:00 2001 From: Vrushali Wani <> Date: Mon, 2 Jul 2018 13:58:39 +0100 Subject: [PATCH 12/17] fix: made UIProperties initialiser var optionals --- Sources/Classes/PDFViewUIProperties.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Classes/PDFViewUIProperties.swift b/Sources/Classes/PDFViewUIProperties.swift index ec0e757..306ed2d 100644 --- a/Sources/Classes/PDFViewUIProperties.swift +++ b/Sources/Classes/PDFViewUIProperties.swift @@ -45,7 +45,7 @@ public struct PDFViewUIProperties { - lineViewColor: color for the line view returns: a `PDFViewUIProperties` */ - public init(guid: String, title: String?, titleFont: UIFont?, subtitle: String?, subtitleFont: UIFont?, backButtonImage: UIImage?, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor?) { + public init(guid: String, title: String? = nil, titleFont: UIFont? = nil, subtitle: String? = nil, subtitleFont: UIFont? = nil, backButtonImage: UIImage? = nil, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor? = nil) { self.guid = guid self.title = title self.titleFont = titleFont @@ -55,4 +55,6 @@ public struct PDFViewUIProperties { self.isThumbnailsEnabled = isThumbnailsEnabled self.lineViewColor = lineViewColor } + + } From 923654583d782c36cf837cd641f50110826a7495 Mon Sep 17 00:00:00 2001 From: Ricardo Nunez Date: Fri, 14 Sep 2018 15:09:59 -0700 Subject: [PATCH 13/17] Uses Swift 4.2 and Xcode 10 --- PDFReader.xcodeproj/project.pbxproj | 55 ++++++++++++------- .../xcshareddata/xcschemes/PDFReader.xcscheme | 4 +- PDFReader/Demo/AppDelegate.swift | 2 +- README.md | 4 +- Sources/Classes/PDFPageView.swift | 4 +- Sources/Classes/PDFViewController.swift | 2 +- 6 files changed, 42 insertions(+), 29 deletions(-) diff --git a/PDFReader.xcodeproj/project.pbxproj b/PDFReader.xcodeproj/project.pbxproj index 4c4496d..e984cca 100644 --- a/PDFReader.xcodeproj/project.pbxproj +++ b/PDFReader.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ @@ -237,23 +237,23 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = mytrus; TargetAttributes = { 14083FD81D4A953900909913 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; ProvisioningStyle = Automatic; }; 146D370B1DAB7E23004EEFA5 = { CreatedOnToolsVersion = 8.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; ProvisioningStyle = Automatic; }; }; }; buildConfigurationList = 14083FD31D4A953900909913 /* Build configuration list for PBXProject "PDFReader" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 10.0"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( @@ -362,12 +362,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -420,12 +422,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -450,7 +454,8 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -472,13 +477,16 @@ INFOPLIST_FILE = PDFReader/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mytrus.PDFReader; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -495,13 +503,16 @@ INFOPLIST_FILE = PDFReader/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mytrus.PDFReader; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -514,16 +525,18 @@ CLANG_WARN_SUSPICIOUS_MOVES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = HC9R4J3HM5; INFOPLIST_FILE = "$(SRCROOT)/PDFReader/Demo/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mytrus.Demo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -536,15 +549,17 @@ CLANG_WARN_SUSPICIOUS_MOVES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = HC9R4J3HM5; INFOPLIST_FILE = "$(SRCROOT)/PDFReader/Demo/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mytrus.Demo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/PDFReader.xcodeproj/xcshareddata/xcschemes/PDFReader.xcscheme b/PDFReader.xcodeproj/xcshareddata/xcschemes/PDFReader.xcscheme index 2497cb1..d6fc2af 100644 --- a/PDFReader.xcodeproj/xcshareddata/xcschemes/PDFReader.xcscheme +++ b/PDFReader.xcodeproj/xcshareddata/xcschemes/PDFReader.xcscheme @@ -1,6 +1,6 @@ @@ -37,7 +36,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/PDFReader/Demo/AppDelegate.swift b/PDFReader/Demo/AppDelegate.swift index a8796fd..3586744 100755 --- a/PDFReader/Demo/AppDelegate.swift +++ b/PDFReader/Demo/AppDelegate.swift @@ -12,7 +12,7 @@ import UIKit class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } } diff --git a/README.md b/README.md index cfc492e..aafeba5 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Deprecated in favor of [PDFKIT](https://developer.apple.com/documentation/pdfkit) for iOS 11 apps +# Deprecated in favor of [PDFKIT](https://developer.apple.com/documentation/pdfkit) for iOS 11+ apps # iOS-PDF-Reader [![Version](https://img.shields.io/cocoapods/v/PDFReader.svg?style=flat)](http://cocoapods.org/pods/PDFReader) @@ -17,7 +17,7 @@ PDF Reader for iOS written in Swift ## Requirements - iOS 8.0+ -- Swift 4 +- Swift 4.2 ## Installation diff --git a/Sources/Classes/PDFPageView.swift b/Sources/Classes/PDFPageView.swift index c4d020b..090ee30 100755 --- a/Sources/Classes/PDFPageView.swift +++ b/Sources/Classes/PDFPageView.swift @@ -87,7 +87,7 @@ internal final class PDFPageView: UIScrollView { } contentView.addSubview(backgroundImageView) - contentView.sendSubview(toBack: backgroundImageView) + contentView.sendSubviewToBack(backgroundImageView) contentView.addSubview(tiledPDFView) addSubview(contentView) @@ -104,7 +104,7 @@ internal final class PDFPageView: UIScrollView { singleTapOne.require(toFail: doubleTapOne) bouncesZoom = false - decelerationRate = UIScrollViewDecelerationRateFast + decelerationRate = UIScrollView.DecelerationRate.fast delegate = self autoresizesSubviews = true autoresizingMask = [.flexibleHeight, .flexibleWidth] diff --git a/Sources/Classes/PDFViewController.swift b/Sources/Classes/PDFViewController.swift index f468155..5c38d21 100755 --- a/Sources/Classes/PDFViewController.swift +++ b/Sources/Classes/PDFViewController.swift @@ -116,7 +116,7 @@ public final class PDFViewController: UIViewController { } /// Slides horizontally (from left to right, default) or vertically (from top to bottom) - public var scrollDirection: UICollectionViewScrollDirection = .horizontal { + public var scrollDirection: UICollectionView.ScrollDirection = .horizontal { didSet { if collectionView == nil { // if the user of the controller is trying to change the scrollDiecton before it _ = view // is on the sceen, we need to show it ofscreen to access it's collectionView. From 39efa4bc1068ad703f947c33e5ecde547d1cddc0 Mon Sep 17 00:00:00 2001 From: cedricr Date: Mon, 17 Sep 2018 10:57:12 +0200 Subject: [PATCH 14/17] Reset page/cell when unpresented (e.g. zoom gets reset back) --- Sources/Classes/PDFViewController.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Classes/PDFViewController.swift b/Sources/Classes/PDFViewController.swift index 5c38d21..610f2d1 100755 --- a/Sources/Classes/PDFViewController.swift +++ b/Sources/Classes/PDFViewController.swift @@ -127,6 +127,9 @@ public final class PDFViewController: UIViewController { } } + /// Reset page when its unpresented + public var resetZoom: Bool = false + override public func viewDidLoad() { super.viewDidLoad() @@ -278,6 +281,9 @@ extension PDFViewController: UIScrollViewDelegate { } if updatedPageIndex != currentPageIndex { + if resetZoom { + self.collectionView.reloadItems(at: [IndexPath(item: currentPageIndex, section: 0)]) + } currentPageIndex = updatedPageIndex thumbnailCollectionController?.currentPageIndex = currentPageIndex } From b65c45edfd4cad9d754ece44b78c327ba924d1d8 Mon Sep 17 00:00:00 2001 From: Karim Sallam Date: Tue, 25 Sep 2018 10:55:22 +0100 Subject: [PATCH 15/17] build all architectures --- PDFReader.xcodeproj/project.pbxproj | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PDFReader.xcodeproj/project.pbxproj b/PDFReader.xcodeproj/project.pbxproj index 61ce2ed..bdeb858 100644 --- a/PDFReader.xcodeproj/project.pbxproj +++ b/PDFReader.xcodeproj/project.pbxproj @@ -409,7 +409,6 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0; @@ -536,7 +535,10 @@ DEVELOPMENT_TEAM = YXKHJYMJA6; INFOPLIST_FILE = "$(SRCROOT)/PDFReader/Demo/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mytrus.Demo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -557,7 +559,10 @@ DEVELOPMENT_TEAM = YXKHJYMJA6; INFOPLIST_FILE = "$(SRCROOT)/PDFReader/Demo/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mytrus.Demo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; From afcfb15000aa3f2e1b1a03a4cd3b07dfa5c9b313 Mon Sep 17 00:00:00 2001 From: Vrushali Wani Date: Tue, 26 Mar 2019 21:03:59 +0000 Subject: [PATCH 16/17] feat: added 'hasFreeUsagePolicy' which specifies availability to users without subscription --- Sources/Classes/PDFViewUIProperties.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/Classes/PDFViewUIProperties.swift b/Sources/Classes/PDFViewUIProperties.swift index 306ed2d..e5eaecc 100644 --- a/Sources/Classes/PDFViewUIProperties.swift +++ b/Sources/Classes/PDFViewUIProperties.swift @@ -33,6 +33,9 @@ public struct PDFViewUIProperties { /// Guid public var guid: String + /// specifies whether the pdf is accessible without subscription. Used for analytics + public var hasFreeUsagePolicy: Bool? + /** Returns newly initialised PDFViewUIProperties - guid: Guid of product @@ -43,9 +46,10 @@ public struct PDFViewUIProperties { - backButtonImage: image for back button - isThumbnailsEnabled: whether or not the thumbnails bar should be enabled - lineViewColor: color for the line view + - hasFreeUsagePolicy: availability to users without subscription returns: a `PDFViewUIProperties` */ - public init(guid: String, title: String? = nil, titleFont: UIFont? = nil, subtitle: String? = nil, subtitleFont: UIFont? = nil, backButtonImage: UIImage? = nil, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor? = nil) { + public init(guid: String, title: String? = nil, titleFont: UIFont? = nil, subtitle: String? = nil, subtitleFont: UIFont? = nil, backButtonImage: UIImage? = nil, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor? = nil, hasFreeUsagePolicy: Bool? = nil) { self.guid = guid self.title = title self.titleFont = titleFont @@ -54,7 +58,6 @@ public struct PDFViewUIProperties { self.backButtonImage = backButtonImage self.isThumbnailsEnabled = isThumbnailsEnabled self.lineViewColor = lineViewColor + self.hasFreeUsagePolicy = hasFreeUsagePolicy } - - } From c84372088bd9400e3002e7184142fbb8d33a9898 Mon Sep 17 00:00:00 2001 From: Vrushali Wani Date: Wed, 27 Mar 2019 14:00:43 +0000 Subject: [PATCH 17/17] refactor: made 'hasFreeUsagePolicy' non-optional --- Sources/Classes/PDFViewUIProperties.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Classes/PDFViewUIProperties.swift b/Sources/Classes/PDFViewUIProperties.swift index e5eaecc..8f420a9 100644 --- a/Sources/Classes/PDFViewUIProperties.swift +++ b/Sources/Classes/PDFViewUIProperties.swift @@ -34,7 +34,7 @@ public struct PDFViewUIProperties { public var guid: String /// specifies whether the pdf is accessible without subscription. Used for analytics - public var hasFreeUsagePolicy: Bool? + public var hasFreeUsagePolicy: Bool /** Returns newly initialised PDFViewUIProperties @@ -49,7 +49,7 @@ public struct PDFViewUIProperties { - hasFreeUsagePolicy: availability to users without subscription returns: a `PDFViewUIProperties` */ - public init(guid: String, title: String? = nil, titleFont: UIFont? = nil, subtitle: String? = nil, subtitleFont: UIFont? = nil, backButtonImage: UIImage? = nil, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor? = nil, hasFreeUsagePolicy: Bool? = nil) { + public init(guid: String, title: String? = nil, titleFont: UIFont? = nil, subtitle: String? = nil, subtitleFont: UIFont? = nil, backButtonImage: UIImage? = nil, isThumbnailsEnabled: Bool = true, lineViewColor: UIColor? = nil, hasFreeUsagePolicy: Bool = false) { self.guid = guid self.title = title self.titleFont = titleFont