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

Issue/140 #237

Merged
merged 136 commits into from
May 30, 2017
Merged
Show file tree
Hide file tree
Changes from 133 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
14bec27
Storyboard example now full screen. Update podfile
kevindelord Mar 28, 2017
1b8f389
Update gitignore
kevindelord Mar 28, 2017
9bbe04f
Add TODOs and replace the shared instance in the FolioReaderKit class
kevindelord Mar 28, 2017
b16196d
Refactor the readerCenter and global book entity
kevindelord Mar 28, 2017
88da69d
ReaderContainer: improve usage
kevindelord Mar 28, 2017
e7c0322
Refactor reader config
kevindelord Mar 28, 2017
6460b63
Improve isDirection functions to use current readerConfig
kevindelord Mar 29, 2017
1d59fc9
PageScrubbler: improve init logic and remove few optional unwrap
kevindelord Mar 29, 2017
4604a53
Refactor highlightlist, scrollscrubber and chapter list
kevindelord Mar 30, 2017
063bd93
Refactor FolioReaderFontsMenu
kevindelord Mar 30, 2017
a9dbb41
Refactor FolioReaderPlayerMenu
kevindelord Mar 30, 2017
81b2e75
Refactor FolioReaderQuoteShare
kevindelord Mar 30, 2017
d13cf98
Refactor FolioReaderAudioPlayer
kevindelord Mar 30, 2017
b3876c8
Refactor FolioReaderWebView.swift
kevindelord Mar 30, 2017
f0e19e6
Highlight: remove explicit try!
kevindelord Mar 30, 2017
9634542
Database method: integrate dynamic reader configuration
kevindelord Mar 30, 2017
c6f0e6e
Refactor HighlightStyle
kevindelord Mar 30, 2017
89528a7
Remove few todos and minor code improvment
kevindelord Mar 30, 2017
5112b2e
Merge pull request #5 from smartmobilefactory/highlight_refactor
kevindelord Mar 30, 2017
3e514d2
remove optional for book and epubPath
kevindelord Mar 30, 2017
276a370
Remove unnecessary optional for FRBook
kevindelord Mar 30, 2017
23f1188
Update todos
kevindelord Mar 30, 2017
8e995c2
PR: add doc and TODOs
kevindelord Mar 30, 2017
db0ed10
ignoreSystemTint: remove shared readerContainer and many optional unw…
kevindelord Mar 30, 2017
5d87547
Reafactor FolioReaderChapterListCell
kevindelord Mar 30, 2017
c927566
Remove todo
kevindelord Mar 30, 2017
8db0395
Merge pull request #6 from smartmobilefactory/refactor_reader_config
kevindelord Mar 30, 2017
44cd612
Carthage; Update gitignore
kevindelord Mar 30, 2017
f571eb0
Merge branch 'refactor_reader_config' into remove_global_variables
kevindelord Mar 30, 2017
b5fdb3f
FolioReader: convert convenience init to internal
kevindelord Mar 30, 2017
5bc3bb3
Highlight: create extension with all static deprecated functions inside
kevindelord Mar 30, 2017
2e3f4b8
Remove kBookId global variable
kevindelord Mar 30, 2017
791d421
Remove calls to FolioReader.shared.ReaderCenter
kevindelord Mar 30, 2017
ffdbc2d
Example app: integrate new API and refactor code
kevindelord Mar 30, 2017
9f36b97
FolioReader: remove all use of FolioReader.shared attribute.
kevindelord Mar 30, 2017
9855444
Remove todo
kevindelord Mar 30, 2017
d878439
Add TODO
kevindelord Mar 31, 2017
5ed8978
PR: refactor guard
kevindelord Mar 31, 2017
5263d2a
Merge branch 'remove_global_variables' into remove_shared_instances
kevindelord Mar 31, 2017
c256dfc
Refactor: isScrolling
kevindelord Mar 31, 2017
f6f509c
Refactor: pageScrollDirection
kevindelord Mar 31, 2017
ff4488b
Merge pull request #7 from smartmobilefactory/remove_global_variables
tschob Mar 31, 2017
9f761d0
Merge branch 'remove_shared_instances' of github.com:smartmobilefacto…
Mar 31, 2017
63a7aad
Refactor: currentPageNumber
kevindelord Mar 31, 2017
17c35b8
Refactor: reuseIdentifier
kevindelord Mar 31, 2017
a843c81
Refactor: pageheight and pageWidth
kevindelord Mar 31, 2017
2d915d6
Refactor: remove possible division by 0
kevindelord Mar 31, 2017
e466ed0
Refactor: remove some optional unwrappings
kevindelord Mar 31, 2017
b3612f8
Refactor: function with bad structure
kevindelord Mar 31, 2017
9d39740
Refactor: duplicated code
kevindelord Mar 31, 2017
085577e
Merge branch 'remove_shared_instances' of https://github.com/smartmob…
kevindelord Mar 31, 2017
3e06a02
Merge branch 'remove_shared_instances' into readerCenter_global_varia…
kevindelord Mar 31, 2017
ed5c6bc
Remove optional unwrapping
kevindelord Mar 31, 2017
bec2b2c
Merge pull request #9 from smartmobilefactory/readerCenter_global_var…
kevindelord Mar 31, 2017
3769df6
Fix and better integrate the storyboard support.
kevindelord Mar 31, 2017
12d26b1
Add todo check
kevindelord Mar 31, 2017
384d9dc
Update API logic to return FolioReaderContainer
kevindelord Mar 31, 2017
34926db
Wrap all store values in dicionaries
kevindelord Apr 1, 2017
626ad07
Add documentation
kevindelord Apr 1, 2017
c9b16f4
Fix typo in delegate function name
kevindelord Apr 1, 2017
04bf473
FolioReader: mark functions as deprecated
kevindelord Apr 1, 2017
7bb0b68
Highlight: mark functions as deprecated
kevindelord Apr 1, 2017
9a73d5e
Remove TODO_SMF_DOCs and create new extensions file
kevindelord Apr 1, 2017
60c1f7b
Report more changes on the migration.md file
kevindelord Apr 1, 2017
e789471
Improve question comment text
kevindelord Apr 1, 2017
16d2607
Comments: fix typo
kevindelord Apr 1, 2017
fa30b2a
Delegate: deprecate one function
kevindelord Apr 1, 2017
805ee59
Add more migration documentation
kevindelord Apr 1, 2017
b6730d9
update documentation and readme
kevindelord Apr 1, 2017
89c6632
Add one minor 0 check
kevindelord Apr 3, 2017
1bcc950
Merge pull request #8 from smartmobilefactory/remove_shared_instances
tschob Apr 3, 2017
6c1a5b9
Merge branch 'refactor_userdefault' of github.com:smartmobilefactory/…
Apr 3, 2017
94e1c3a
Merge pull request #11 from smartmobilefactory/refactor_userdefault
tschob Apr 3, 2017
67d335d
Migrationm: add description
kevindelord Apr 3, 2017
82d9394
Update TODO_SMF_QUESTION
kevindelord Apr 3, 2017
908659e
Update migration.md
kevindelord Apr 3, 2017
522226c
Remove unwanted space
Apr 10, 2017
a54da92
Merge pull request #12 from smartmobilefactory/documentation_and_depr…
tschob Apr 10, 2017
1cd8cd6
Remove unneeded SMF content
Apr 10, 2017
c1b0dd1
Remove Xcode 8.1 logging workaround from the schemes
Apr 10, 2017
aa67bf6
Replace tabs with spaces for the indentation
Apr 10, 2017
9cf2624
Merge pull request #14 from smartmobilefactory/documentation_and_depr…
tschob Apr 10, 2017
341b3fb
Remove outcommented code
Apr 10, 2017
0924b50
Merge branch 'development' of github.com:smartmobilefactory/FolioRead…
Apr 10, 2017
1016efe
Fix indentation
Apr 10, 2017
631e484
Remove out commented code
Apr 10, 2017
5395d6c
Replace tabs with spaces for the indentation
Apr 10, 2017
ef98459
Replace tabs with spaces for the indentation
Apr 10, 2017
b1972f9
Replace tabs with spaces for the indentation
Apr 10, 2017
5e2b213
Merge pull request #13 from smartmobilefactory/development
tschob Apr 10, 2017
aab39db
Merge branch 'master' of github.com:FolioReader/FolioReaderKit into f…
Apr 10, 2017
a397c71
Merge pull request #15 from smartmobilefactory/merge
tschob Apr 10, 2017
6f72925
Remove unused enum case
Apr 10, 2017
6570ae3
Fix "getCurrentChapterName()"
Apr 10, 2017
c37d747
Remove SMF TODOs which are not questions
Apr 10, 2017
8569930
Refactor reader config identifier logic to use custom identifiers ins…
Apr 10, 2017
2d41af8
Add multiple instances with Storyboard example
Apr 13, 2017
2ee2035
Settings: Register default values only if a key wasn't registered bef…
Apr 13, 2017
86b3062
Fix night mode appearance on first book opening
Apr 13, 2017
dc73880
Add multiple instances code base example project
Apr 13, 2017
10b2bab
Add missing shared instance configuration. Remove optional unwrapping…
kevindelord Apr 26, 2017
7e5c7e8
Fix indentation with tabs to use spaces
Apr 27, 2017
d0a1f03
Merge pull request #16 from smartmobilefactory/fix_legacy
tschob Apr 27, 2017
586b459
Fix wrong page number when using horizontal with vertical content scr…
May 5, 2017
b6cab0c
Merge branch 'master' of github.com:smartmobilefactory/FolioReaderKit…
May 5, 2017
1458169
Really fix wrong page number when using horizontal with vertical cont…
May 8, 2017
d897599
Fix sometimes wrong page offset for new pages when using vertical wit…
May 9, 2017
7bf89bb
Merge branch 'master' of github.com:smartmobilefactory/FolioReaderKit…
May 9, 2017
34dd9e5
Improved TODO and FIXME naming
May 9, 2017
5292a0c
Fix indentation
May 9, 2017
10ad010
Merge pull request #17 from smartmobilefactory/multipleInstancesMerge
tschob May 9, 2017
f955909
PR: Remove all extra whitepace on variable declarations DBGIOS-1004
kevindelord May 18, 2017
40d436f
PR: Remove parenthesis and some minor demands DBGIOS-1004
kevindelord May 18, 2017
1bbeefc
Fix indentation with tabs to use spaces
May 19, 2017
4b3fda1
Merge pull request #18 from smartmobilefactory/fix_PR_comments
tschob May 19, 2017
41ab2cb
Go to table of contents and select a new chapter, it should not scrol…
kevindelord May 20, 2017
5bcfe34
Bug fix: Bar toggle: tap to show is now showing the bar DBGIOS-1004
kevindelord May 20, 2017
903f7e9
Merge branch 'fix_PR_comments' of https://github.com/smartmobilefacto…
kevindelord May 20, 2017
4ffcb0e
PR: Remove extra brackets
kevindelord May 20, 2017
0699dce
Bug fix: jumping to chapter DBGIOS-1004
kevindelord May 23, 2017
7bd273a
Remove commented code DBGIOS-1004
kevindelord May 23, 2017
faaa348
Add epub identifier to avoid problems between example books DBGIOS-1004
kevindelord May 23, 2017
6d2c60a
PR: minor indentation change
kevindelord May 23, 2017
9cb26ba
Merge branch 'fix_PR_comments' of github.com:smartmobilefactory/Folio…
May 24, 2017
0384a0b
Fix indentation with tabs to use spaces
May 24, 2017
801e69d
Update to CocoaPods version 1.2.1
May 24, 2017
94fe4c7
Merge pull request #19 from smartmobilefactory/fix_PR_comments
tschob May 24, 2017
f2ac648
Fixed bar animation and not showing after couple page loads
hebertialmeida May 26, 2017
83a8223
Light refactor to have weak references of readerContainer
hebertialmeida May 26, 2017
3b3da43
Fixed tests
hebertialmeida May 26, 2017
55681dd
Removed forcing object
hebertialmeida May 29, 2017
cfd5937
Use weak reference
hebertialmeida May 29, 2017
ef320fc
Removed the need for retain ReaderContainer
hebertialmeida May 29, 2017
4fc7483
Updated migration guide
hebertialmeida May 30, 2017
c79f2ab
Make some methods public
hebertialmeida May 30, 2017
5fc6b3e
Updated dependencies
hebertialmeida May 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
Expand All @@ -9,25 +15,52 @@ build/
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
xcuserdata/

