Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #20 from readium/develop
Browse files Browse the repository at this point in the history
1.0.4
  • Loading branch information
aferditamuriqi authored Aug 12, 2018
2 parents 05e9027 + 31b2b81 commit ea6c269
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Hearst-DD/ObjectMapper" "2.2.9"
github "Readium/r2-shared-swift" "1.2.0"
github "Hearst-DD/ObjectMapper" "2.2.0"
github "Readium/r2-shared-swift" "07f5fe26381e0980925f7a16e8c05a1c7455ea45"
20 changes: 19 additions & 1 deletion r2-navigator-swift/NavigatorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ open class NavigatorViewController: UIViewController {
triptychView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
view.addSubview(triptychView)
}

public var currentPosition:(Int, Double) {
get {
let progression = triptychView.getCurrentDocumentProgression()
let index = triptychView.getCurrentDocumentIndex()
return (index, progression ?? 0)
}
}

open override func viewWillDisappear(_ animated: Bool) {
// Save the currently opened document index and progression.
Expand All @@ -100,7 +108,17 @@ extension NavigatorViewController {
}
triptychView.moveTo(index: index)
}


/// Display the spine item at `index` with scroll `progression`
///
/// - Parameter index: The index of the spine item to display.
public func displaySpineItem(at index: Int, progression: Double) {
displaySpineItem(at: index)
if let webView = triptychView.currentView as? WebView {
webView.scrollAt(position: progression)
}
}

/// Load resource with the corresponding href.
///
/// - Parameter href: The href of the resource to load. Can contain a tag id.
Expand Down
21 changes: 21 additions & 0 deletions r2-navigator-swift/UserSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class UserSettings {
private var wordSpacing: Float = 0
private var letterSpacing: Float = 0
private var pageMargins: Float = 1
private var lineHeight: Float = 1

public var userSettingsUIPreset: [ReadiumCSSName: Bool]?
public let userProperties = UserProperties()
Expand Down Expand Up @@ -122,6 +123,13 @@ public class UserSettings {
pageMargins = 1
}

// Line height
if isKeyPresentInUserDefaults(key: ReadiumCSSName.lineHeight) {
lineHeight = userDefaults.float(forKey: ReadiumCSSName.lineHeight.rawValue)
} else {
lineHeight = 1
}

buildCssProperties()

}
Expand Down Expand Up @@ -210,6 +218,15 @@ public class UserSettings {
reference: ReadiumCSSReference.pageMargins.rawValue,
name: ReadiumCSSName.pageMargins.rawValue)

// Line height
userProperties.addIncrementable(nValue: lineHeight,
min: 1,
max: 2,
step: 0.25,
suffix: "",
reference: ReadiumCSSReference.lineHeight.rawValue,
name: ReadiumCSSName.lineHeight.rawValue)

}

// Save settings to UserDefaults
Expand Down Expand Up @@ -261,6 +278,10 @@ public class UserSettings {
userDefaults.set(currentPageMargins.value, forKey: ReadiumCSSName.pageMargins.rawValue)
}

if let currentLineHeight = userProperties.getProperty(reference: ReadiumCSSReference.lineHeight.rawValue) as? Incrementable {
userDefaults.set(currentLineHeight.value, forKey: ReadiumCSSName.lineHeight.rawValue)
}

}

/// Check if a given key is set in the UserDefaults.
Expand Down

0 comments on commit ea6c269

Please sign in to comment.