diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 076595264..46b881672 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -333,7 +333,6 @@ CA10C12F1C572A4B0049165D /* Resources */, C1392FF51E4FD15EBB5AA8DD /* [CP] Embed Pods Frameworks */, E82F486563C1547E0775A59F /* 📦 Embed Pods Frameworks */, - 064D38CE83FACC358B7C0EC8 /* 📦 Copy Pods Resources */, ); buildRules = ( ); @@ -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; diff --git a/Example/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/Example/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index 4e9a31728..6c8217d1e 100755 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -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") { diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 33f298757..b3a0d3de3 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -58,4 +58,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: d5e64429a71bc13b6eceb790b04656d8082e4d66 -COCOAPODS: 1.5.2 +COCOAPODS: 1.5.3 diff --git a/Source/FolioReaderConfig.swift b/Source/FolioReaderConfig.swift index 033772f3e..e9962ff55 100755 --- a/Source/FolioReaderConfig.swift +++ b/Source/FolioReaderConfig.swift @@ -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 /** @@ -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 diff --git a/Source/FolioReaderWebView.swift b/Source/FolioReaderWebView.swift index 3fc9aed18..cf23cd924 100644 --- a/Source/FolioReaderWebView.swift +++ b/Source/FolioReaderWebView.swift @@ -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 @@ -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 } } diff --git a/Source/Resources/Style.css b/Source/Resources/Style.css index c1a0a458f..3f7a461dd 100755 --- a/Source/Resources/Style.css +++ b/Source/Resources/Style.css @@ -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; } }