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

Feature: Two columns config. #343

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 0 additions & 16 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@
CA10C12F1C572A4B0049165D /* Resources */,
C1392FF51E4FD15EBB5AA8DD /* [CP] Embed Pods Frameworks */,
E82F486563C1547E0775A59F /* 📦 Embed Pods Frameworks */,
064D38CE83FACC358B7C0EC8 /* 📦 Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -489,21 +488,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
064D38CE83FACC358B7C0EC8 /* 📦 Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FolioReaderTests/Pods-FolioReaderTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
1D8126CC73301F2413345444 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
3 changes: 2 additions & 1 deletion Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ 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"))

// config.twoColumnsMode = .alwaysEnabled

// Custom sharing quote background
config.quoteCustomBackgrounds = []
if let image = UIImage(named: "demo-bg") {
Expand Down
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: d5e64429a71bc13b6eceb790b04656d8082e4d66

COCOAPODS: 1.5.2
COCOAPODS: 1.5.3
26 changes: 26 additions & 0 deletions Source/FolioReaderConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ public enum FolioReaderScrollDirection: Int {
}
}

///Show book content in two columns side by side. Note: Only for `horizontal scroll direction`.
public enum FolioReaderTwoColumnsMode {
case disabled

///Enabled in any situation, iPhone or iPad, portrait or landscape orientation.
case alwaysEnabled

///Enabled in any device, only landscape orientation.
case onlyLandscape

///Enabled only on iPad, portrait or landscape orientation.
case onlyIpad

///Enabled only on iPad, only landscape orientation.
case onlyIpadLandscape

///Enabled only on iPhone, portrait or landscape orientation.
case onlyIphone

///Enabled only on iPhone, only landscape orientation.
case onlyIphoneLandscape
}

// MARK: - ClassBasedOnClickListener

/**
Expand Down Expand Up @@ -128,6 +151,9 @@ open class FolioReaderConfig: NSObject {

/// If `canChangeScrollDirection` is `true` it will be overrided by user's option.
open var scrollDirection: FolioReaderScrollDirection = .defaultVertical

/// Show book content in two columns side by side. Note: Only for `horizontal scroll direction`. The default is 'disabled'.
open var twoColumnsMode = FolioReaderTwoColumnsMode.disabled

/// Enable or disable hability to user change scroll direction on menu.
open var canChangeScrollDirection = true
Expand Down
39 changes: 38 additions & 1 deletion Source/FolioReaderWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ open class FolioReaderWebView: UIWebView {
if let updateId = js("setHighlightStyle('\(HighlightStyle.classForStyle(style.rawValue))')") {
Highlight.updateById(withConfiguration: self.readerConfig, highlightId: updateId, type: style)
}

//FIX: https://github.com/FolioReader/FolioReaderKit/issues/316
setMenuVisible(false)
}

// MARK: - Create and show menu
Expand Down Expand Up @@ -371,8 +374,42 @@ open class FolioReaderWebView: UIWebView {
case .horizontal:
scrollView.isPagingEnabled = true
paginationMode = .leftToRight
paginationBreakingMode = .page
scrollView.bounces = false

var enableTwoColumns = false
if readerConfig.twoColumnsMode != .disabled {
let isIpad = UIDevice.current.userInterfaceIdiom == .pad
let isIphone = UIDevice.current.userInterfaceIdiom == .phone
let orientation = UIApplication.shared.statusBarOrientation
let isLandscape = orientation == .landscapeLeft || orientation == .landscapeRight

switch readerConfig.twoColumnsMode {
case .alwaysEnabled:
enableTwoColumns = true
break
case .onlyLandscape:
enableTwoColumns = isLandscape
break
case .onlyIpad:
enableTwoColumns = isIpad
break
case .onlyIpadLandscape:
enableTwoColumns = isIpad && isLandscape
break
case .onlyIphone:
enableTwoColumns = isIphone
break
case .onlyIphoneLandscape:
enableTwoColumns = isIphone && isLandscape
break
default:
break
}
}

paginationBreakingMode = enableTwoColumns ? .column : .page
pageLength = enableTwoColumns ? bounds.size.width/2 : bounds.size.width

break
}
}
Expand Down
3 changes: 2 additions & 1 deletion Source/Resources/Style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ body {
/* Custom padding for tablets */
@media only screen and (min-device-width: 768px){
body {
padding: 60px 80px !important;
/* padding: 60px 80px !important;*/
padding: 30px 40px !important;
}
}

Expand Down