Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Fixed all migration warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hebertialmeida committed Feb 12, 2018
1 parent 2036fbf commit fe3f81a
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 57 deletions.
10 changes: 4 additions & 6 deletions FolioReaderKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
objects = {

/* Begin PBXBuildFile section */
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 */; };
1A65DDD31DA744190033C277 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A65DDD11DA744190033C277 /* RealmSwift.framework */; };
1A65DDD51DA744410033C277 /* QuoteImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A65DDD41DA744410033C277 /* QuoteImage.swift */; };
1A65DDD71DA7450A0033C277 /* FolioReaderQuoteShare.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A65DDD61DA7450A0033C277 /* FolioReaderQuoteShare.swift */; };
1A958F911D397BE900D56699 /* FRBook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F051D397BE900D56699 /* FRBook.swift */; };
1A958F921D397BE900D56699 /* FREpubParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F061D397BE900D56699 /* FREpubParser.swift */; };
1A958F931D397BE900D56699 /* FRMediaType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F071D397BE900D56699 /* FRMediaType.swift */; };
1A958F941D397BE900D56699 /* FRMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F081D397BE900D56699 /* FRMetadata.swift */; };
1A958F951D397BE900D56699 /* FRResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F091D397BE900D56699 /* FRResource.swift */; };
1A958F961D397BE900D56699 /* FRResources.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F0A1D397BE900D56699 /* FRResources.swift */; };
Expand Down Expand Up @@ -64,7 +64,6 @@
3A27F08E1FD9BE5800D84A57 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27F08B1FD9BE5800D84A57 /* Extensions.swift */; };
3A27F09D1FD9C24A00D84A57 /* FRBook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F051D397BE900D56699 /* FRBook.swift */; };
3A27F09E1FD9C24A00D84A57 /* FREpubParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F061D397BE900D56699 /* FREpubParser.swift */; };
3A27F09F1FD9C24A00D84A57 /* FRMediaType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F071D397BE900D56699 /* FRMediaType.swift */; };
3A27F0A01FD9C24A00D84A57 /* FRMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F081D397BE900D56699 /* FRMetadata.swift */; };
3A27F0A11FD9C24A00D84A57 /* FRResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F091D397BE900D56699 /* FRResource.swift */; };
3A27F0A21FD9C24A00D84A57 /* FRResources.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F0A1D397BE900D56699 /* FRResources.swift */; };
Expand Down Expand Up @@ -121,14 +120,14 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1A41E8902031E22300A8F70C /* MediaType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaType.swift; sourceTree = "<group>"; };
1A65DDCB1DA73F8D0033C277 /* MenuItemKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MenuItemKit.framework; path = Carthage/Build/iOS/MenuItemKit.framework; sourceTree = "<group>"; };
1A65DDD01DA744190033C277 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = Carthage/Build/iOS/Realm.framework; sourceTree = "<group>"; };
1A65DDD11DA744190033C277 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = Carthage/Build/iOS/RealmSwift.framework; sourceTree = "<group>"; };
1A65DDD41DA744410033C277 /* QuoteImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuoteImage.swift; sourceTree = "<group>"; };
1A65DDD61DA7450A0033C277 /* FolioReaderQuoteShare.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FolioReaderQuoteShare.swift; sourceTree = "<group>"; };
1A958F051D397BE900D56699 /* FRBook.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FRBook.swift; sourceTree = "<group>"; };
1A958F061D397BE900D56699 /* FREpubParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FREpubParser.swift; sourceTree = "<group>"; };
1A958F071D397BE900D56699 /* FRMediaType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FRMediaType.swift; sourceTree = "<group>"; };
1A958F081D397BE900D56699 /* FRMetadata.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FRMetadata.swift; sourceTree = "<group>"; };
1A958F091D397BE900D56699 /* FRResource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FRResource.swift; sourceTree = "<group>"; };
1A958F0A1D397BE900D56699 /* FRResources.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FRResources.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -266,9 +265,9 @@
1A958F041D397BE900D56699 /* EPUBCore */ = {
isa = PBXGroup;
children = (
1A41E8902031E22300A8F70C /* MediaType.swift */,
1A958F051D397BE900D56699 /* FRBook.swift */,
1A958F061D397BE900D56699 /* FREpubParser.swift */,
1A958F071D397BE900D56699 /* FRMediaType.swift */,
1A958F081D397BE900D56699 /* FRMetadata.swift */,
1A958F091D397BE900D56699 /* FRResource.swift */,
1A958F0A1D397BE900D56699 /* FRResources.swift */,
Expand Down Expand Up @@ -587,6 +586,7 @@
1A958FAD1D397BE900D56699 /* Highlight.swift in Sources */,
1A958F981D397BE900D56699 /* FRSmils.swift in Sources */,
1A958F971D397BE900D56699 /* FRSmilElement.swift in Sources */,
1A41E8912031E22300A8F70C /* MediaType.swift in Sources */,
3A27F08E1FD9BE5800D84A57 /* Extensions.swift in Sources */,
1A958F9D1D397BE900D56699 /* FolioReaderChapterList.swift in Sources */,
1A958F951D397BE900D56699 /* FRResource.swift in Sources */,
Expand All @@ -595,7 +595,6 @@
1A958F9A1D397BE900D56699 /* FRTocReference.swift in Sources */,
1A958F911D397BE900D56699 /* FRBook.swift in Sources */,
1A958F941D397BE900D56699 /* FRMetadata.swift in Sources */,
1A958F931D397BE900D56699 /* FRMediaType.swift in Sources */,
1A9590131D397BE900D56699 /* ScrollScrubber.swift in Sources */,
B0D69CC81D0387F7003B4CCD /* HADiscreteSlider.swift in Sources */,
1A65DDD51DA744410033C277 /* QuoteImage.swift in Sources */,
Expand Down Expand Up @@ -625,7 +624,6 @@
3A27F0A01FD9C24A00D84A57 /* FRMetadata.swift in Sources */,
3A27F0B21FD9C25500D84A57 /* FolioReaderChapterList.swift in Sources */,
3A27F0B41FD9C25500D84A57 /* FolioReaderConfig.swift in Sources */,
3A27F09F1FD9C24A00D84A57 /* FRMediaType.swift in Sources */,
3A27F0B61FD9C25500D84A57 /* FolioReaderFontsMenu.swift in Sources */,
3A27F0AF1FD9C25500D84A57 /* Extensions.swift in Sources */,
3A27F0C81FD9C33A00D84A57 /* Highlight.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions Source/EPUBCore/FREpubParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class FREpubParser: NSObject, SSZipArchiveDelegate {
}

guard let reference = navpointElement["content"].attributes["src"] else { return nil }
let hrefSplit = reference.characters.split {$0 == "#"}.map { String($0) }
let hrefSplit = reference.split {$0 == "#"}.map { String($0) }
let fragmentID = hrefSplit.count > 1 ? hrefSplit[1] : ""
let href = hrefSplit[0]

Expand All @@ -340,7 +340,7 @@ class FREpubParser: NSObject, SSZipArchiveDelegate {
}

guard let reference = navpointElement["a"].attributes["href"] else { return nil }
let hrefSplit = reference.characters.split {$0 == "#"}.map { String($0) }
let hrefSplit = reference.split {$0 == "#"}.map { String($0) }
let fragmentID = hrefSplit.count > 1 ? hrefSplit[1] : ""
let href = hrefSplit[0]

Expand Down
11 changes: 6 additions & 5 deletions Source/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ internal extension UIColor {
var alpha: CGFloat = 1.0

if rgba.hasPrefix("#") {
let index = rgba.characters.index(rgba.startIndex, offsetBy: 1)
let hex = rgba.substring(from: index)
let index = rgba.index(rgba.startIndex, offsetBy: 1)
let hex = String(rgba[index...])
let scanner = Scanner(string: hex)
var hexValue: CUnsignedLongLong = 0
if scanner.scanHexInt64(&hexValue) {
switch (hex.characters.count) {
switch (hex.count) {
case 3:
red = CGFloat((hexValue & 0xF00) >> 8) / 15.0
green = CGFloat((hexValue & 0x0F0) >> 4) / 15.0
Expand Down Expand Up @@ -284,8 +284,9 @@ internal extension String {
/// Truncates the string to length number of characters and
/// appends optional trailing string if longer
func truncate(_ length: Int, trailing: String? = nil) -> String {
if self.characters.count > length {
return self.substring(to: self.characters.index(self.startIndex, offsetBy: length)) + (trailing ?? "")
if count > length {
let indexOfText = index(startIndex, offsetBy: length)
return String(self[..<indexOfText])
} else {
return self
}
Expand Down
20 changes: 6 additions & 14 deletions Source/FolioReaderCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,16 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl

func reloadData() {
self.loadingView.stopAnimating()
self.totalPages = (self.book.spine.spineReferences.count ?? 0)
self.totalPages = book.spine.spineReferences.count

self.collectionView.reloadData()
self.configureNavBarButtons()
self.setCollectionViewProgressiveDirection()

if self.readerConfig.loadSavedPositionForCurrentBook {
guard
let bookId = self.book.name,
let position = folioReader.savedPositionForCurrentBook as? NSDictionary,
let pageNumber = position["pageNumber"] as? Int,
(pageNumber > 0) else {
self.currentPageNumber = 1
return
guard let position = folioReader.savedPositionForCurrentBook, let pageNumber = position["pageNumber"] as? Int, pageNumber > 0 else {
self.currentPageNumber = 1
return
}

self.changePageWith(page: pageNumber)
Expand Down Expand Up @@ -437,7 +433,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl
}

open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
var reuseableCell = collectionView.dequeueReusableCell(withReuseIdentifier: kReuseCellIdentifier, for: indexPath) as? FolioReaderPage
let reuseableCell = collectionView.dequeueReusableCell(withReuseIdentifier: kReuseCellIdentifier, for: indexPath) as? FolioReaderPage
return self.configure(readerPageCell: reuseableCell, atIndexPath: indexPath)
}

Expand Down Expand Up @@ -875,7 +871,6 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl
// Need check page orientation (v/h) and make correct calc for vertical
guard
let cell = collectionView.cellForItem(at: getCurrentIndexPath()) as? FolioReaderPage,
let contentOffset = cell.webView?.scrollView.contentOffset,
let contentSize = cell.webView?.scrollView.contentSize else {
completion?()
return
Expand All @@ -902,7 +897,6 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl
// Need check page orientation (v/h) and make correct calc for vertical
guard
let cell = collectionView.cellForItem(at: getCurrentIndexPath()) as? FolioReaderPage,
let contentOffset = cell.webView?.scrollView.contentOffset,
let contentSize = cell.webView?.scrollView.contentSize else {
delegate?.pageItemChanged?(getCurrentPageItemNumber())
completion?()
Expand Down Expand Up @@ -1366,9 +1360,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl
extension FolioReaderCenter: FolioReaderPageDelegate {

public func pageDidLoad(_ page: FolioReaderPage) {
if self.readerConfig.loadSavedPositionForCurrentBook,
let bookId = self.book.name,
let position = folioReader.savedPositionForCurrentBook as? NSDictionary {
if self.readerConfig.loadSavedPositionForCurrentBook, let position = folioReader.savedPositionForCurrentBook {
let pageNumber = position["pageNumber"] as? Int
let offset = self.readerConfig.isDirection(position["pageOffsetY"], position["pageOffsetX"], position["pageOffsetY"]) as? CGFloat
let pageOffset = offset
Expand Down
10 changes: 3 additions & 7 deletions Source/FolioReaderContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ open class FolioReaderContainer: UIViewController {
self.readerConfig.scrollDirection = scrollDirection
}

let hideBars = (self.readerConfig.hideBars ?? false)
let hideBars = readerConfig.hideBars
self.readerConfig.shouldHideNavigationOnTap = ((hideBars == true) ? true : self.readerConfig.shouldHideNavigationOnTap)

self.centerViewController = FolioReaderCenter(withContainer: self)
Expand Down Expand Up @@ -164,17 +164,12 @@ open class FolioReaderContainer: UIViewController {
DispatchQueue.global(qos: .userInitiated).async {

do {
guard let parsedBook = try? FREpubParser().readEpub(epubPath: self.epubPath, removeEpub: self.shouldRemoveEpub, unzipPath: self.unzipPath) else {
self.errorOnLoad = true
return
}

let parsedBook = try FREpubParser().readEpub(epubPath: self.epubPath, removeEpub: self.shouldRemoveEpub, unzipPath: self.unzipPath)
self.book = parsedBook
self.folioReader.isReaderOpen = true

// Reload data
DispatchQueue.main.async {

// Add audio player if needed
if self.book.hasAudio || self.readerConfig.enableTTS {
self.addAudioPlayer()
Expand All @@ -184,6 +179,7 @@ open class FolioReaderContainer: UIViewController {
self.folioReader.delegate?.folioReader?(self.folioReader, didFinishedLoading: self.book)
}
} catch {
self.errorOnLoad = true
self.alert(message: error.localizedDescription)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderHighlightList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FolioReaderHighlightList: 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)

guard let bookId = (self.folioReader.readerContainer?.book.name as? NSString)?.deletingPathExtension else {
guard let bookId = (self.folioReader.readerContainer?.book.name as NSString?)?.deletingPathExtension else {
self.highlights = []
return
}
Expand Down
6 changes: 2 additions & 4 deletions Source/FolioReaderKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ extension FolioReader {
/// - animated: Pass true to animate the presentation; otherwise, pass false.
open func presentReader(parentViewController: UIViewController, withEpubPath epubPath: String, unzipPath: String? = nil, andConfig config: FolioReaderConfig, shouldRemoveEpub: Bool = true, animated:
Bool = true) {
var readerContainer = FolioReaderContainer(withConfig: config, folioReader: self, epubPath: epubPath, unzipPath: unzipPath, removeEpub: shouldRemoveEpub)
let readerContainer = FolioReaderContainer(withConfig: config, folioReader: self, epubPath: epubPath, unzipPath: unzipPath, removeEpub: shouldRemoveEpub)
self.readerContainer = readerContainer
parentViewController.present(readerContainer, animated: animated, completion: nil)
addObservers()
Expand Down Expand Up @@ -342,9 +342,7 @@ extension FolioReader {
return
}

guard let bookId = self.readerContainer?.book.name,
let currentPage = self.readerCenter?.currentPage,
let webView = currentPage.webView else {
guard let currentPage = self.readerCenter?.currentPage, let webView = currentPage.webView else {
return
}

Expand Down
Loading

0 comments on commit fe3f81a

Please sign in to comment.