## Other
*.moved-aside
DerivedData
*.xcuserstate
*.DS_Store

## Obj-C/Swift specific
*.hmap
*.ipa
*.xcuserstate
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
Example/Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
422 changes: 309 additions & 113 deletions Example/Example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AAA8B671E9BB78B00A47E5A"
BuildableName = "MultipleInstance-Example.app"
BlueprintName = "MultipleInstance-Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AAA8B671E9BB78B00A47E5A"
BuildableName = "MultipleInstance-Example.app"
BlueprintName = "MultipleInstance-Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AAA8B671E9BB78B00A47E5A"
BuildableName = "MultipleInstance-Example.app"
BlueprintName = "MultipleInstance-Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AAA8B671E9BB78B00A47E5A"
BuildableName = "MultipleInstance-Example.app"
BlueprintName = "MultipleInstance-Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D12066621D65FABD006E1D18"
BuildableName = "Storyboard-Example.app"
BlueprintName = "Storyboard-Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D12066621D65FABD006E1D18"
BuildableName = "Storyboard-Example.app"
BlueprintName = "Storyboard-Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D12066621D65FABD006E1D18"
BuildableName = "Storyboard-Example.app"
BlueprintName = "Storyboard-Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D12066621D65FABD006E1D18"
BuildableName = "Storyboard-Example.app"
BlueprintName = "Storyboard-Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
11 changes: 0 additions & 11 deletions Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,9 @@ import FolioReaderKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
FolioReader.applicationWillResignActive()
}

