Browse Source

【2025】【批量】文件列表UI调整

lizhe 2 months ago
parent
commit
85d12ce1ac

+ 9 - 9
PDF Office/PDF Master/KMClass/ImageToPDF/Base/KMBatchOperateLeftViewController.xib

@@ -32,7 +32,7 @@
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="yD5-qe-EWK">
-                    <rect key="frame" x="0.0" y="446" width="718" height="64"/>
+                    <rect key="frame" x="0.0" y="496" width="718" height="64"/>
                     <subviews>
                         <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0F7-Ym-8wO">
                             <rect key="frame" x="662" y="12" width="32" height="32"/>
@@ -69,13 +69,13 @@
                     </constraints>
                 </customView>
                 <scrollView autohidesScrollers="YES" horizontalLineScroll="17" horizontalPageScroll="10" verticalLineScroll="17" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cSo-1J-C87">
-                    <rect key="frame" x="24" y="0.0" width="670" height="446"/>
-                    <clipView key="contentView" id="5QZ-3D-5sN">
-                        <rect key="frame" x="1" y="1" width="668" height="429"/>
+                    <rect key="frame" x="24" y="0.0" width="670" height="496"/>
+                    <clipView key="contentView" ambiguous="YES" id="5QZ-3D-5sN">
+                        <rect key="frame" x="1" y="1" width="668" height="479"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="plain" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="Mlr-rw-6rm" viewBased="YES" id="iqp-fI-b2v" customClass="KMTableView" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                                <rect key="frame" x="0.0" y="0.0" width="847" height="404"/>
+                            <tableView verticalHuggingPriority="750" ambiguous="YES" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="plain" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="Mlr-rw-6rm" viewBased="YES" id="iqp-fI-b2v" customClass="KMTableView" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                <rect key="frame" x="0.0" y="0.0" width="847" height="454"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 <color key="gridColor" red="1" green="0.64784158279075421" blue="0.26014074763814632" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -230,7 +230,7 @@
                         <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="670" id="LUW-2r-W1h"/>
                     </constraints>
                     <scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="RBU-7C-fCt">
-                        <rect key="frame" x="1" y="430" width="668" height="15"/>
+                        <rect key="frame" x="1" y="480" width="668" height="15"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </scroller>
                     <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="32b-Um-caF">
@@ -243,10 +243,10 @@
                     </tableHeaderView>
                 </scrollView>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="G6v-if-4fr" customClass="KMBlankView" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                    <rect key="frame" x="0.0" y="0.0" width="718" height="446"/>
+                    <rect key="frame" x="0.0" y="0.0" width="718" height="496"/>
                     <subviews>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="9GJ-Lf-bRA">
-                            <rect key="frame" x="222" y="128" width="275" height="190"/>
+                            <rect key="frame" x="222" y="153" width="275" height="190"/>
                             <subviews>
                                 <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="aT2-4b-2xG">
                                     <rect key="frame" x="67" y="50" width="140" height="140"/>

+ 76 - 14
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/KMBatchProcessingView.swift

