浏览代码

Merge pull request #2008 from nextcloud/fix/pdfSearch

Fix/pdf search
Marino Faggiana 2 年之前
父节点
当前提交
07f6d805a2
共有 2 个文件被更改,包括 14 次插入6 次删除
  1. 12 5
      iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift
  2. 2 1
      iOSClient/Viewer/NCViewerPDF/NCViewerPDFSearch.swift

+ 12 - 5
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -202,8 +202,8 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         if UIDevice.current.userInterfaceIdiom == .phone && !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerPDFThumbnail){
 
             var preferences = EasyTipView.Preferences()
-            preferences.drawing.foregroundColor = NCBrandColor.shared.brandText
-            preferences.drawing.backgroundColor = NCBrandColor.shared.customer
+            preferences.drawing.foregroundColor = .white
+            preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
             preferences.drawing.textAlignment = .left
             preferences.drawing.arrowPosition = .right
             preferences.drawing.cornerRadius = 10
@@ -474,9 +474,16 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
     func searchPdfSelection(_ pdfSelection: PDFSelection) {
 
-        pdfSelection.color = .yellow
-        pdfView.currentSelection = pdfSelection
-        pdfView.go(to: pdfSelection)
+        pdfSelection.pages.forEach { page in
+            let highlight = PDFAnnotation(bounds: pdfSelection.bounds(for: page), forType: .highlight, withProperties: nil)
+            highlight.endLineStyle = .square
+            highlight.color = .yellow
+            page.addAnnotation(highlight)
+        }
+        if let page = pdfSelection.pages.first {
+            pdfView.go(to: page)
+        }
+        handlePageChange()
     }
 
     private func selectPage(with label: String) {

+ 2 - 1
iOSClient/Viewer/NCViewerPDF/NCViewerPDFSearch.swift

@@ -81,7 +81,8 @@ class NCViewerPDFSearch: UITableViewController, UISearchBarDelegate, PDFDocument
         // }
 
         let pdfPage = pdfSelection.pages.first
-        cell.pageNumberLabel.text = NSLocalizedString("_scan_document_pdf_page_", comment: "") + ": " + (pdfPage?.label ?? "")
+        let pageNumber = pdfPage?.pageRef?.pageNumber ?? 0
+        cell.pageNumberLabel.text = NSLocalizedString("_scan_document_pdf_page_", comment: "") + ": " + String(pageNumber)
 
         let extendSelection = pdfSelection.copy() as! PDFSelection
         extendSelection.extend(atStart: 10)