Epub阅读器0.0.1
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import UIKit
|
||||
|
||||
public struct RDEPUBNavigatorLayoutContext: Equatable {
|
||||
public var containerSize: CGSize
|
||||
public var pagesPerScreen: Int
|
||||
public var safeAreaInsets: UIEdgeInsets
|
||||
public var userInterfaceIdiom: UIUserInterfaceIdiom
|
||||
public var reflowableContentInsets: UIEdgeInsets
|
||||
|
||||
public init(
|
||||
containerSize: CGSize,
|
||||
pagesPerScreen: Int = 1,
|
||||
safeAreaInsets: UIEdgeInsets = .zero,
|
||||
userInterfaceIdiom: UIUserInterfaceIdiom = .phone,
|
||||
reflowableContentInsets: UIEdgeInsets = UIEdgeInsets(top: 40, left: 16, bottom: 40, right: 16)
|
||||
) {
|
||||
self.containerSize = containerSize
|
||||
self.pagesPerScreen = max(1, pagesPerScreen)
|
||||
self.safeAreaInsets = safeAreaInsets
|
||||
self.userInterfaceIdiom = userInterfaceIdiom
|
||||
self.reflowableContentInsets = reflowableContentInsets
|
||||
}
|
||||
|
||||
public var viewportSize: CGSize {
|
||||
let width: CGFloat
|
||||
if pagesPerScreen > 1 {
|
||||
width = containerSize.width / CGFloat(pagesPerScreen)
|
||||
} else {
|
||||
width = containerSize.width
|
||||
}
|
||||
return CGSize(width: width, height: containerSize.height)
|
||||
}
|
||||
|
||||
public var fixedContentInset: UIEdgeInsets {
|
||||
var insets = safeAreaInsets
|
||||
if userInterfaceIdiom != .phone {
|
||||
insets = .zero
|
||||
}
|
||||
|
||||
let horizontalInsets = max(insets.left, insets.right)
|
||||
insets.left = horizontalInsets
|
||||
insets.right = horizontalInsets
|
||||
return insets
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user