From 22cd9cbf085d5d399d0267d5691e345bad8bedef Mon Sep 17 00:00:00 2001 From: Duane de Moura Silva Date: Mon, 14 Jan 2019 11:45:26 -0200 Subject: [PATCH] update swift 4.2 --- Cartfile | 8 +-- Cartfile.resolved | 8 +-- FolioReaderKit.podspec | 8 +-- FolioReaderKit.xcodeproj/project.pbxproj | 54 ++++++++++++------- .../xcschemes/FolioReaderKit.xcscheme | 4 +- Source/Extensions.swift | 18 +++---- Source/FolioReaderAddHighlightNote.swift | 10 ++-- Source/FolioReaderAudioPlayer.swift | 10 ++-- Source/FolioReaderCenter.swift | 22 ++++---- Source/FolioReaderChapterList.swift | 4 +- Source/FolioReaderChapterListCell.swift | 2 +- Source/FolioReaderConfig.swift | 2 +- Source/FolioReaderContainer.swift | 8 +-- Source/FolioReaderFontsMenu.swift | 6 +-- Source/FolioReaderHighlightList.swift | 28 +++++----- Source/FolioReaderKit.swift | 8 +-- Source/FolioReaderPage.swift | 4 +- Source/FolioReaderPageIndicator.swift | 4 +- Source/FolioReaderPlayerMenu.swift | 32 +++++------ Source/FolioReaderQuoteShare.swift | 20 ++++--- Source/FolioReaderSharingProvider.swift | 8 +-- Source/FolioReaderWebView.swift | 4 +- Source/PageViewController.swift | 8 +-- Source/ScrollScrubber.swift | 4 +- Vendor/HAControls/HADiscreteSlider.swift | 2 +- Vendor/SMSegmentView/SMSegment.swift | 6 +-- 26 files changed, 153 insertions(+), 139 deletions(-) diff --git a/Cartfile b/Cartfile index 62b60a747..d03518979 100644 --- a/Cartfile +++ b/Cartfile @@ -1,7 +1,7 @@ github "ZipArchive/ZipArchive" == 2.1.1 -github "cxa/MenuItemKit" == 3.0.0 +github "cxa/MenuItemKit" == 3.1.3 github "alexpopov/ZFDragableModalTransition" "merge-carthage-into-zoonooz" -github "tadija/AEXML" == 4.2.2 -github "ArtSabintsev/FontBlaster" == 4.0.1 +github "tadija/AEXML" == 4.3.3 +github "ArtSabintsev/FontBlaster" == 4.1.0 github "jessesquires/JSQWebViewController" == 6.0.0 -github "realm/realm-cocoa" == 3.1.1 +github "realm/realm-cocoa" == 3.13.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 883b6f499..43f7c7ec7 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,7 +1,7 @@ -github "ArtSabintsev/FontBlaster" "4.0.1" +github "ArtSabintsev/FontBlaster" "4.1.0" github "ZipArchive/ZipArchive" "v2.1.1" github "alexpopov/ZFDragableModalTransition" "8da951efb4202385630d1cf7104b60d1208f807e" -github "cxa/MenuItemKit" "3.0.0" +github "cxa/MenuItemKit" "3.1.3" github "jessesquires/JSQWebViewController" "6.0.0" -github "realm/realm-cocoa" "v3.1.1" -github "tadija/AEXML" "4.2.2" +github "realm/realm-cocoa" "v3.13.0" +github "tadija/AEXML" "4.3.3" diff --git a/FolioReaderKit.podspec b/FolioReaderKit.podspec index 4a0388c10..a249fcee0 100644 --- a/FolioReaderKit.podspec +++ b/FolioReaderKit.podspec @@ -31,11 +31,11 @@ Pod::Spec.new do |s| s.libraries = "z" s.dependency 'SSZipArchive', '2.1.1' - s.dependency 'MenuItemKit', '3.0.0' + s.dependency 'MenuItemKit', '3.1.3' s.dependency 'ZFDragableModalTransition', '0.6' - s.dependency 'AEXML', '4.2.2' - s.dependency 'FontBlaster', '4.0.1' + s.dependency 'AEXML', '4.3.3' + s.dependency 'FontBlaster', '4.1.0' s.dependency 'JSQWebViewController', '6.0.0' - s.dependency 'RealmSwift', '3.1.1' + s.dependency 'RealmSwift', '3.13.0' end diff --git a/FolioReaderKit.xcodeproj/project.pbxproj b/FolioReaderKit.xcodeproj/project.pbxproj index 23a628d4e..fac630937 100644 --- a/FolioReaderKit.xcodeproj/project.pbxproj +++ b/FolioReaderKit.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 146014E621ECBBFB0000456B /* AEXML.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 146014DF21ECBBFB0000456B /* AEXML.framework */; }; + 146014E721ECBBFB0000456B /* FontBlaster.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 146014E021ECBBFB0000456B /* FontBlaster.framework */; }; + 146014EA21ECBBFB0000456B /* JSQWebViewController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 146014E321ECBBFB0000456B /* JSQWebViewController.framework */; }; + 146014EE21ECC27F0000456B /* ZFDragableModalTransition.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 146014ED21ECC27F0000456B /* ZFDragableModalTransition.framework */; }; 1A41E8912031E22300A8F70C /* MediaType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A41E8902031E22300A8F70C /* MediaType.swift */; }; 1A65DDCC1DA73F8E0033C277 /* MenuItemKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A65DDCB1DA73F8D0033C277 /* MenuItemKit.framework */; }; 1A65DDD21DA744190033C277 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A65DDD01DA744190033C277 /* Realm.framework */; }; @@ -103,10 +107,6 @@ B0D69CC81D0387F7003B4CCD /* HADiscreteSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C441D0387F7003B4CCD /* HADiscreteSlider.swift */; }; B0D69CC91D0387F7003B4CCD /* SMSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C461D0387F7003B4CCD /* SMSegment.swift */; }; B0D69CCA1D0387F7003B4CCD /* SMSegmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C471D0387F7003B4CCD /* SMSegmentView.swift */; }; - B0D69CD11D0388EF003B4CCD /* AEXML.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCB1D0388EF003B4CCD /* AEXML.framework */; }; - B0D69CD21D0388EF003B4CCD /* FontBlaster.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCC1D0388EF003B4CCD /* FontBlaster.framework */; }; - B0D69CD31D0388EF003B4CCD /* JSQWebViewController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCD1D0388EF003B4CCD /* JSQWebViewController.framework */; }; - B0D69CD51D0388EF003B4CCD /* ZFDragableModalTransition.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCF1D0388EF003B4CCD /* ZFDragableModalTransition.framework */; }; B0D69CD61D0388EF003B4CCD /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CD01D0388EF003B4CCD /* ZipArchive.framework */; }; /* End PBXBuildFile section */ @@ -121,6 +121,14 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 146014DF21ECBBFB0000456B /* AEXML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AEXML.framework; path = Carthage/Build/iOS/AEXML.framework; sourceTree = ""; }; + 146014E021ECBBFB0000456B /* FontBlaster.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FontBlaster.framework; path = Carthage/Build/iOS/FontBlaster.framework; sourceTree = ""; }; + 146014E121ECBBFB0000456B /* ZipArchive.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ZipArchive.framework; path = Carthage/Build/iOS/ZipArchive.framework; sourceTree = ""; }; + 146014E221ECBBFB0000456B /* MenuItemKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MenuItemKit.framework; path = Carthage/Build/iOS/MenuItemKit.framework; sourceTree = ""; }; + 146014E321ECBBFB0000456B /* JSQWebViewController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JSQWebViewController.framework; path = Carthage/Build/iOS/JSQWebViewController.framework; sourceTree = ""; }; + 146014E421ECBBFB0000456B /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = Carthage/Build/iOS/RealmSwift.framework; sourceTree = ""; }; + 146014E521ECBBFB0000456B /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = Carthage/Build/iOS/Realm.framework; sourceTree = ""; }; + 146014ED21ECC27F0000456B /* ZFDragableModalTransition.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ZFDragableModalTransition.framework; path = Carthage/Build/iOS/ZFDragableModalTransition.framework; sourceTree = ""; }; 1A41E8902031E22300A8F70C /* MediaType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaType.swift; sourceTree = ""; }; 1A65DDCB1DA73F8D0033C277 /* MenuItemKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MenuItemKit.framework; path = Carthage/Build/iOS/MenuItemKit.framework; sourceTree = ""; }; 1A65DDD01DA744190033C277 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = Carthage/Build/iOS/Realm.framework; sourceTree = ""; }; @@ -187,10 +195,6 @@ B0D69C441D0387F7003B4CCD /* HADiscreteSlider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HADiscreteSlider.swift; sourceTree = ""; }; B0D69C461D0387F7003B4CCD /* SMSegment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SMSegment.swift; sourceTree = ""; }; B0D69C471D0387F7003B4CCD /* SMSegmentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SMSegmentView.swift; sourceTree = ""; }; - B0D69CCB1D0388EF003B4CCD /* AEXML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AEXML.framework; path = Carthage/Build/iOS/AEXML.framework; sourceTree = ""; }; - B0D69CCC1D0388EF003B4CCD /* FontBlaster.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FontBlaster.framework; path = Carthage/Build/iOS/FontBlaster.framework; sourceTree = ""; }; - B0D69CCD1D0388EF003B4CCD /* JSQWebViewController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JSQWebViewController.framework; path = Carthage/Build/iOS/JSQWebViewController.framework; sourceTree = ""; }; - B0D69CCF1D0388EF003B4CCD /* ZFDragableModalTransition.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ZFDragableModalTransition.framework; path = Carthage/Build/iOS/ZFDragableModalTransition.framework; sourceTree = ""; }; B0D69CD01D0388EF003B4CCD /* ZipArchive.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ZipArchive.framework; path = Carthage/Build/iOS/ZipArchive.framework; sourceTree = ""; }; /* End PBXFileReference section */ @@ -200,13 +204,13 @@ buildActionMask = 2147483647; files = ( 1A65DDCC1DA73F8E0033C277 /* MenuItemKit.framework in Frameworks */, - B0D69CD11D0388EF003B4CCD /* AEXML.framework in Frameworks */, - B0D69CD21D0388EF003B4CCD /* FontBlaster.framework in Frameworks */, - B0D69CD31D0388EF003B4CCD /* JSQWebViewController.framework in Frameworks */, - B0D69CD51D0388EF003B4CCD /* ZFDragableModalTransition.framework in Frameworks */, + 146014EE21ECC27F0000456B /* ZFDragableModalTransition.framework in Frameworks */, + 146014EA21ECBBFB0000456B /* JSQWebViewController.framework in Frameworks */, + 146014E621ECBBFB0000456B /* AEXML.framework in Frameworks */, B0D69CD61D0388EF003B4CCD /* ZipArchive.framework in Frameworks */, 1A65DDD21DA744190033C277 /* Realm.framework in Frameworks */, 1A65DDD31DA744190033C277 /* RealmSwift.framework in Frameworks */, + 146014E721ECBBFB0000456B /* FontBlaster.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -401,10 +405,14 @@ B0D69B501D0365AC003B4CCD /* Frameworks */ = { isa = PBXGroup; children = ( - B0D69CCB1D0388EF003B4CCD /* AEXML.framework */, - B0D69CCC1D0388EF003B4CCD /* FontBlaster.framework */, - B0D69CCD1D0388EF003B4CCD /* JSQWebViewController.framework */, - B0D69CCF1D0388EF003B4CCD /* ZFDragableModalTransition.framework */, + 146014ED21ECC27F0000456B /* ZFDragableModalTransition.framework */, + 146014DF21ECBBFB0000456B /* AEXML.framework */, + 146014E021ECBBFB0000456B /* FontBlaster.framework */, + 146014E321ECBBFB0000456B /* JSQWebViewController.framework */, + 146014E221ECBBFB0000456B /* MenuItemKit.framework */, + 146014E521ECBBFB0000456B /* Realm.framework */, + 146014E421ECBBFB0000456B /* RealmSwift.framework */, + 146014E121ECBBFB0000456B /* ZipArchive.framework */, B0D69CD01D0388EF003B4CCD /* ZipArchive.framework */, ); name = Frameworks; @@ -495,7 +503,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = FolioReader; TargetAttributes = { B0D6990A1D035FA2003B4CCD = { @@ -671,12 +679,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; @@ -729,12 +739,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; @@ -771,6 +783,7 @@ B0D699201D035FA2003B4CCD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; @@ -783,17 +796,19 @@ ); INFOPLIST_FILE = FolioReaderKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKit; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Debug; }; B0D699211D035FA2003B4CCD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; @@ -806,11 +821,12 @@ ); INFOPLIST_FILE = FolioReaderKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKit; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/FolioReaderKit.xcodeproj/xcshareddata/xcschemes/FolioReaderKit.xcscheme b/FolioReaderKit.xcodeproj/xcshareddata/xcschemes/FolioReaderKit.xcscheme index 2e3f859ca..2ab8c3478 100644 --- a/FolioReaderKit.xcodeproj/xcshareddata/xcschemes/FolioReaderKit.xcscheme +++ b/FolioReaderKit.xcodeproj/xcshareddata/xcschemes/FolioReaderKit.xcscheme @@ -1,6 +1,6 @@ UICollectionViewScrollDirection { +extension UICollectionView.ScrollDirection { + static func direction(withConfiguration readerConfig: FolioReaderConfig) -> UICollectionView.ScrollDirection { return readerConfig.isDirection(.vertical, .horizontal, .horizontal) } } -extension UICollectionViewScrollPosition { - static func direction(withConfiguration readerConfig: FolioReaderConfig) -> UICollectionViewScrollPosition { +extension UICollectionView.ScrollPosition { + static func direction(withConfiguration readerConfig: FolioReaderConfig) -> UICollectionView.ScrollPosition { return readerConfig.isDirection(.top, .left, .left) } } @@ -462,20 +462,20 @@ internal extension UIViewController { navBar?.showBottomHairline() navBar?.isTranslucent = translucent navBar?.tintColor = tintColor - navBar?.titleTextAttributes = [NSAttributedStringKey.foregroundColor: titleColor, NSAttributedStringKey.font: font] + navBar?.titleTextAttributes = [NSAttributedString.Key.foregroundColor: titleColor, NSAttributedString.Key.font: font] } } internal extension UINavigationBar { func hideBottomHairline() { - let navigationBarImageView = hairlineImageViewInNavigationBar(self) - navigationBarImageView!.isHidden = true + guard let navigationBarImageView = hairlineImageViewInNavigationBar(self) else {return} + navigationBarImageView.isHidden = true } func showBottomHairline() { - let navigationBarImageView = hairlineImageViewInNavigationBar(self) - navigationBarImageView!.isHidden = false + guard let navigationBarImageView = hairlineImageViewInNavigationBar(self) else {return} + navigationBarImageView.isHidden = false } fileprivate func hairlineImageViewInNavigationBar(_ view: UIView) -> UIImageView? { diff --git a/Source/FolioReaderAddHighlightNote.swift b/Source/FolioReaderAddHighlightNote.swift index 754b8f760..519a203b1 100644 --- a/Source/FolioReaderAddHighlightNote.swift +++ b/Source/FolioReaderAddHighlightNote.swift @@ -136,21 +136,21 @@ class FolioReaderAddHighlightNote: UIViewController { let font = UIFont(name: "Avenir-Light", size: 17)! setTranslucentNavigation(false, color: navBackground, tintColor: tintColor, titleColor: navText, andFont: font) - let titleAttrs = [NSAttributedStringKey.foregroundColor: readerConfig.tintColor] + let titleAttrs = [NSAttributedString.Key.foregroundColor: readerConfig.tintColor] let saveButton = UIBarButtonItem(title: readerConfig.localizedSave, style: .plain, target: self, action: #selector(saveNote(_:))) - saveButton.setTitleTextAttributes(titleAttrs, for: UIControlState()) + saveButton.setTitleTextAttributes(titleAttrs, for: UIControl.State()) navigationItem.rightBarButtonItem = saveButton } private func configureKeyboardObserver() { - NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name:NSNotification.Name.UIKeyboardWillShow, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name:NSNotification.Name.UIKeyboardWillHide, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name:UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name:UIResponder.keyboardWillHideNotification, object: nil) } @objc private func keyboardWillShow(notification: NSNotification){ //give room at the bottom of the scroll view, so it doesn't cover up anything the user needs to tap var userInfo = notification.userInfo! - var keyboardFrame:CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue + var keyboardFrame:CGRect = (userInfo[UIResponder.keyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue keyboardFrame = self.view.convert(keyboardFrame, from: nil) var contentInset:UIEdgeInsets = self.scrollView.contentInset diff --git a/Source/FolioReaderAudioPlayer.swift b/Source/FolioReaderAudioPlayer.swift index a7b3c5bce..994e046bf 100644 --- a/Source/FolioReaderAudioPlayer.swift +++ b/Source/FolioReaderAudioPlayer.swift @@ -42,13 +42,9 @@ open class FolioReaderAudioPlayer: NSObject { // this is needed to the audio can play even when the "silent/vibrate" toggle is on let session = AVAudioSession.sharedInstance() - try? session.setCategory(AVAudioSessionCategoryPlayback) + try? session.setCategory(.playback, mode: .default) - NotificationCenter.default.addObserver(self, - selector: #selector(pause), - name: .AVAudioSessionInterruption, - object: session - ) + NotificationCenter.default.addObserver(self,selector: #selector(pause),name: AVAudioSession.interruptionNotification,object: session ) self.updateNowPlayingInfo() } @@ -411,7 +407,7 @@ open class FolioReaderAudioPlayer: NSObject { fileprivate func startPlayerTimer() { // we must add the timer in this mode in order for it to continue working even when the user is scrolling a webview playingTimer = Timer(timeInterval: 0.01, target: self, selector: #selector(playerTimerObserver), userInfo: nil, repeats: true) - RunLoop.current.add(playingTimer, forMode: RunLoopMode.commonModes) + RunLoop.current.add(playingTimer, forMode: RunLoop.Mode.common) } fileprivate func stopPlayerTimer() { diff --git a/Source/FolioReaderCenter.swift b/Source/FolioReaderCenter.swift index a50e20225..a0b01af66 100644 --- a/Source/FolioReaderCenter.swift +++ b/Source/FolioReaderCenter.swift @@ -119,8 +119,8 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl self.totalPages = book.spine.spineReferences.count // Loading indicator - let style: UIActivityIndicatorViewStyle = folioReader.isNight(.white, .gray) - loadingView = UIActivityIndicatorView(activityIndicatorStyle: style) + let style: UIActivityIndicatorView.Style = folioReader.isNight(.white, .gray) + loadingView = UIActivityIndicatorView(style: style) loadingView.hidesWhenStopped = true loadingView.startAnimating() self.view.addSubview(loadingView) @@ -153,7 +153,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl collectionView.showsVerticalScrollIndicator = false collectionView.showsHorizontalScrollIndicator = false collectionView.backgroundColor = background - collectionView.decelerationRate = UIScrollViewDecelerationRateFast + collectionView.decelerationRate = UIScrollView.DecelerationRate.fast enableScrollBetweenChapters(scrollEnabled: true) view.addSubview(collectionView) @@ -162,12 +162,12 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl } // Activity Indicator - self.activityIndicator.activityIndicatorViewStyle = .gray + self.activityIndicator.style = .gray self.activityIndicator.hidesWhenStopped = true self.activityIndicator = UIActivityIndicatorView(frame: CGRect(x: screenBounds.size.width/2, y: screenBounds.size.height/2, width: 30, height: 30)) self.activityIndicator.backgroundColor = UIColor.gray self.view.addSubview(self.activityIndicator) - self.view.bringSubview(toFront: self.activityIndicator) + self.view.bringSubviewToFront(self.activityIndicator) if #available(iOS 10.0, *) { collectionView.isPrefetchingEnabled = false @@ -595,7 +595,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl return } - self.collectionView.scrollToItem(at: IndexPath(row: self.currentPageNumber - 1, section: 0), at: UICollectionViewScrollPosition(), animated: false) + self.collectionView.scrollToItem(at: IndexPath(row: self.currentPageNumber - 1, section: 0), at: UICollectionView.ScrollPosition(), animated: false) if (self.currentPageNumber + 1) >= totalPages { UIView.animate(withDuration: duration, animations: { self.collectionView.setContentOffset(self.frameForPage(self.currentPageNumber).origin, animated: false) @@ -772,7 +772,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl return } - UIView.animate(withDuration: animated ? 0.3 : 0, delay: 0, options: UIViewAnimationOptions(), animations: { () -> Void in + UIView.animate(withDuration: animated ? 0.3 : 0, delay: 0, options: UIView.AnimationOptions(), animations: { () -> Void in self.collectionView.scrollToItem(at: indexPath, at: .direction(withConfiguration: self.readerConfig), animated: false) }) { (finished: Bool) -> Void in completion?() @@ -942,7 +942,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl contentOffsetX = 0 } - UIView.animate(withDuration: animated ? 0.3 : 0, delay: 0, options: UIViewAnimationOptions(), animations: { () -> Void in + UIView.animate(withDuration: animated ? 0.3 : 0, delay: 0, options: UIView.AnimationOptions(), animations: { () -> Void in cell.scrollPageToOffset(contentOffsetX, animated: animated) }) { (finished: Bool) -> Void in self.updateCurrentPage { @@ -1120,7 +1120,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl shareItems.insert(contentsOf: [act, "" as AnyObject], at: 0) let activityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil) - activityViewController.excludedActivityTypes = [UIActivityType.print, UIActivityType.postToVimeo] + activityViewController.excludedActivityTypes = [UIActivity.ActivityType.print, UIActivity.ActivityType.postToVimeo] // Pop style on iPad if let actv = activityViewController.popoverPresentationController { @@ -1179,7 +1179,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl shareItems.insert(contentsOf: [act, "" as AnyObject], at: 0) let activityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil) - activityViewController.excludedActivityTypes = [UIActivityType.print, UIActivityType.postToVimeo] + activityViewController.excludedActivityTypes = [UIActivity.ActivityType.print, UIActivity.ActivityType.postToVimeo] // Pop style on iPad if let actv = activityViewController.popoverPresentationController { @@ -1295,7 +1295,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl open func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { recentlyScrolledTimer = Timer(timeInterval:recentlyScrolledDelay, target: self, selector: #selector(FolioReaderCenter.clearRecentlyScrolled), userInfo: nil, repeats: false) - RunLoop.current.add(recentlyScrolledTimer, forMode: RunLoopMode.commonModes) + RunLoop.current.add(recentlyScrolledTimer, forMode: RunLoop.Mode.common) } @objc func clearRecentlyScrolled() { diff --git a/Source/FolioReaderChapterList.swift b/Source/FolioReaderChapterList.swift index bdf27ca1d..be6076d84 100755 --- a/Source/FolioReaderChapterList.swift +++ b/Source/FolioReaderChapterList.swift @@ -35,7 +35,7 @@ class FolioReaderChapterList: UITableViewController { self.delegate = delegate self.book = book - super.init(style: UITableViewStyle.plain) + super.init(style: UITableView.Style.plain) } required init?(coder aDecoder: NSCoder) { @@ -51,7 +51,7 @@ class FolioReaderChapterList: UITableViewController { self.tableView.backgroundColor = self.folioReader.isNight(self.readerConfig.nightModeMenuBackground, self.readerConfig.menuBackgroundColor) self.tableView.separatorColor = self.folioReader.isNight(self.readerConfig.nightModeSeparatorColor, self.readerConfig.menuSeparatorColor) - self.tableView.rowHeight = UITableViewAutomaticDimension + self.tableView.rowHeight = UITableView.automaticDimension self.tableView.estimatedRowHeight = 50 // Create TOC list diff --git a/Source/FolioReaderChapterListCell.swift b/Source/FolioReaderChapterListCell.swift index 75f2f7f87..733d9ee57 100755 --- a/Source/FolioReaderChapterListCell.swift +++ b/Source/FolioReaderChapterListCell.swift @@ -11,7 +11,7 @@ import UIKit class FolioReaderChapterListCell: UITableViewCell { var indexLabel: UILabel? - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) self.indexLabel = UILabel() diff --git a/Source/FolioReaderConfig.swift b/Source/FolioReaderConfig.swift index 033772f3e..1f35ed71e 100755 --- a/Source/FolioReaderConfig.swift +++ b/Source/FolioReaderConfig.swift @@ -27,7 +27,7 @@ public enum FolioReaderScrollDirection: Int { /// The current scroll direction /// /// - Returns: Returns `UICollectionViewScrollDirection` - func collectionViewScrollDirection() -> UICollectionViewScrollDirection { + func collectionViewScrollDirection() -> UICollectionView.ScrollDirection { switch self { case .vertical, .defaultVertical: return .vertical diff --git a/Source/FolioReaderContainer.swift b/Source/FolioReaderContainer.swift index 76277aa42..66dc08b10 100755 --- a/Source/FolioReaderContainer.swift +++ b/Source/FolioReaderContainer.swift @@ -138,9 +138,9 @@ open class FolioReaderContainer: UIViewController { self.centerNavigationController?.setNavigationBarHidden(self.readerConfig.shouldHideNavigationOnTap, animated: false) if let _centerNavigationController = self.centerNavigationController { self.view.addSubview(_centerNavigationController.view) - self.addChildViewController(_centerNavigationController) + self.addChild(_centerNavigationController) } - self.centerNavigationController?.didMove(toParentViewController: self) + self.centerNavigationController?.didMove(toParent: self) if (self.readerConfig.hideBars == true) { self.readerConfig.shouldHideNavigationOnTap = false @@ -215,9 +215,9 @@ extension FolioReaderContainer { let alertController = UIAlertController( title: "Error", message: message, - preferredStyle: UIAlertControllerStyle.alert + preferredStyle: UIAlertController.Style.alert ) - let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.cancel) { [weak self] + let action = UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel) { [weak self] (result : UIAlertAction) -> Void in self?.dismiss() } diff --git a/Source/FolioReaderFontsMenu.swift b/Source/FolioReaderFontsMenu.swift index aec858504..e87a6b392 100644 --- a/Source/FolioReaderFontsMenu.swift +++ b/Source/FolioReaderFontsMenu.swift @@ -198,7 +198,7 @@ class FolioReaderFontsMenu: UIViewController, SMSegmentViewDelegate, UIGestureRe slider.tintColor = self.readerConfig.nightModeSeparatorColor slider.minimumValue = 0 slider.value = CGFloat(self.folioReader.currentFontSize.rawValue) - slider.addTarget(self, action: #selector(FolioReaderFontsMenu.sliderValueChanged(_:)), for: UIControlEvents.valueChanged) + slider.addTarget(self, action: #selector(FolioReaderFontsMenu.sliderValueChanged(_:)), for: UIControl.Event.valueChanged) // Force remove fill color slider.layer.sublayers?.forEach({ layer in @@ -210,12 +210,12 @@ class FolioReaderFontsMenu: UIViewController, SMSegmentViewDelegate, UIGestureRe // Font icons let fontSmallView = UIImageView(frame: CGRect(x: 20, y: line2.frame.origin.y+14, width: 30, height: 30)) fontSmallView.image = fontSmallNormal - fontSmallView.contentMode = UIViewContentMode.center + fontSmallView.contentMode = UIView.ContentMode.center menuView.addSubview(fontSmallView) let fontBigView = UIImageView(frame: CGRect(x: view.frame.width-50, y: line2.frame.origin.y+14, width: 30, height: 30)) fontBigView.image = fontBigNormal - fontBigView.contentMode = UIViewContentMode.center + fontBigView.contentMode = UIView.ContentMode.center menuView.addSubview(fontBigView) // Only continues if user can change scroll direction diff --git a/Source/FolioReaderHighlightList.swift b/Source/FolioReaderHighlightList.swift index 3ba7763fe..593c167d0 100644 --- a/Source/FolioReaderHighlightList.swift +++ b/Source/FolioReaderHighlightList.swift @@ -18,7 +18,7 @@ class FolioReaderHighlightList: UITableViewController { self.readerConfig = readerConfig self.folioReader = folioReader - super.init(style: UITableViewStyle.plain) + super.init(style: UITableView.Style.plain) } required init?(coder aDecoder: NSCoder) { @@ -67,7 +67,7 @@ class FolioReaderHighlightList: UITableViewController { if cell.contentView.viewWithTag(456) == nil { dateLabel = UILabel(frame: CGRect(x: 0, y: 0, width: view.frame.width-40, height: 16)) dateLabel.tag = 456 - dateLabel.autoresizingMask = UIViewAutoresizing.flexibleWidth + dateLabel.autoresizingMask = UIView.AutoresizingMask.flexibleWidth dateLabel.font = UIFont(name: "Avenir-Medium", size: 12) cell.contentView.addSubview(dateLabel) } else { @@ -86,16 +86,16 @@ class FolioReaderHighlightList: UITableViewController { paragraph.lineSpacing = 3 let textColor = self.folioReader.isNight(self.readerConfig.menuTextColor, UIColor.black) - text.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraph, range: range) - text.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "Avenir-Light", size: 16)!, range: range) - text.addAttribute(NSAttributedStringKey.foregroundColor, value: textColor, range: range) + text.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraph, range: range) + text.addAttribute(NSAttributedString.Key.font, value: UIFont(name: "Avenir-Light", size: 16)!, range: range) + text.addAttribute(NSAttributedString.Key.foregroundColor, value: textColor, range: range) if (highlight.type == HighlightStyle.underline.rawValue) { - text.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.clear, range: range) - text.addAttribute(NSAttributedStringKey.underlineColor, value: HighlightStyle.colorForStyle(highlight.type, nightMode: self.folioReader.nightMode), range: range) - text.addAttribute(NSAttributedStringKey.underlineStyle, value: NSNumber(value: NSUnderlineStyle.styleSingle.rawValue as Int), range: range) + text.addAttribute(NSAttributedString.Key.backgroundColor, value: UIColor.clear, range: range) + text.addAttribute(NSAttributedString.Key.underlineColor, value: HighlightStyle.colorForStyle(highlight.type, nightMode: self.folioReader.nightMode), range: range) + text.addAttribute(NSAttributedString.Key.underlineStyle, value: NSNumber(value: NSUnderlineStyle.single.rawValue as Int), range: range) } else { - text.addAttribute(NSAttributedStringKey.backgroundColor, value: HighlightStyle.colorForStyle(highlight.type, nightMode: self.folioReader.nightMode), range: range) + text.addAttribute(NSAttributedString.Key.backgroundColor, value: HighlightStyle.colorForStyle(highlight.type, nightMode: self.folioReader.nightMode), range: range) } // Text @@ -103,7 +103,7 @@ class FolioReaderHighlightList: UITableViewController { if cell.contentView.viewWithTag(123) == nil { highlightLabel = UILabel(frame: CGRect(x: 0, y: 0, width: view.frame.width-40, height: 0)) highlightLabel.tag = 123 - highlightLabel.autoresizingMask = UIViewAutoresizing.flexibleWidth + highlightLabel.autoresizingMask = UIView.AutoresizingMask.flexibleWidth highlightLabel.numberOfLines = 0 highlightLabel.textColor = UIColor.black cell.contentView.addSubview(highlightLabel) @@ -122,7 +122,7 @@ class FolioReaderHighlightList: UITableViewController { noteLabel = UILabel(frame: CGRect(x: 0, y: 0, width: view.frame.width-40, height: 0)) noteLabel.tag = 789 noteLabel.font = UIFont.systemFont(ofSize: 14) - noteLabel.autoresizingMask = UIViewAutoresizing.flexibleWidth + noteLabel.autoresizingMask = UIView.AutoresizingMask.flexibleWidth noteLabel.numberOfLines = 3 noteLabel.textColor = UIColor.gray cell.contentView.addSubview(noteLabel) @@ -151,8 +151,8 @@ class FolioReaderHighlightList: UITableViewController { let range = NSRange(location: 0, length: text.length) let paragraph = NSMutableParagraphStyle() paragraph.lineSpacing = 3 - text.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraph, range: range) - text.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "Avenir-Light", size: 16)!, range: range) + text.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraph, range: range) + text.addAttribute(NSAttributedString.Key.font, value: UIFont(name: "Avenir-Light", size: 16)!, range: range) let s = text.boundingRect(with: CGSize(width: view.frame.width-40, height: CGFloat.greatestFiniteMagnitude), options: [NSStringDrawingOptions.usesLineFragmentOrigin, NSStringDrawingOptions.usesFontLeading], @@ -184,7 +184,7 @@ class FolioReaderHighlightList: UITableViewController { self.dismiss() } - override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { guard let highlight = highlights[safe: indexPath.row] else { return } diff --git a/Source/FolioReaderKit.swift b/Source/FolioReaderKit.swift index da13130a4..96914b6ef 100755 --- a/Source/FolioReaderKit.swift +++ b/Source/FolioReaderKit.swift @@ -136,14 +136,14 @@ open class FolioReader: NSObject { // Add necessary observers fileprivate func addObservers() { removeObservers() - NotificationCenter.default.addObserver(self, selector: #selector(saveReaderState), name: .UIApplicationWillResignActive, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(saveReaderState), name: .UIApplicationWillTerminate, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(saveReaderState), name: UIApplication.willResignActiveNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(saveReaderState), name: UIApplication.willTerminateNotification, object: nil) } /// Remove necessary observers fileprivate func removeObservers() { - NotificationCenter.default.removeObserver(self, name: .UIApplicationWillResignActive, object: nil) - NotificationCenter.default.removeObserver(self, name: .UIApplicationWillTerminate, object: nil) + NotificationCenter.default.removeObserver(self, name: UIApplication.willResignActiveNotification, object: nil) + NotificationCenter.default.removeObserver(self, name: UIApplication.willTerminateNotification, object: nil) } } diff --git a/Source/FolioReaderPage.swift b/Source/FolioReaderPage.swift index fa09427ff..34cc111f6 100755 --- a/Source/FolioReaderPage.swift +++ b/Source/FolioReaderPage.swift @@ -226,7 +226,7 @@ open class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGestureRe delegate?.pageDidLoad?(self) } - open func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { + open func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool { guard let webView = webView as? FolioReaderWebView, let scheme = request.url?.scheme else { @@ -240,7 +240,7 @@ open class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGestureRe guard let decoded = url.absoluteString.removingPercentEncoding else { return false } let index = decoded.index(decoded.startIndex, offsetBy: 12) - let rect = CGRectFromString(String(decoded[index...])) + let rect = NSCoder.cgRect(for: String(decoded[index...])) webView.createMenu(options: true) webView.setMenuVisible(true, andRect: rect) diff --git a/Source/FolioReaderPageIndicator.swift b/Source/FolioReaderPageIndicator.swift index 1e244bd96..fc1960556 100644 --- a/Source/FolioReaderPageIndicator.swift +++ b/Source/FolioReaderPageIndicator.swift @@ -75,11 +75,11 @@ class FolioReaderPageIndicator: UIView { let currentColor = UIColor(cgColor: layer.shadowColor!) animation.fromValue = currentColor.cgColor animation.toValue = color.cgColor - animation.fillMode = kCAFillModeForwards + animation.fillMode = CAMediaTimingFillMode.forwards animation.isRemovedOnCompletion = false animation.duration = 0.6 animation.delegate = self - animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) layer.add(animation, forKey: "shadowColor") minutesLabel.textColor = self.folioReader.isNight(UIColor(white: 1, alpha: 0.3), UIColor(white: 0, alpha: 0.6)) diff --git a/Source/FolioReaderPlayerMenu.swift b/Source/FolioReaderPlayerMenu.swift index af0c6bd74..8b2d24434 100644 --- a/Source/FolioReaderPlayerMenu.swift +++ b/Source/FolioReaderPlayerMenu.swift @@ -78,16 +78,16 @@ class FolioReaderPlayerMenu: UIViewController, SMSegmentViewDelegate, UIGestureR // prev button let prevBtn = UIButton(frame: CGRect(x: gutterX + padX, y: 0, width: size, height: size)) - prevBtn.setImage(prevNormal, for: UIControlState()) + prevBtn.setImage(prevNormal, for: UIControl.State()) prevBtn.setImage(prevSelected, for: .selected) prevBtn.addTarget(self, action: #selector(FolioReaderPlayerMenu.prevChapter(_:)), for: .touchUpInside) menuView.addSubview(prevBtn) // play / pause button let playPauseBtn = UIButton(frame: CGRect(x: Int(prevBtn.frame.origin.x) + padX + size, y: 0, width: size, height: size)) - playPauseBtn.setTitleColor(selectedColor, for: UIControlState()) + playPauseBtn.setTitleColor(selectedColor, for: UIControl.State()) playPauseBtn.setTitleColor(selectedColor, for: .selected) - playPauseBtn.setImage(playSelected, for: UIControlState()) + playPauseBtn.setImage(playSelected, for: UIControl.State()) playPauseBtn.setImage(pauseSelected, for: .selected) playPauseBtn.titleLabel!.font = UIFont(name: "Avenir", size: 22)! playPauseBtn.addTarget(self, action: #selector(FolioReaderPlayerMenu.togglePlay(_:)), for: .touchUpInside) @@ -99,7 +99,7 @@ class FolioReaderPlayerMenu: UIViewController, SMSegmentViewDelegate, UIGestureR // next button let nextBtn = UIButton(frame: CGRect(x: Int(playPauseBtn.frame.origin.x) + padX + size, y: 0, width: size, height: size)) - nextBtn.setImage(nextNormal, for: UIControlState()) + nextBtn.setImage(nextNormal, for: UIControl.State()) nextBtn.setImage(nextSelected, for: .selected) nextBtn.addTarget(self, action: #selector(FolioReaderPlayerMenu.nextChapter(_:)), for: .touchUpInside) menuView.addSubview(nextBtn) @@ -142,9 +142,9 @@ class FolioReaderPlayerMenu: UIViewController, SMSegmentViewDelegate, UIGestureR let style0 = UIButton(frame: CGRect(x: 0, y: line2.frame.height+line2.frame.origin.y, width: view.frame.width/3, height: 55)) style0.titleLabel!.textAlignment = .center style0.titleLabel!.font = UIFont(name: "Avenir-Light", size: 17) - style0.setTitleColor(self.folioReader.isNight(self.readerConfig.nightModeMenuBackground, UIColor.white), for: UIControlState()) + style0.setTitleColor(self.folioReader.isNight(self.readerConfig.nightModeMenuBackground, UIColor.white), for: UIControl.State()) style0.setTitleColor(self.folioReader.isNight(self.readerConfig.nightModeMenuBackground, UIColor.white), for: .selected) - style0.setTitle(self.readerConfig.localizedPlayerMenuStyle, for: UIControlState()) + style0.setTitle(self.readerConfig.localizedPlayerMenuStyle, for: UIControl.State()) menuView.addSubview(style0); style0.titleLabel?.sizeToFit() let style0Bgd = UIView(frame: style0.titleLabel!.frame) @@ -159,25 +159,25 @@ class FolioReaderPlayerMenu: UIViewController, SMSegmentViewDelegate, UIGestureR let style1 = UIButton(frame: CGRect(x: view.frame.width/3, y: line2.frame.height+line2.frame.origin.y, width: view.frame.width/3, height: 55)) style1.titleLabel!.textAlignment = .center style1.titleLabel!.font = UIFont(name: "Avenir-Light", size: 17) - style1.setTitleColor(normalColor, for: UIControlState()) + style1.setTitleColor(normalColor, for: UIControl.State()) style1.setAttributedTitle(NSAttributedString(string: "Style", attributes: [ - NSAttributedStringKey.foregroundColor: normalColor, - NSAttributedStringKey.underlineStyle: NSUnderlineStyle.patternDot.rawValue|NSUnderlineStyle.styleSingle.rawValue, - NSAttributedStringKey.underlineColor: normalColor - ]), for: UIControlState()) + NSAttributedString.Key.foregroundColor: normalColor, + NSAttributedString.Key.underlineStyle: NSUnderlineStyle.patternDot.rawValue|NSUnderlineStyle.single.rawValue, + NSAttributedString.Key.underlineColor: normalColor + ]), for: UIControl.State()) style1.setAttributedTitle(NSAttributedString(string: self.readerConfig.localizedPlayerMenuStyle, attributes: [ - NSAttributedStringKey.foregroundColor: self.folioReader.isNight(UIColor.white, UIColor.black), - NSAttributedStringKey.underlineStyle: NSUnderlineStyle.patternDot.rawValue|NSUnderlineStyle.styleSingle.rawValue, - NSAttributedStringKey.underlineColor: selectedColor + NSAttributedString.Key.foregroundColor: self.folioReader.isNight(UIColor.white, UIColor.black), + NSAttributedString.Key.underlineStyle: NSUnderlineStyle.patternDot.rawValue|NSUnderlineStyle.single.rawValue, + NSAttributedString.Key.underlineColor: selectedColor ]), for: .selected) menuView.addSubview(style1); let style2 = UIButton(frame: CGRect(x: view.frame.width/1.5, y: line2.frame.height+line2.frame.origin.y, width: view.frame.width/3, height: 55)) style2.titleLabel!.textAlignment = .center style2.titleLabel!.font = UIFont(name: "Avenir-Light", size: 17) - style2.setTitleColor(normalColor, for: UIControlState()) + style2.setTitleColor(normalColor, for: UIControl.State()) style2.setTitleColor(selectedColor, for: .selected) - style2.setTitle(self.readerConfig.localizedPlayerMenuStyle, for: UIControlState()) + style2.setTitle(self.readerConfig.localizedPlayerMenuStyle, for: UIControl.State()) menuView.addSubview(style2); // add line dividers between style buttons diff --git a/Source/FolioReaderQuoteShare.swift b/Source/FolioReaderQuoteShare.swift index f93842a84..16e35874f 100644 --- a/Source/FolioReaderQuoteShare.swift +++ b/Source/FolioReaderQuoteShare.swift @@ -53,9 +53,9 @@ class FolioReaderQuoteShare: UIViewController { self.setCloseButton(withConfiguration: self.readerConfig) configureNavBar() - let titleAttrs = [NSAttributedStringKey.foregroundColor: self.readerConfig.tintColor] + let titleAttrs = [NSAttributedString.Key.foregroundColor: self.readerConfig.tintColor] let share = UIBarButtonItem(title: self.readerConfig.localizedShare, style: .plain, target: self, action: #selector(shareQuote(_:))) - share.setTitleTextAttributes(titleAttrs, for: UIControlState()) + share.setTitleTextAttributes(titleAttrs, for: UIControl.State()) navigationItem.rightBarButtonItem = share let isPad = (UIDevice.current.userInterfaceIdiom == .pad) @@ -108,10 +108,10 @@ class FolioReaderQuoteShare: UIViewController { filterImage.addSubview(titleLabel) // Attributed author - let attrs = [NSAttributedStringKey.font: UIFont(name: "Lato-Italic", size: 15)!] + let attrs = [NSAttributedString.Key.font: UIFont(name: "Lato-Italic", size: 15)!] let attributedString = NSMutableAttributedString(string:"\(self.readerConfig.localizedShareBy) ", attributes: attrs) - let attrs1 = [NSAttributedStringKey.font: UIFont(name: "Lato-Regular", size: 15)!] + let attrs1 = [NSAttributedString.Key.font: UIFont(name: "Lato-Regular", size: 15)!] let boldString = NSMutableAttributedString(string: authorName, attributes:attrs1) attributedString.append(boldString) @@ -168,7 +168,7 @@ class FolioReaderQuoteShare: UIViewController { collectionView.dataSource = self collectionView.showsHorizontalScrollIndicator = false collectionView.backgroundColor = background - collectionView.decelerationRate = UIScrollViewDecelerationRateFast + collectionView.decelerationRate = UIScrollView.DecelerationRate.fast view.addSubview(collectionView) if (UIDevice.current.userInterfaceIdiom == .phone) { @@ -285,7 +285,7 @@ class FolioReaderQuoteShare: UIViewController { shareItems.insert(act, at: 0) let activityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil) - activityViewController.excludedActivityTypes = [UIActivityType.print, UIActivityType.postToVimeo] + activityViewController.excludedActivityTypes = [UIActivity.ActivityType.print, UIActivity.ActivityType.postToVimeo] // Pop style on iPad if let actv = activityViewController.popoverPresentationController { @@ -408,8 +408,12 @@ extension FolioReaderQuoteShare: UICollectionViewDelegate { // MARK: ImagePicker delegate extension FolioReaderQuoteShare: UIImagePickerControllerDelegate, UINavigationControllerDelegate { - func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { - if let image = info[UIImagePickerControllerEditedImage] as? UIImage { + + //func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]){ + //if let image = info[UIImagePickerControllerEditedImage] as? UIImage { + if let image = info[UIImagePickerController.InfoKey.editedImage] as? UIImage { let quoteImage = QuoteImage(withImage: image, alpha: 0.6, backgroundColor: UIColor.black) diff --git a/Source/FolioReaderSharingProvider.swift b/Source/FolioReaderSharingProvider.swift index 307bbf5db..da0fdbefe 100644 --- a/Source/FolioReaderSharingProvider.swift +++ b/Source/FolioReaderSharingProvider.swift @@ -23,16 +23,16 @@ class FolioReaderSharingProvider: UIActivityItemProvider { super.init(placeholderItem: "") } - override func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivityType?) -> String { + override func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivity.ActivityType?) -> String { return subject } - override func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivityType?) -> Any? { - if let html = html , activityType == UIActivityType.mail { + override func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? { + if let html = html , activityType == UIActivity.ActivityType.mail { return html } - if let image = image , activityType == UIActivityType.postToFacebook { + if let image = image , activityType == UIActivity.ActivityType.postToFacebook { return image } diff --git a/Source/FolioReaderWebView.swift b/Source/FolioReaderWebView.swift index 9711c6460..68803cdb6 100644 --- a/Source/FolioReaderWebView.swift +++ b/Source/FolioReaderWebView.swift @@ -137,7 +137,7 @@ open class FolioReaderWebView: UIWebView { do { let json = try JSONSerialization.jsonObject(with: jsonData!, options: []) as! NSArray let dic = json.firstObject as! [String: String] - let rect = CGRectFromString(dic["rect"]!) + let rect = NSCoder.cgRect(for: dic["rect"]!) guard let startOffset = dic["startOffset"] else { return } @@ -173,7 +173,7 @@ open class FolioReaderWebView: UIWebView { do { let json = try JSONSerialization.jsonObject(with: jsonData!, options: []) as! NSArray let dic = json.firstObject as! [String: String] - let rect = CGRectFromString(dic["rect"]!) + let rect = NSCoder.cgRect(for: dic["rect"]!) guard let startOffset = dic["startOffset"] else { return } guard let endOffset = dic["endOffset"] else { return } diff --git a/Source/PageViewController.swift b/Source/PageViewController.swift index fcfaf6383..b445ea22c 100644 --- a/Source/PageViewController.swift +++ b/Source/PageViewController.swift @@ -39,7 +39,7 @@ class PageViewController: UIPageViewController { super.viewDidLoad() segmentedControl = UISegmentedControl(items: segmentedControlItems) - segmentedControl.addTarget(self, action: #selector(PageViewController.didSwitchMenu(_:)), for: UIControlEvents.valueChanged) + segmentedControl.addTarget(self, action: #selector(PageViewController.didSwitchMenu(_:)), for: UIControl.Event.valueChanged) segmentedControl.selectedSegmentIndex = index segmentedControl.setWidth(100, forSegmentAt: 0) segmentedControl.setWidth(100, forSegmentAt: 1) @@ -47,8 +47,8 @@ class PageViewController: UIPageViewController { viewList = [viewControllerOne, viewControllerTwo] - viewControllerOne.didMove(toParentViewController: self) - viewControllerTwo.didMove(toParentViewController: self) + viewControllerOne.didMove(toParent: self) + viewControllerTwo.didMove(toParent: self) self.delegate = self self.dataSource = self @@ -84,7 +84,7 @@ class PageViewController: UIPageViewController { @objc func didSwitchMenu(_ sender: UISegmentedControl) { self.index = sender.selectedSegmentIndex - let direction: UIPageViewControllerNavigationDirection = (index == 0 ? .reverse : .forward) + let direction: UIPageViewController.NavigationDirection = (index == 0 ? .reverse : .forward) setViewControllers([viewList[index]], direction: direction, animated: true, completion: nil) self.folioReader.currentMenuIndex = index } diff --git a/Source/ScrollScrubber.swift b/Source/ScrollScrubber.swift index 7f73b4297..10487d5c3 100644 --- a/Source/ScrollScrubber.swift +++ b/Source/ScrollScrubber.swift @@ -93,7 +93,7 @@ class ScrollScrubber: NSObject, UIScrollViewDelegate { // less obtrusive knob and fixes jump: http://stackoverflow.com/a/22301039/484780 let thumbImg = UIImage(readerImageNamed: "knob") let thumbImgColor = thumbImg?.imageTintColor(readerConfig.tintColor)?.withRenderingMode(.alwaysOriginal) - slider.setThumbImage(thumbImgColor, for: UIControlState()) + slider.setThumbImage(thumbImgColor, for: UIControl.State()) slider.setThumbImage(thumbImgColor, for: .selected) slider.setThumbImage(thumbImgColor, for: .highlighted) @@ -221,7 +221,7 @@ class ScrollScrubber: NSObject, UIScrollViewDelegate { func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { scrollDeltaTimer = Timer(timeInterval:0.5, target: self, selector: #selector(ScrollScrubber.resetScrollDelta), userInfo: nil, repeats: false) - RunLoop.current.add(scrollDeltaTimer, forMode: RunLoopMode.commonModes) + RunLoop.current.add(scrollDeltaTimer, forMode: RunLoop.Mode.common) } @objc func resetScrollDelta() { diff --git a/Vendor/HAControls/HADiscreteSlider.swift b/Vendor/HAControls/HADiscreteSlider.swift index 8c65c5b78..5f93eff20 100644 --- a/Vendor/HAControls/HADiscreteSlider.swift +++ b/Vendor/HAControls/HADiscreteSlider.swift @@ -160,7 +160,7 @@ class HADiscreteSlider : UIControl { } func sendActionsForControlEvents() { - self.sendActions(for: UIControlEvents.valueChanged) + self.sendActions(for: UIControl.Event.valueChanged) } // MARK: HADiscreteSlider diff --git a/Vendor/SMSegmentView/SMSegment.swift b/Vendor/SMSegmentView/SMSegment.swift index e153581da..1fd67d456 100755 --- a/Vendor/SMSegmentView/SMSegment.swift +++ b/Vendor/SMSegmentView/SMSegment.swift @@ -58,7 +58,7 @@ class SMSegment: UIView { self.label.text = self.title if let titleText = self.label.text as NSString? { - self.labelWidth = titleText.boundingRect(with: CGSize(width: self.frame.size.width, height: self.frame.size.height), options:NSStringDrawingOptions.usesLineFragmentOrigin , attributes: [NSAttributedStringKey.font: self.label.font], context: nil).size.width + self.labelWidth = titleText.boundingRect(with: CGSize(width: self.frame.size.width, height: self.frame.size.height), options:NSStringDrawingOptions.usesLineFragmentOrigin , attributes: [NSAttributedString.Key.font: self.label.font], context: nil).size.width } else { self.labelWidth = 0.0 @@ -86,7 +86,7 @@ class SMSegment: UIView { self.label.font = self.titleFont if let titleText = self.label.text as NSString? { - self.labelWidth = titleText.boundingRect(with: CGSize(width: self.frame.size.width + 1.0, height: self.frame.size.height), options:NSStringDrawingOptions.usesLineFragmentOrigin , attributes: [NSAttributedStringKey.font: self.label.font], context: nil).size.width + self.labelWidth = titleText.boundingRect(with: CGSize(width: self.frame.size.width + 1.0, height: self.frame.size.height), options:NSStringDrawingOptions.usesLineFragmentOrigin , attributes: [NSAttributedString.Key.font: self.label.font], context: nil).size.width } else { self.labelWidth = 0.0 @@ -152,7 +152,7 @@ class SMSegment: UIView { self.backgroundColor = self.offSelectionColour - self.imageView.contentMode = UIViewContentMode.scaleAspectFit + self.imageView.contentMode = UIView.ContentMode.scaleAspectFit self.addSubview(self.imageView) self.label.textAlignment = NSTextAlignment.center