完善阅读器主题与批注界面

This commit is contained in:
shenlei
2026-07-13 13:01:14 +09:00
parent adc24d3f36
commit 6a0a1223b1
22 changed files with 133 additions and 189 deletions
@@ -224,15 +224,6 @@ final class RDEPUBReaderAnnotationCoordinator {
controller.present(navigationController, animated: true)
}
func presentAnnotationCreation() {
guard let controller else { return }
guard controller.configuration.allowsHighlights,
let currentSelection = controller.currentSelection else {
return
}
presentAnnotationActionSheet(for: currentSelection)
}
func handleHighlightMenuAction(_ action: RDEPUBExistingHighlightMenuAction, highlight: RDEPUBHighlight) {
switch action {
case .copy:
@@ -477,25 +468,6 @@ final class RDEPUBReaderAnnotationCoordinator {
}
}
private func presentAnnotationActionSheet(for selection: RDEPUBSelection) {
guard let controller else { return }
let alert = UIAlertController(title: "创建标注", message: nil, preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "划线", style: .default) { [weak self] _ in
self?.createAnnotation(from: selection, style: .underline)
})
alert.addAction(UIAlertAction(title: "注释", style: .default) { [weak self] _ in
self?.presentAnnotationNoteEditor(for: selection)
})
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
if let popover = alert.popoverPresentationController {
popover.sourceView = controller.bottomToolView
popover.sourceRect = controller.bottomToolView.bounds
}
controller.present(alert, animated: true)
}
private func createAnnotation(
from selection: RDEPUBSelection,
style: RDEPUBHighlightStyle,
@@ -533,6 +505,7 @@ final class RDEPUBReaderAnnotationCoordinator {
let editor = RDEPUBAnnotationEditorViewController(
quote: quote,
initialNote: initialNote,
theme: controller.configuration.theme,
onSave: onSave
)
let navigationController = UINavigationController(rootViewController: editor)
@@ -46,9 +46,6 @@ final class RDEPUBReaderChromeCoordinator: NSObject, UIAdaptivePresentationContr
toolView.onShowHighlights = { [weak self] in
self?.context.runtime?.presentHighlightsManager()
}
toolView.onAddHighlight = { [weak self] in
self?.context.runtime?.presentAnnotationCreation()
}
toolView.onShowSettings = { [weak self] in
self?.presentSettings()
}
@@ -68,7 +65,6 @@ final class RDEPUBReaderChromeCoordinator: NSObject, UIAdaptivePresentationContr
canToggleBookmark: controller.currentBookIdentifier != nil,
hasBookmarkAtCurrentLocation: hasBookmarkAtCurrentLocation(),
canShowBookmarks: !controller.activeBookmarks.isEmpty,
canAddHighlight: controller.configuration.allowsHighlights && context.selectionState.hasSelection,
canShowHighlights: controller.configuration.allowsHighlights && !controller.activeHighlights.isEmpty,
showsTableOfContents: controller.configuration.showsTableOfContents,
allowsHighlights: controller.configuration.allowsHighlights,
@@ -93,7 +89,6 @@ final class RDEPUBReaderChromeCoordinator: NSObject, UIAdaptivePresentationContr
showsSettingsPanel: state.showsSettingsPanel
)
controller.bottomToolView.setBookmarksEnabled(state.canShowBookmarks)
controller.bottomToolView.setAddHighlightEnabled(state.canAddHighlight)
controller.bottomToolView.setHighlightsEnabled(state.canShowHighlights)
}
@@ -261,11 +256,12 @@ private final class RDEPUBReaderSettingsPresentationController: UIPresentationCo
let bounds = containerView.bounds
let isLandscape = bounds.width > bounds.height
if isLandscape {
let safeBounds = bounds.inset(by: containerView.safeAreaInsets)
let width = min(390, max(300, bounds.width * 0.32))
let height = min(340, bounds.height - 32)
let height = min(340, safeBounds.height - 32)
return CGRect(
x: bounds.maxX - width - 16,
y: bounds.midY - height / 2,
x: safeBounds.maxX - width - 16,
y: safeBounds.midY - height / 2,
width: width,
height: height
)
@@ -139,11 +139,10 @@ final class RDEPUBReaderPaginationCoordinator {
return
}
let restoreLocation = context.currentVisibleLocation() ?? context.persistenceLocation()
if readerView.currentDisplayType == .pageCurl, readerView.currentPage >= 0 {
readerView.transitionToPage(pageNum: readerView.currentPage, animated: false)
} else {
readerView.reloadData()
}
// pageCurl transitionToPage(, animated: false) fault
// / configure reloadData
//
readerView.reloadData()
if let restoreLocation {
_ = context.restoreReadingLocation(restoreLocation)
}
@@ -252,10 +252,6 @@ final class RDEPUBReaderRuntime {
annotationCoordinator.presentHighlightsManager()
}
func presentAnnotationCreation() {
annotationCoordinator.presentAnnotationCreation()
}
func handleHighlightMenuAction(_ action: RDEPUBExistingHighlightMenuAction, highlight: RDEPUBHighlight) {
annotationCoordinator.handleHighlightMenuAction(action, highlight: highlight)
}
@@ -8,8 +8,6 @@ struct RDEPUBReaderUIState {
let canShowBookmarks: Bool
let canAddHighlight: Bool
let canShowHighlights: Bool
let showsTableOfContents: Bool
@@ -25,7 +23,6 @@ extension RDEPUBReaderUIState {
canToggleBookmark: false,
hasBookmarkAtCurrentLocation: false,
canShowBookmarks: false,
canAddHighlight: false,
canShowHighlights: false,
showsTableOfContents: true,
allowsHighlights: true,