ReadViewSDK/Sources/RDEpubReaderView/EPUBUI/Settings/RDEPUBReaderTheme.swift
2026-07-13 13:01:14 +09:00

85 lines
2.7 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
public struct RDEPUBReaderTheme: Equatable {
public var contentBackgroundColor: UIColor
public var contentTextColor: UIColor
public var toolBackgroundColor: UIColor
public var toolControlTextColor: UIColor
public var toolControlBorderUnselectColor: UIColor
public var toolLineColor: UIColor
public init(
contentBackgroundColor: UIColor,
contentTextColor: UIColor,
toolBackgroundColor: UIColor,
toolControlTextColor: UIColor,
toolControlBorderUnselectColor: UIColor,
toolLineColor: UIColor
) {
self.contentBackgroundColor = contentBackgroundColor
self.contentTextColor = contentTextColor
self.toolBackgroundColor = toolBackgroundColor
self.toolControlTextColor = toolControlTextColor
self.toolControlBorderUnselectColor = toolControlBorderUnselectColor
self.toolLineColor = toolLineColor
}
public static let light = preset(contentBackground: .white, text: .black)
public static let dark = preset(contentBackground: .black, text: .white)
public static let yellow = preset(
contentBackground: UIColor(red: 0.89, green: 0.87, blue: 0.79, alpha: 1),
text: .black
)
public static let green = preset(
contentBackground: UIColor(red: 0.87, green: 0.91, blue: 0.82, alpha: 1),
text: .black
)
public static let pink = preset(
contentBackground: UIColor(red: 1, green: 0.89, blue: 0.91, alpha: 1),
text: .black
)
public static let blue = preset(
contentBackground: UIColor(red: 0.8, green: 0.84, blue: 0.89, alpha: 1),
text: .black
)
/// /
private static func preset(contentBackground: UIColor, text: UIColor) -> RDEPUBReaderTheme {
RDEPUBReaderTheme(
contentBackgroundColor: contentBackground,
contentTextColor: text,
toolBackgroundColor: contentBackground.rd_chromeShade,
toolControlTextColor: text,
toolControlBorderUnselectColor: UIColor.lightGray.withAlphaComponent(0.5),
toolLineColor: UIColor.lightGray.withAlphaComponent(0.5)
)
}
}
extension RDEPUBReaderTheme {
/// Background color for the full-screen image viewer.
/// Always near-black regardless of theme, since the image is the focus.
var imageViewerBackgroundColor: UIColor {
UIColor(white: 0.0, alpha: 0.95)
}
var themeBackgroundColorCSS: String {
contentBackgroundColor.rd_cssString
}
var themeTextColorCSS: String {
contentTextColor.rd_cssString
}
}