diff --git a/ReadViewDemo/ReadViewDemo/PDFDemoReaderViewController.swift b/ReadViewDemo/ReadViewDemo/PDFDemoReaderViewController.swift index 1097632..055cd38 100644 --- a/ReadViewDemo/ReadViewDemo/PDFDemoReaderViewController.swift +++ b/ReadViewDemo/ReadViewDemo/PDFDemoReaderViewController.swift @@ -152,6 +152,9 @@ private final class PDFDemoPageProvider: RDPDFReaderPageProvider, RDPDFReaderOut /// 成品阅读器的 Demo 宿主:存储位置、返回导航和自动化状态是唯一的应用职责。 final class PDFDemoReaderViewController: UIViewController, RDPDFReaderViewControllerDelegate { private static let annotationStorageFolderName = "RDPDFImageReaderAnnotations" + /// 暂时隐藏阅读器中的 AI 助手入口与 TTS 朗读控件,实现保留以便随时恢复。 + private static let showsAIAssistant = false + private static let showsSpeechControls = false private let reader: RDPDFReaderViewController private lazy var speechSession: RDPDFSpeechSession = { let session = reader.makeSpeechSession() @@ -224,15 +227,17 @@ final class PDFDemoReaderViewController: UIViewController, RDPDFReaderViewContro reader.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(reader.view) reader.didMove(toParent: self) - configureSpeechControls() - let assistantButton = UIButton(type: .system) - assistantButton.setTitle("AI", for: .normal) - assistantButton.titleLabel?.font = .preferredFont(forTextStyle: .headline) - assistantButton.addTarget(self, action: #selector(presentAIAssistant), for: .touchUpInside) - assistantButton.accessibilityLabel = "打开阅读助手" - view.addSubview(assistantButton) - assistantButton.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([assistantButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 12), assistantButton.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor), assistantButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 44), assistantButton.heightAnchor.constraint(equalToConstant: 44)]) + if Self.showsSpeechControls { configureSpeechControls() } + if Self.showsAIAssistant { + let assistantButton = UIButton(type: .system) + assistantButton.setTitle("AI", for: .normal) + assistantButton.titleLabel?.font = .preferredFont(forTextStyle: .headline) + assistantButton.addTarget(self, action: #selector(presentAIAssistant), for: .touchUpInside) + assistantButton.accessibilityLabel = "打开阅读助手" + view.addSubview(assistantButton) + assistantButton.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([assistantButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 12), assistantButton.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor), assistantButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 44), assistantButton.heightAnchor.constraint(equalToConstant: 44)]) + } stateLabel.translatesAutoresizingMaskIntoConstraints = false view.addSubview(stateLabel) NSLayoutConstraint.activate([stateLabel.widthAnchor.constraint(equalToConstant: 1), stateLabel.heightAnchor.constraint(equalToConstant: 1), stateLabel.topAnchor.constraint(equalTo: view.topAnchor), stateLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor)])