@@ -11,8 +11,13 @@ import KMComponentLibrary
 class KMBatchProcessingView: BaseXibView {
     @IBOutlet weak var tableView: KMBatchProcessingTableView!
     @IBOutlet weak var selectedFilesView: KMBatchSelectedFilesView!
-    @IBOutlet weak var addFilesButton: ComponentDropdownTool!
+//    @IBOutlet weak var addFilesButton: ComponentDropdownTool!
     @IBOutlet weak var deleteButton: ComponentButton!
+    @IBOutlet weak var addFilesButton: ComponentButton!
+    @IBOutlet weak var addFilesMoreButton: ComponentButton!
+    @IBOutlet weak var lineView: NSView!
+    
+    var groupView: ComponentGroup?
     
     weak var delegate: KMBatchProcessingViewDelegate?
     var inputType: KMBatchCollectionViewType? {
@@ -40,19 +45,33 @@ class KMBatchProcessingView: BaseXibView {
     }
     
     override func setup() {
+        
+        self.backgroundColor(ComponentLibrary.shared.getComponentColorFromKey("colorBg/layout-low"))
         self.border(ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider"), 0.5, 0)
+        self.lineView.backgroundColor(ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider"))
         
-        self.addFilesButton.properties = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Add Files..."), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
-        self.addFilesButton.delegate = self
         
-        let items = ["Add Files", "Add Folder", "Add Open Files"]
-        var menuItemArr: [ComponentMenuitemProperty] = []
-        for item in items {
-            let menuItem = ComponentMenuitemProperty(type: .normal, text: KMLocalizedString(item, comment: ""), identifier: "")
-            menuItemArr.append(menuItem)
-        }
-        self.addFilesButton.properties.menuItemArr = menuItemArr
-        self.addFilesButton.reloadData()
+        let properties = ComponentButtonProperty()
+        properties.type = .gray
+        properties.size = .s
+        properties.buttonText = KMLocalizedString("Add Files...")
+        addFilesButton.properties = properties
+        properties.propertyInfo.cornerRadius_topRight = 0
+        properties.propertyInfo.cornerRadius_bottomRight = 0
+        addFilesButton.reloadData()
+        addFilesButton.setTarget(self, action: #selector(addFileAction))
+        
+        let properties2 = ComponentButtonProperty()
+        properties2.type = .gray
+        properties2.size = .s
+        properties2.onlyIcon = true
+        properties2.icon = NSImage(named: "KMImageNameImageToPDFDropdown")
+        addFilesMoreButton.properties = properties2
+        properties2.propertyInfo.cornerRadius_topLeft = 0
+        properties2.propertyInfo.cornerRadius_bottomLeft = 0
+        addFilesMoreButton.reloadData()
+        addFilesMoreButton.setTarget(self, action: #selector(addFileAction))
+        
         
         
         self.deleteButton.properties = ComponentButtonProperty(type: .default_tertiary,
@@ -81,13 +100,44 @@ class KMBatchProcessingView: BaseXibView {
         if (self.tableView.data != nil) && self.tableView.data!.count != 0 {
             self.selectedFilesView.isHidden = true
             self.tableView.isHidden = false
+            self.lineView.isHidden = false
         } else {
             self.selectedFilesView.isHidden = false
             self.tableView.isHidden = true
+            self.lineView.isHidden = true
         }
         
         self.tableView.reloadData()
     }
+    
+    func showGroupView() {
+        
+        var viewHeight: CGFloat = 8
+        var menuItemArr: [ComponentMenuitemProperty] = []
+        for i in ["Add Files", "Add Folder"] {
+            let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
+                                                                                               itemSelected: false,
+                                                                                               isDisabled: false,
+                                                                                               keyEquivalent: nil,
+                                                                                               text: KMLocalizedString(i))
+            menuItemArr.append(properties_Menuitem)
+            viewHeight += 36
+        }
+        
+        if groupView == nil {
+            groupView = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
+        }
+        groupView?.groupDelegate = self
+        groupView?.frame = CGRectMake(310, 0, 200, viewHeight)
+        groupView?.updateGroupInfo(menuItemArr)
+        
+        var point = addFilesButton.convert(addFilesButton.frame.origin, to: nil)
+        point.y -= viewHeight
+        groupView?.showWithPoint(point, relativeTo: addFilesButton)
+        
+//        addFileButton_?.properties.state = .pressed
+//        addFileButton_?.reloadData()
+    }
 }
 
 
@@ -107,6 +157,10 @@ extension KMBatchProcessingView: KMBatchProcessingViewAction {
         self.reloadData()
     }
     
+    func addFileAction() {
+        self.showGroupView()
+    }
+    
     func addFiles() {
         KMBatchProcessingView.openfiles(window: window!) { [unowned self] openPanel in
             if self.inputType == .OCR {
@@ -234,9 +288,9 @@ protocol KMBatchProcessingViewDelegate: NSObject {
     func reloadData(data: [KMBatchProcessingTableViewModel])
 }
 
-extension KMBatchProcessingView: ComponentDropdownToolDelegate {
-    func componentDropdownToolDidClicked(_ view: ComponentDropdownTool, menuItem: ComponentMenuitemProperty?) {
-        let familyString = menuItem?.text
+extension KMBatchProcessingView: ComponentGroupDelegate {
+    func componentGroupDidSelect(group: ComponentGroup?, menuItemProperty: ComponentMenuitemProperty?) {
+        let familyString = menuItemProperty?.text
         
         if familyString == KMLocalizedString("Add Files", comment: "") {
             self.addFiles()
@@ -246,4 +300,12 @@ extension KMBatchProcessingView: ComponentDropdownToolDelegate {
             self.addOpenFiles()
         }
     }
+    
+    func componentGroupDidDismiss(group: ComponentGroup?) {
+        self.addFilesButton.properties.state = .normal
+        self.addFilesMoreButton.properties.state = .normal
+        
+        self.addFilesButton.reloadData()
+        self.addFilesMoreButton.reloadData()
+    }
 }

+ 42 - 10
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/KMBatchProcessingView.xib

@@ -8,9 +8,11 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMBatchProcessingView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
-                <outlet property="addFilesButton" destination="xeT-vH-I6z" id="P7H-n4-sgp"/>
+                <outlet property="addFilesButton" destination="wII-w3-XMz" id="xrD-yx-714"/>
+                <outlet property="addFilesMoreButton" destination="Han-zq-wgu" id="zjb-Xt-6I6"/>
                 <outlet property="contentView" destination="c22-O7-iKe" id="Fy0-yD-EFd"/>
                 <outlet property="deleteButton" destination="Wzb-X4-fBh" id="pJS-40-r2o"/>
+                <outlet property="lineView" destination="Wzh-FD-bFw" id="gbc-yr-3ME"/>
                 <outlet property="selectedFilesView" destination="Btb-75-0Y1" id="UsJ-q1-h2h"/>
                 <outlet property="tableView" destination="OMY-wn-4ox" id="fPx-xC-NN0"/>
             </connections>
@@ -36,13 +38,6 @@
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="0fj-Mr-qTR">
                                     <rect key="frame" x="24" y="0.0" width="584" height="54"/>
                                     <subviews>
-                                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="xeT-vH-I6z" customClass="ComponentDropdownTool" customModule="KMComponentLibrary">
-                                            <rect key="frame" x="0.0" y="11" width="129" height="32"/>
-                                            <constraints>
-                                                <constraint firstAttribute="width" constant="129" id="BUM-L1-2BR"/>
-                                                <constraint firstAttribute="height" constant="32" id="TwA-k0-enb"/>
-                                            </constraints>
-                                        </customView>
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="Wzb-X4-fBh" customClass="ComponentButton" customModule="KMComponentLibrary">
                                             <rect key="frame" x="552" y="11" width="32" height="32"/>
                                             <constraints>
@@ -50,12 +45,49 @@
                                                 <constraint firstAttribute="height" constant="32" id="VrI-ne-0XQ"/>
                                             </constraints>
                                         </customView>
+                                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="Kmj-4I-oid">
+                                            <rect key="frame" x="0.0" y="11" width="129" height="32"/>
+                                            <subviews>
+                                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="wII-w3-XMz" customClass="ComponentButton" customModule="KMComponentLibrary">
+                                                    <rect key="frame" x="0.0" y="0.0" width="97" height="32"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" constant="97" id="v0Q-ut-oBd"/>
+                                                    </constraints>
+                                                </customView>
+                                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="Han-zq-wgu" customClass="ComponentButton" customModule="KMComponentLibrary">
+                                                    <rect key="frame" x="97" y="0.0" width="32" height="32"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="32" id="IcW-FN-eEc"/>
+                                                        <constraint firstAttribute="width" constant="32" id="mce-Iz-6Ne"/>
+                                                    </constraints>
+                                                </customView>
+                                            </subviews>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="32" id="Apu-eH-4dE"/>
+                                                <constraint firstAttribute="trailing" secondItem="Han-zq-wgu" secondAttribute="trailing" id="Qj8-UF-NN5"/>
+                                                <constraint firstAttribute="width" constant="129" id="SSg-Xg-oFt"/>
+                                                <constraint firstAttribute="bottom" secondItem="wII-w3-XMz" secondAttribute="bottom" id="ahc-3a-WeD"/>
+                                                <constraint firstItem="wII-w3-XMz" firstAttribute="leading" secondItem="Kmj-4I-oid" secondAttribute="leading" id="edY-ur-qh2"/>
+                                                <constraint firstItem="wII-w3-XMz" firstAttribute="top" secondItem="Kmj-4I-oid" secondAttribute="top" id="jj2-Y5-RSw"/>
+                                                <constraint firstAttribute="bottom" secondItem="Han-zq-wgu" secondAttribute="bottom" id="owu-qa-YdL"/>
+                                                <constraint firstItem="Han-zq-wgu" firstAttribute="top" secondItem="Kmj-4I-oid" secondAttribute="top" id="wQI-Ge-eVX"/>
+                                            </constraints>
+                                        </customView>
+                                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="Wzh-FD-bFw">
+                                            <rect key="frame" x="0.0" y="0.0" width="584" height="1"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="0.5" id="E6w-3Z-U2h"/>
+                                            </constraints>
+                                        </customView>
                                     </subviews>
                                     <constraints>
-                                        <constraint firstItem="xeT-vH-I6z" firstAttribute="centerY" secondItem="0fj-Mr-qTR" secondAttribute="centerY" id="4yc-fg-tWt"/>
                                         <constraint firstItem="Wzb-X4-fBh" firstAttribute="centerY" secondItem="0fj-Mr-qTR" secondAttribute="centerY" id="9HJ-oq-9dz"/>
                                         <constraint firstAttribute="trailing" secondItem="Wzb-X4-fBh" secondAttribute="trailing" id="PS8-hu-u5Y"/>
-                                        <constraint firstItem="xeT-vH-I6z" firstAttribute="leading" secondItem="0fj-Mr-qTR" secondAttribute="leading" id="cVy-w2-bbf"/>
+                                        <constraint firstItem="Kmj-4I-oid" firstAttribute="centerY" secondItem="0fj-Mr-qTR" secondAttribute="centerY" id="S1i-7w-WUv"/>
+                                        <constraint firstItem="Kmj-4I-oid" firstAttribute="leading" secondItem="0fj-Mr-qTR" secondAttribute="leading" id="U3d-KJ-PSW"/>
+                                        <constraint firstAttribute="bottom" secondItem="Wzh-FD-bFw" secondAttribute="bottom" id="eQd-ct-RVh"/>
+                                        <constraint firstItem="Wzh-FD-bFw" firstAttribute="leading" secondItem="0fj-Mr-qTR" secondAttribute="leading" id="jsK-v7-gtX"/>
+                                        <constraint firstAttribute="trailing" secondItem="Wzh-FD-bFw" secondAttribute="trailing" id="nQW-Sj-tbh"/>
                                     </constraints>
                                 </customView>
                             </subviews>

+ 26 - 4
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/Views/Tableview/Views/KMBatchProcessingColumnHeaderCell.swift

@@ -15,6 +15,7 @@ class KMBatchProcessingColumnHeaderCell: NSTableHeaderCell {
     override func draw(withFrame cellFrame: NSRect, in controlView: NSView) {
         super.draw(withFrame: cellFrame, in: controlView)
         
+        // 自定义绘制外框和竖线
         self.draw(frame: cellFrame, highlight: false)
     }
     
@@ -23,10 +24,32 @@ class KMBatchProcessingColumnHeaderCell: NSTableHeaderCell {
     }
     
     func draw(frame: CGRect, highlight: Bool) {
-        ComponentLibrary.shared.backgroundColor(forToken: "colorFill/4")?.withAlphaComponent(1).setFill()
-        let path = NSBezierPath(roundedRect: frame, xRadius: 0, yRadius: 0)
-        path.fill()
+        // 填充背景颜色
+        ComponentLibrary.shared.getComponentColorFromKey("colorFill/4").setFill()
+        let backgroundPath = NSBezierPath(roundedRect: frame, xRadius: 0, yRadius: 0)
+        backgroundPath.fill()
         
+//        // 绘制外框
+//        let borderColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider")
+//        borderColor.setStroke()
+//        let borderPath = NSBezierPath(rect: frame)
+//        borderPath.lineWidth = 0.5
+//        borderPath.stroke()
+        
+        // 绘制每栏中间的竖线
+        let separatorColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider")
+        separatorColor.setStroke()
+        let separatorPath = NSBezierPath()
+        separatorPath.lineWidth = 0.5
+        
+//         在frame宽度范围内绘制竖线
+        for x in stride(from: frame.minX, to: frame.maxX, by: frame.width) { // 100 为每栏的宽度,可以根据需要调整
+            separatorPath.move(to: CGPoint(x: x, y: frame.minY + 4))
+            separatorPath.line(to: CGPoint(x: x, y: frame.maxY - 4))
+        }
+        separatorPath.stroke()
+        
+        // 绘制单元格内容
         self.drawInterior(withFrame: frame, in: controlView ?? NSView())
     }
     
@@ -38,7 +61,6 @@ class KMBatchProcessingColumnHeaderCell: NSTableHeaderCell {
         let attributes = [NSAttributedString.Key.foregroundColor: ComponentLibrary.shared.getComponentColorFromKey("colorText/1"),
                           NSAttributedString.Key.font: ComponentLibrary.shared.font(forToken: "mac/body-s-medium")]
         
-        
         let attributedString = NSAttributedString(string: self.attributedStringValue.string, attributes: attributes)
         attributedString.draw(in: titleRect)
     }