- Add RDEPUBReaderUIState struct for centralized UI state model - Refactor RDEPUBReaderChromeCoordinator with makeUIState() and applyUIState() - Remove direct UI updates from RDEPUBReaderAnnotationCoordinator - Consolidate updateBookmarkChrome() into updateReaderChrome() - Update RDEPUBReaderContext, Runtime, and LocationCoordinator - Add reader problem fix development checklist documentation Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
39 lines
1.5 KiB
Swift
39 lines
1.5 KiB
Swift
import Foundation
|
||
|
||
/// 阅读器 UI 状态模型:统一管理顶部/底部工具栏按钮的可用性和显示状态。
|
||
///
|
||
/// 解决问题:之前书签、高亮等按钮的状态分散在 ChromeCoordinator 和 AnnotationCoordinator 中,
|
||
/// 导致状态更新入口不一致,容易出现不同步的情况。
|
||
struct RDEPUBReaderUIState {
|
||
/// 顶部书签按钮是否可用(当前有书籍标识时可用)
|
||
let canToggleBookmark: Bool
|
||
/// 顶部书签按钮是否选中(当前位置已加书签时选中)
|
||
let hasBookmarkAtCurrentLocation: Bool
|
||
/// 底部书签列表按钮是否可用(有书签数据时可用)
|
||
let canShowBookmarks: Bool
|
||
/// 底部新建标注按钮是否可用(有选中文本时可用)
|
||
let canAddHighlight: Bool
|
||
/// 底部高亮列表按钮是否可用(有高亮数据时可用)
|
||
let canShowHighlights: Bool
|
||
/// 是否显示目录按钮
|
||
let showsTableOfContents: Bool
|
||
/// 是否显示高亮相关按钮(新建标注和高亮列表)
|
||
let allowsHighlights: Bool
|
||
/// 是否显示设置按钮
|
||
let showsSettingsPanel: Bool
|
||
}
|
||
|
||
extension RDEPUBReaderUIState {
|
||
/// 默认的空状态
|
||
static let empty = RDEPUBReaderUIState(
|
||
canToggleBookmark: false,
|
||
hasBookmarkAtCurrentLocation: false,
|
||
canShowBookmarks: false,
|
||
canAddHighlight: false,
|
||
canShowHighlights: false,
|
||
showsTableOfContents: true,
|
||
allowsHighlights: true,
|
||
showsSettingsPanel: true
|
||
)
|
||
}
|