func applicationWillTerminate(_ application: UIApplication) {
FolioReader.applicationWillTerminate()
}
}

92 changes: 58 additions & 34 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,25 @@ import FolioReaderKit

class ViewController: UIViewController {

@IBOutlet var bookOne: UIButton!
@IBOutlet var bookTwo: UIButton!
let epubSampleFiles = [
"The Silver Chair", // standard eBook
"The Adventures Of Sherlock Holmes - Adventure I", // audio-eBook
]
@IBOutlet weak var bookOne: UIButton?
@IBOutlet weak var bookTwo: UIButton?
let folioReader = FolioReader()

override func viewDidLoad() {
super.viewDidLoad()

setCover(bookOne, index: 0)
setCover(bookTwo, index: 1)
}

@IBAction func didOpen(_ sender: AnyObject) {
openEpub(sender.tag);
self.bookOne?.tag = Epub.bookOne.rawValue
self.bookTwo?.tag = Epub.bookTwo.rawValue

self.setCover(self.bookOne, index: 0)
self.setCover(self.bookTwo, index: 1)
}
func openEpub(_ sampleNum: Int) {
let config = FolioReaderConfig()
config.shouldHideNavigationOnTap = sampleNum == 1 ? true : false
config.scrollDirection = sampleNum == 1 ? .horizontal : .vertical

private func readerConfiguration(forEpub epub: Epub) -> FolioReaderConfig {
let config = FolioReaderConfig(withIdentifier: epub.readerIdentifier)
config.shouldHideNavigationOnTap = epub.shouldHideNavigationOnTap
config.scrollDirection = epub.scrollDirection

// See more at FolioReaderConfig.swift
// config.canChangeScrollDirection = false
// config.enableTTS = false
Expand All @@ -45,26 +41,41 @@ class ViewController: UIViewController {
// config.menuBackgroundColor = UIColor.lightGrayColor()
// config.hidePageIndicator = true
// config.realmConfiguration = Realm.Configuration(fileURL: FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("highlights.realm"))

// Custom sharing quote background
let customImageQuote = QuoteImage(withImage: UIImage(named: "demo-bg")!, alpha: 0.6, backgroundColor: UIColor.black)
let customQuote = QuoteImage(withColor: UIColor(red:0.30, green:0.26, blue:0.20, alpha:1.0), alpha: 1.0, textColor: UIColor(red:0.86, green:0.73, blue:0.70, alpha:1.0))

config.quoteCustomBackgrounds = [customImageQuote, customQuote]

// Epub file
let epubName = epubSampleFiles[sampleNum-1];
let bookPath = Bundle.main.path(forResource: epubName, ofType: "epub")
FolioReader.presentReader(parentViewController: self, withEpubPath: bookPath!, andConfig: config, shouldRemoveEpub: false)
config.quoteCustomBackgrounds = []
if let image = UIImage(named: "demo-bg") {
let customImageQuote = QuoteImage(withImage: image, alpha: 0.6, backgroundColor: UIColor.black)
config.quoteCustomBackgrounds.append(customImageQuote)
}

let textColor = UIColor(red:0.86, green:0.73, blue:0.70, alpha:1.0)
let customColor = UIColor(red:0.30, green:0.26, blue:0.20, alpha:1.0)
let customQuote = QuoteImage(withColor: customColor, alpha: 1.0, textColor: textColor)
config.quoteCustomBackgrounds.append(customQuote)

return config
}

fileprivate func open(epub: Epub) {
guard let bookPath = epub.bookPath else {
return
}

let readerConfiguration = self.readerConfiguration(forEpub: epub)
folioReader.presentReader(parentViewController: self, withEpubPath: bookPath, andConfig: readerConfiguration, shouldRemoveEpub: false)
}

func setCover(_ button: UIButton, index: Int) {
let epubName = epubSampleFiles[index];
let bookPath = Bundle.main.path(forResource: epubName, ofType: "epub")

private func setCover(_ button: UIButton?, index: Int) {
guard
let epub = Epub(rawValue: index),
let bookPath = epub.bookPath else {
return
}

do {
if let image = try FolioReader.getCoverImage(bookPath!) {
button.setBackgroundImage(image, for: .normal)
if let image = try FolioReader.getCoverImage(bookPath) {
button?.setBackgroundImage(image, for: .normal)
}
} catch let e as FolioReaderError {
print(e.localizedDescription)
Expand All @@ -73,3 +84,16 @@ class ViewController: UIViewController {
}
}
}

// MARK: - IBAction

extension ViewController {

@IBAction func didOpen(_ sender: AnyObject) {
guard let epub = Epub(rawValue: sender.tag) else {
return
}

self.open(epub: epub)
}
}
Loading