-
Notifications
You must be signed in to change notification settings - Fork 772
variable hideBars, scroll to navigate through paragraphs and scroll to read the content are added, README.md is updated #107
Changes from 8 commits
7cce5ff
6cbb26f
a02e406
966368f
8ff6a52
ec5a2ec
b05733b
730da00
2d5b67a
d9e0071
0c66d04
5920de6
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 |
---|---|---|
|
@@ -56,7 +56,7 @@ Then, follow the steps as described in Carthage's [README](https://github.com/Ca | |
|
||
## Basic Usage | ||
|
||
To get started, this is a simple usage sample. | ||
To get started, this is a simple usage sample of using the integrated view controller. | ||
|
||
```swift | ||
import FolioReaderKit | ||
|
@@ -68,6 +68,19 @@ func open(sender: AnyObject) { | |
} | ||
``` | ||
|
||
You can also use your own FolioReader view controller like this. | ||
|
||
```swift | ||
let config = FolioReaderConfig() | ||
|
||
let bookPath = NSBundle.mainBundle().pathForResource("book", ofType: "epub") | ||
let epubVC = FolioReaderContainer(config: config, epubPath: bookPath, removeEpub: true) | ||
FolioReader.sharedInstance.readerContainer = epubVC | ||
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.
Maybe we can assign to the singleton inside the init, so on implementation will be simplified. There is no need to call What do you think? |
||
|
||
// present the epubVC view controller like every other UIViewController instance | ||
self.presentViewController(epubVC, animated: true, completion: nil) | ||
``` | ||
|
||
In your AppDelegate call `applicationWillResignActive` and `applicationWillTerminate`. This will save the reader state even if you kill the app. | ||
|
||
```swift | ||
|
@@ -96,7 +109,7 @@ func applicationWillTerminate(application: UIApplication) { | |
- [x] Media Overlays (Sync text rendering with audio playback) | ||
- [x] TTS - Text to Speech Support | ||
- [x] Parse epub cover image | ||
- [x] Vertical and Horizontal scrolling | ||
- [x] Vertical or/and Horizontal scrolling | ||
- [x] RTL Support | ||
- [ ] PDF support | ||
- [ ] Book Search | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import UIKit | |
public enum FolioReaderScrollDirection: Int { | ||
case vertical | ||
case horizontal | ||
case sectionHorizontalContentVertical | ||
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. This is a really interesting addition 👍 Some points that I have noticed:
|
||
|
||
/** | ||
The current scroll direction | ||
|
@@ -21,7 +22,7 @@ public enum FolioReaderScrollDirection: Int { | |
switch self { | ||
case vertical: | ||
return .Vertical | ||
case horizontal: | ||
case horizontal, sectionHorizontalContentVertical: | ||
return .Horizontal | ||
} | ||
} | ||
|
@@ -41,7 +42,9 @@ public class FolioReaderConfig: NSObject { | |
public lazy var mediaOverlayColor: UIColor! = self.tintColor | ||
|
||
// MARK: Custom actions | ||
|
||
/// hide the navigation bar and the bottom status view | ||
public var hideBars = false | ||
|
||
/// If `canChangeScrollDirection` is `true` it will be overrided by user's option. | ||
public var scrollDirection: FolioReaderScrollDirection = .vertical | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,21 +78,26 @@ class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGestureRecogni | |
} | ||
|
||
func webViewFrame() -> CGRect { | ||
let paddingTop: CGFloat = 20 | ||
|
||
if (readerConfig.hideBars == true) { | ||
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. You can use Need to test, but something like this: guard readerConfig.hideBars == false else { return UIScreen.mainScreen().bounds } |
||
return UIScreen.mainScreen().bounds | ||
} | ||
|
||
let paddingTop: CGFloat = 20 | ||
let paddingBottom: CGFloat = 30 | ||
guard readerConfig.shouldHideNavigationOnTap else { | ||
let statusbarHeight = UIApplication.sharedApplication().statusBarFrame.size.height | ||
let navBarHeight = FolioReader.sharedInstance.readerCenter.navigationController?.navigationBar.frame.size.height | ||
let navTotal = statusbarHeight + navBarHeight! | ||
let newFrame = CGRect( | ||
x: bounds.origin.x, | ||
y: isVerticalDirection(bounds.origin.y + navTotal, bounds.origin.y + navTotal + paddingTop), | ||
width: bounds.width, | ||
height: isVerticalDirection(bounds.height - navTotal, bounds.height - navTotal - paddingTop - paddingBottom)) | ||
return newFrame | ||
} | ||
|
||
guard readerConfig.shouldHideNavigationOnTap else { | ||
let statusbarHeight = UIApplication.sharedApplication().statusBarFrame.size.height | ||
let navBarHeight = FolioReader.sharedInstance.readerCenter.navigationController?.navigationBar.frame.size.height | ||
let navTotal = statusbarHeight + navBarHeight! | ||
let newFrame = CGRect( | ||
x: bounds.origin.x, | ||
y: isVerticalDirection(bounds.origin.y + navTotal, bounds.origin.y + navTotal + paddingTop), | ||
width: bounds.width, | ||
height: isVerticalDirection(bounds.height - navTotal, bounds.height - navTotal - paddingTop - paddingBottom)) | ||
return newFrame | ||
} | ||
|
||
let newFrame = CGRect( | ||
x: bounds.origin.x, | ||
y: isVerticalDirection(bounds.origin.y, bounds.origin.y + paddingTop), | ||
|
@@ -620,11 +625,15 @@ extension UIWebView { | |
paginationMode = .LeftToRight | ||
paginationBreakingMode = .Page | ||
scrollView.bounces = false | ||
} else { | ||
} else if readerConfig.scrollDirection == .vertical { | ||
scrollView.pagingEnabled = false | ||
paginationMode = .Unpaginated | ||
scrollView.bounces = true | ||
} | ||
} else { | ||
// swipe paragraphs horizontal, read content vertical | ||
scrollView.bounces = true | ||
self.scrollView.showsVerticalScrollIndicator = true | ||
} | ||
} | ||
} | ||
|
||
|
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.
Have you tested this? This init is not public, we need to make it public to work.
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.
This init still not public yet, we have to make it public on
FolioReaderContainer
.