ReadViewSDK/Sources/RDReaderView/EPUBUI/RDEPUBReaderController+Orientation.swift
shenlei d5a7755702 feat: 支持加密 EPUB、试读墙、工具栏定制与朝向锁定
- 新增 RDEPUBResourceDataProvider 解密钩子协议 + 访问登记表,收敛章节 HTML/
  图片/内联 CSS/脚注/封面/图片查看器/正文取图等读取点,scheme handler 对加密书
  禁用流式分支;新增 RDEPUBDecryptingImageAttachment 解密 DTCoreText 图片附件;
  RDEPUBReaderDependencies.live(resourceDataProvider:) 便捷注入。明文书零影响。
- 试读墙:configuration.trialPolicy + delegate epubReaderTrialWallView/
  DidReachTrialWall,UI 由宿主提供(RDEPUBReaderController+Trial)。
- 工具栏定制:RDEPUBReaderTop/BottomToolViewProtocol 协议 + dependencies 工厂注入,
  内置栏已 conform,configureTopToolView 改协议类型。
- 朝向锁定:RDEPUBMetadata.orientation(OPF rendition:orientation 主,
  iBooks display-options 兜底)+ RDEPUBReaderController+Orientation 重写支持朝向、
  打开后主动转向。

注:RDEPUBReaderController+LocationResolution / PaginationCoordinator 为本次改动前
即存在的工作区修改,一并纳入。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 12:25:17 +09:00

49 lines
2.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import UIKit
///
///
/// `publication.metadata.orientation` OPF rendition:orientation
/// iBooks display-options
/// nil / .auto
///
/// `supportedInterfaceOrientations`
/// 宿 present
extension RDEPUBReaderController {
/// EPUB nil =
var epubSupportedOrientationMask: UIInterfaceOrientationMask? {
switch publication?.metadata.orientation {
case .portrait:
return .portrait
case .landscape:
return .landscape
case .auto, .none:
return nil
}
}
public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
epubSupportedOrientationMask ?? super.supportedInterfaceOrientations
}
public override var shouldAutorotate: Bool {
//
epubSupportedOrientationMask == nil
}
/// iOS 16+ requestGeometryUpdate退
///
func applyOrientationLockIfNeeded() {
guard let mask = epubSupportedOrientationMask else { return }
if #available(iOS 16.0, *) {
setNeedsUpdateOfSupportedInterfaceOrientations()
guard let scene = view.window?.windowScene else { return }
scene.requestGeometryUpdate(.iOS(interfaceOrientations: mask)) { _ in }
} else {
let target: UIInterfaceOrientation = (mask == .landscape) ? .landscapeRight : .portrait
UIDevice.current.setValue(target.rawValue, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
}
}
}