瀏覽代碼

【2025】【综合】侧边栏按钮完善,阅读模式页码提示完善

niehaoyu 3 周之前
父節點
當前提交
74042b6933

+ 6 - 2
PDF Office/KMComponentLibrary/KMComponentLibrary/View/SideBar/SideBarItem/PageTurner/ComponentSidebarPageTurner.swift

@@ -53,8 +53,8 @@ public class ComponentSidebarPageTurner: ComponentBaseXibView {
     var lastPageProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, state: .normal, onlyIcon: true, keepPressState: false)
     
     var sepDividerProperty: ComponentDividerProperty = ComponentDividerProperty(type: .horizontal, dash: false)
-    var previousProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, state: .normal, onlyIcon: true, keepPressState: false)
-    var nextProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, state: .normal, onlyIcon: true, keepPressState: false)
+    public var previousProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, state: .normal, onlyIcon: true, keepPressState: false)
+    public var nextProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, state: .normal, onlyIcon: true, keepPressState: false)
     
     weak open var delegate: ComponentSidebarDelegate?
     
@@ -218,6 +218,10 @@ public class ComponentSidebarPageTurner: ComponentBaseXibView {
         lastPageProperty.state = .normal
         lastPageButton.reloadData()
         
+        previousButton.reloadData()
+        
+        nextButton.reloadData()
+        
     }
     
     private func actionFinish() {

+ 7 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -1360,7 +1360,13 @@ struct KMNMWCFlags {
         if pageNumberToolbar == nil {
             pageNumberToolbar = KMPageNumberPromptView.init()
         }
-        pageNumberToolbar?.frame = CGRectMake(CGRectGetWidth(listView.frame)/2-144, 20, 288, 40)
+        if viewManager.isPDFReadMode {
+            pageNumberToolbar?.frame = CGRectMake(CGRectGetWidth(listView.frame)/2-366/2, 20, 366, 40)
+            pageNumberToolbar?.hideBackForwordButton(false)
+        } else {
+            pageNumberToolbar?.frame = CGRectMake(CGRectGetWidth(listView.frame)/2-288/2, 20, 288, 40)
+            pageNumberToolbar?.hideBackForwordButton(true)
+        }
         pageNumberToolbar?.autoresizingMask = [.minXMargin, .maxXMargin, .maxYMargin]
         pageNumberToolbar?.pdfView = self.listView
         pageNumberToolbar?.reloadData()

+ 37 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/KMNDisplayViewController/Toolbar/KMPageNumberPromptView.swift

@@ -11,6 +11,11 @@ import KMComponentLibrary
 class KMPageNumberPromptView: BaseXibView {
     
     @IBOutlet var contendView: NSView!
+    
+    @IBOutlet var backButton: ComponentButton!
+    @IBOutlet var forwordButton: ComponentButton!
+    @IBOutlet var forwordDivider: ComponentDivider!
+     
     @IBOutlet var paginationView: ComponentPagination!
     @IBOutlet var dividerView: ComponentDivider!
     @IBOutlet var selectView: ComponentSelect!
@@ -53,8 +58,22 @@ class KMPageNumberPromptView: BaseXibView {
 
     }
     
+    func hideBackForwordButton(_ hidden: Bool) {
+        self.backButton.isHidden = hidden
+        self.forwordButton.isHidden = hidden
+        self.forwordDivider.isHidden = hidden
+        
+    }
+    
     func setupProperty() {
+        backButton.properties = ComponentButtonProperty(type: .text_gray_opacity, size: .xxs, onlyIcon: true, icon: ComponentLibrary.shared.image(forResource: "sider_Pervious"), keepPressState: false)
+        backButton.setTarget(self, action: #selector(backButtonClicked))
+        
+        forwordButton.properties = ComponentButtonProperty(type: .text_gray_opacity, size: .xxs, onlyIcon: true, icon: ComponentLibrary.shared.image(forResource: "sider_Next"), keepPressState: false)
+        forwordButton.setTarget(self, action: #selector(forwordButtonClicked))
         
+        forwordDivider.properties = ComponentDividerProperty(type: .vertical, dash: false)
+ 
         paginationView.properties = ComponentPaginationProperty(doubleArrow_show: false, currentIndex: 0, totalCount: 1)
         paginationView.delegate = self
         
@@ -69,6 +88,12 @@ class KMPageNumberPromptView: BaseXibView {
         selectView.updateMenuItemsArr(KMPDFToolbarConfig.scaleZoomItems())
         
         if let pdfview = self.pdfView, let document = pdfview.document {
+            backButton.properties.isDisabled = pdfview.km_canGoBack() ? false : true
+            backButton.reloadData()
+            
+            forwordButton.properties.isDisabled = pdfview.km_canGoForward() ? false : true
+            forwordButton.reloadData()
+             
             let curIndex = Int(pdfview.currentPageIndex) + 1
             paginationView.properties.currentIndex = curIndex
             paginationView.properties.totalCount = Int(document.pageCount)
@@ -79,6 +104,18 @@ class KMPageNumberPromptView: BaseXibView {
         }
     }
      
+    //MARK: - Action
+    func backButtonClicked() {
+        self.pdfView?.km_goBack(NSButton())
+        
+        self.reloadData()
+    }
+    
+    func forwordButtonClicked() {
+        self.pdfView?.km_goForward(NSButton())
+        
+        self.reloadData()
+    }
 }
 
 

+ 36 - 6
PDF Office/PDF Master/KMClass/KMPDFViewController/KMNDisplayViewController/Toolbar/KMPageNumberPromptView.xib

@@ -8,8 +8,11 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMPageNumberPromptView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
+                <outlet property="backButton" destination="GTh-Xu-pNj" id="Hzg-KU-VZD"/>
                 <outlet property="contendView" destination="hyv-yT-G6z" id="MXQ-o8-RqX"/>
                 <outlet property="dividerView" destination="Gb3-Ja-qzt" id="k2y-7J-RtZ"/>
+                <outlet property="forwordButton" destination="Tgc-p3-sgf" id="NRP-wJ-d3c"/>
+                <outlet property="forwordDivider" destination="hVI-Ss-mI4" id="R1W-tC-DUH"/>
                 <outlet property="paginationView" destination="eNq-VW-By6" id="Lzd-6z-ulM"/>
                 <outlet property="selectView" destination="KzC-V3-ova" id="gLo-kU-gZw"/>
             </connections>
@@ -17,28 +20,49 @@
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView id="c22-O7-iKe">
-            <rect key="frame" x="0.0" y="0.0" width="288" height="40"/>
+            <rect key="frame" x="0.0" y="0.0" width="368" height="40"/>
             <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
             <subviews>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="hyv-yT-G6z">
-                    <rect key="frame" x="0.0" y="0.0" width="288" height="40"/>
+                    <rect key="frame" x="0.0" y="0.0" width="368" height="40"/>
                     <subviews>
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="GTh-Xu-pNj" customClass="ComponentButton" customModule="KMComponentLibrary">
+                            <rect key="frame" x="8" y="8" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="24" id="hXM-80-kBY"/>
+                                <constraint firstAttribute="width" constant="24" id="iDG-Sg-UPf"/>
+                            </constraints>
+                        </customView>
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="Tgc-p3-sgf" customClass="ComponentButton" customModule="KMComponentLibrary">
+                            <rect key="frame" x="40" y="8" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="JIj-CW-qtM"/>
+                                <constraint firstAttribute="height" constant="24" id="cVo-wl-YyS"/>
+                            </constraints>
+                        </customView>
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="hVI-Ss-mI4" customClass="ComponentDivider" customModule="KMComponentLibrary">
+                            <rect key="frame" x="68" y="12" width="16" height="16"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="16" id="JOz-bh-Ncd"/>
+                                <constraint firstAttribute="width" constant="16" id="bZC-jx-YnO"/>
+                            </constraints>
+                        </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="eNq-VW-By6" customClass="ComponentPagination" customModule="KMComponentLibrary">
-                            <rect key="frame" x="8" y="8" width="165" height="24"/>
+                            <rect key="frame" x="88" y="8" width="165" height="24"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="24" id="Dnu-bu-DfT"/>
                                 <constraint firstAttribute="width" constant="165" id="yh9-fP-low"/>
                             </constraints>
                         </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="Gb3-Ja-qzt" customClass="ComponentDivider" customModule="KMComponentLibrary">
-                            <rect key="frame" x="177" y="12" width="16" height="16"/>
+                            <rect key="frame" x="257" y="12" width="16" height="16"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="16" id="Lt6-NU-RKs"/>
                                 <constraint firstAttribute="width" constant="16" id="ZTN-7M-GAO"/>
                             </constraints>
                         </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="KzC-V3-ova" customClass="ComponentSelect" customModule="KMComponentLibrary">
-                            <rect key="frame" x="197" y="8" width="83" height="24"/>
+                            <rect key="frame" x="277" y="8" width="83" height="24"/>
                             <constraints>
                                 <constraint firstAttribute="width" constant="83" id="JT0-6y-lxq"/>
                                 <constraint firstAttribute="height" constant="24" id="fCT-6n-tjj"/>
@@ -46,11 +70,17 @@
                         </customView>
                     </subviews>
                     <constraints>
-                        <constraint firstItem="eNq-VW-By6" firstAttribute="leading" secondItem="hyv-yT-G6z" secondAttribute="leading" constant="8" id="70Z-LC-aze"/>
                         <constraint firstItem="Gb3-Ja-qzt" firstAttribute="leading" secondItem="eNq-VW-By6" secondAttribute="trailing" constant="4" id="8E6-J8-9Bw"/>
+                        <constraint firstItem="GTh-Xu-pNj" firstAttribute="centerY" secondItem="hyv-yT-G6z" secondAttribute="centerY" id="Aps-MD-nw3"/>
+                        <constraint firstItem="GTh-Xu-pNj" firstAttribute="leading" secondItem="hyv-yT-G6z" secondAttribute="leading" constant="8" id="C1n-gp-rPu"/>
                         <constraint firstItem="Gb3-Ja-qzt" firstAttribute="centerY" secondItem="hyv-yT-G6z" secondAttribute="centerY" id="Nqt-ka-Qgt"/>
+                        <constraint firstItem="hVI-Ss-mI4" firstAttribute="centerY" secondItem="hyv-yT-G6z" secondAttribute="centerY" id="QnN-Ji-SrP"/>
                         <constraint firstItem="KzC-V3-ova" firstAttribute="leading" secondItem="Gb3-Ja-qzt" secondAttribute="trailing" constant="4" id="atL-Nz-KEc"/>
                         <constraint firstItem="eNq-VW-By6" firstAttribute="centerY" secondItem="hyv-yT-G6z" secondAttribute="centerY" id="bPx-91-kab"/>
+                        <constraint firstItem="hVI-Ss-mI4" firstAttribute="leading" secondItem="Tgc-p3-sgf" secondAttribute="trailing" constant="4" id="dBr-o9-2s0"/>
+                        <constraint firstAttribute="trailing" secondItem="KzC-V3-ova" secondAttribute="trailing" constant="8" id="k9m-Ba-otb"/>
+                        <constraint firstItem="Tgc-p3-sgf" firstAttribute="centerY" secondItem="hyv-yT-G6z" secondAttribute="centerY" id="rb5-kT-H0D"/>
+                        <constraint firstItem="Tgc-p3-sgf" firstAttribute="leading" secondItem="GTh-Xu-pNj" secondAttribute="trailing" constant="8" id="vuZ-DT-ARX"/>
                         <constraint firstItem="KzC-V3-ova" firstAttribute="centerY" secondItem="hyv-yT-G6z" secondAttribute="centerY" id="wHx-s6-Ju7"/>
                     </constraints>
                 </customView>

+ 10 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/SideBar/KMPDFSideBarController.swift

@@ -44,8 +44,8 @@ class KMPDFSideBarController: NSViewController {
 
     let firstPageProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "first_vertical"), righticon: nil, text: KMLocalizedString("First Page"))
     let lastPageProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "last_vertical"), righticon: nil, text: KMLocalizedString("Last Page"))
-    let previouseProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "arrow_left"), righticon: nil, text: KMLocalizedString("Previous Page"))
-    let nextProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "arrow_right"), righticon: nil, text: KMLocalizedString("Next Page"))
+    let previouseProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "arrow_left"), righticon: nil, text: KMLocalizedString("Forward"))
+    let nextProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "arrow_right"), righticon: nil, text: KMLocalizedString("Back"))
     
     private var groupView: ComponentGroup!
     
@@ -179,6 +179,10 @@ class KMPDFSideBarController: NSViewController {
         let curIndex = Int(pdfview.currentPageIndex) + 1
         pageTurnerView.properties.currentIndex = curIndex
         pageTurnerView.properties.totalCount = Int(pdfview.document.pageCount)
+        
+        pageTurnerView.previousProperty.isDisabled = pdfview.km_canGoBack() ? false : true
+        pageTurnerView.nextProperty.isDisabled = pdfview.km_canGoForward() ? false : true
+        
         pageTurnerView.reloadData()
     }
     
@@ -305,11 +309,15 @@ extension KMPDFSideBarController: ComponentSidebarDelegate {
     }
     
     func componentSidebarPageTurnerDidPreviousButtonClicked(pageTurner: ComponentSidebarPageTurner) {
+        self.pdfView?.km_goBack(NSButton())
         
+        reloadData()
     }
     
     func componentSidebarPageTurnerDidNextButtonClicked(pageTurner: ComponentSidebarPageTurner) {
+        self.pdfView?.km_goForward(NSButton())
         
+        reloadData()
     }
     
 }