-
Notifications
You must be signed in to change notification settings - Fork 772
Make the changePage and scrollTo functionality accesable to the public #128
Changes from 3 commits
3607363
afce92c
eaee636
f0eec1f
34228a6
4eea438
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -613,17 +613,6 @@ public class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICo | |
) | ||
} | ||
|
||
func changePageWith(page page: Int, animated: Bool = false, completion: (() -> Void)? = nil) { | ||
if page > 0 && page-1 < totalPages { | ||
let indexPath = NSIndexPath(forRow: page-1, inSection: 0) | ||
changePageWith(indexPath: indexPath, animated: animated, completion: { () -> Void in | ||
self.updateCurrentPage({ () -> Void in | ||
completion?() | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
func changePageWith(page page: Int, andFragment fragment: String, animated: Bool = false, completion: (() -> Void)? = nil) { | ||
if currentPageNumber == page { | ||
if let currentPage = currentPage where fragment != "" { | ||
|
@@ -640,7 +629,7 @@ public class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICo | |
} | ||
} | ||
|
||
func changePageWith(href href: String, animated: Bool = false, completion: (() -> Void)? = nil) { | ||
func changePageWith(href href: String, animated: Bool = false, completion: (() -> Void)? = nil) { | ||
let item = findPageByHref(href) | ||
let indexPath = NSIndexPath(forRow: item, inSection: 0) | ||
changePageWith(indexPath: indexPath, animated: animated, completion: { () -> Void in | ||
|
@@ -681,7 +670,7 @@ public class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICo | |
completion?() | ||
} | ||
} | ||
|
||
func indexPathIsValid(indexPath: NSIndexPath) -> Bool { | ||
let section = indexPath.section | ||
let row = indexPath.row | ||
|
@@ -772,6 +761,23 @@ public class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICo | |
} | ||
return nil | ||
} | ||
|
||
// MARK: Public page methods | ||
|
||
public func changePageWith(page page: Int, animated: Bool = false, completion: (() -> Void)? = nil) { | ||
if page > 0 && page-1 < totalPages { | ||
let indexPath = NSIndexPath(forRow: page-1, inSection: 0) | ||
changePageWith(indexPath: indexPath, animated: animated, completion: { () -> Void in | ||
self.updateCurrentPage({ () -> Void in | ||
completion?() | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
public func getCurrentPage() -> FolioReaderPage? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think is better to make public private(set) var currentPage: FolioReaderPage? And use it FolioReader.sharedInstance.readerCenter.currentPage What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine for me. |
||
return self.currentPage | ||
} | ||
|
||
// MARK: - Audio Playing | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ var book: FRBook! | |
/// Reader container | ||
public class FolioReaderContainer: UIViewController { | ||
var centerNavigationController: UINavigationController! | ||
var centerViewController: FolioReaderCenter! | ||
var centerViewController: FolioReaderCenter! | ||
var audioPlayer: FolioReaderAudioPlayer! | ||
var shouldHideStatusBar = true | ||
var shouldRemoveEpub = true | ||
|
@@ -188,4 +188,11 @@ public class FolioReaderContainer: UIViewController { | |
override public func preferredStatusBarStyle() -> UIStatusBarStyle { | ||
return isNight(.LightContent, .Default) | ||
} | ||
|
||
// MARK: - Public | ||
|
||
public func readerCenter() -> FolioReaderCenter { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? it is already exposed thought singleton. You can use it: let readerCenter = FolioReader.sharedInstance.readerCenter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, didn't see this one. |
||
return self.centerViewController | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some docs for public functions, so you help me on generated docs 😀