Browse Source

【2025】Home界面广告位模块处理

niehaoyu 5 months ago
parent
commit
8da1b7d4d3

+ 13 - 2
PDF Office/PDF Master/KMClass/KMHomeViewController/KMNHomeViewController.swift

@@ -6,22 +6,33 @@
 //
 
 import Cocoa
+import KMComponentLibrary
 
 class KMNHomeViewController: NSViewController {
 
+    @IBOutlet var leftContendBox: NSBox!
     @IBOutlet var homeOpenView: KMHomeOpenView!
-    
     @IBOutlet var homeRecommondView: KMHomeRecommondView!
     
+    
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do view setup here.
         
-        homeOpenView.delegate = self
+        
+        self.configLeftContendView()
         
         self.initAdvertisementData()
     }
     
+    func configLeftContendView() {
+        
+        leftContendBox.fillColor = ComponentLibrary.shared.getComponentColorFromKey("colorBg/layout-middle")
+        
+        homeOpenView.delegate = self
+        
+    }
+    
     func initAdvertisementData() {
         KMAdvertisementManager.manager.fetchDataWithResponseObject { [weak self] data, responseObject, error in
             KMPrint("获取广告数据成功")

+ 12 - 0
PDF Office/PDF Master/KMClass/KMHomeViewController/KMNHomeViewController.xib

@@ -10,6 +10,7 @@
             <connections>
                 <outlet property="homeOpenView" destination="Bxr-Ds-C57" id="DCS-RO-SoJ"/>
                 <outlet property="homeRecommondView" destination="SUk-pI-GKI" id="QLA-2x-bdU"/>
+                <outlet property="leftContendBox" destination="YQl-na-PHq" id="1OU-uy-3MI"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
             </connections>
         </customObject>
@@ -25,6 +26,13 @@
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="elb-1V-cgI">
                             <rect key="frame" x="0.0" y="0.0" width="240" height="469"/>
                             <subviews>
+                                <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="YQl-na-PHq">
+                                    <rect key="frame" x="0.0" y="0.0" width="240" height="469"/>
+                                    <view key="contentView" id="aZH-46-zgg">
+                                        <rect key="frame" x="0.0" y="0.0" width="240" height="469"/>
+                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                    </view>
+                                </box>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="Bxr-Ds-C57" customClass="KMHomeOpenView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                     <rect key="frame" x="16" y="345" width="208" height="92"/>
                                     <constraints>
@@ -40,10 +48,14 @@
                                 </customView>
                             </subviews>
                             <constraints>
+                                <constraint firstAttribute="trailing" secondItem="YQl-na-PHq" secondAttribute="trailing" id="482-mQ-OzQ"/>
                                 <constraint firstItem="Bxr-Ds-C57" firstAttribute="centerX" secondItem="elb-1V-cgI" secondAttribute="centerX" id="5oo-uK-JgL"/>
+                                <constraint firstItem="YQl-na-PHq" firstAttribute="top" secondItem="elb-1V-cgI" secondAttribute="top" id="Csr-Vz-Akl"/>
                                 <constraint firstAttribute="width" constant="240" id="GIp-bc-gJQ"/>
                                 <constraint firstItem="Bxr-Ds-C57" firstAttribute="top" secondItem="elb-1V-cgI" secondAttribute="top" constant="32" id="GfU-54-afy"/>
+                                <constraint firstAttribute="bottom" secondItem="YQl-na-PHq" secondAttribute="bottom" id="OrC-td-S9N"/>
                                 <constraint firstItem="SUk-pI-GKI" firstAttribute="centerX" secondItem="elb-1V-cgI" secondAttribute="centerX" id="aB5-Av-Nyq"/>
+                                <constraint firstItem="YQl-na-PHq" firstAttribute="leading" secondItem="elb-1V-cgI" secondAttribute="leading" id="kZn-o5-xaW"/>
                                 <constraint firstAttribute="bottom" secondItem="SUk-pI-GKI" secondAttribute="bottom" constant="16" id="p9Q-6E-3Bf"/>
                                 <constraint firstItem="SUk-pI-GKI" firstAttribute="top" secondItem="Bxr-Ds-C57" secondAttribute="bottom" constant="24" id="yLo-oH-mlQ"/>
                             </constraints>

+ 30 - 4
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRecommondView/KMHomeRecommondView.swift

@@ -19,6 +19,10 @@ class KMHomeRecommondView: BaseXibView {
     @IBOutlet var othersLabel: NSTextField!
     @IBOutlet var othersTopConst: NSLayoutConstraint!
     
+    @IBOutlet var adsView: NSView!
+    @IBOutlet var adsImageView: NSImageView!
+    @IBOutlet var adsCloseBtn: NSButton!
+    
     
     //MARK: - func
     override func draw(_ dirtyRect: NSRect) {
@@ -60,8 +64,9 @@ class KMHomeRecommondView: BaseXibView {
             othersTopConst.constant = 100
             
             var viewXValue: CGFloat = 0
+            
             for item: KMAdvertisementItemInfo in productContents {
-                var view = ComponentCSelector()
+                let view = ComponentCSelector()
                 view.frame = CGRectMake(viewXValue, 0, 43, 24)
                 productsBGView.addSubview(view)
                 viewXValue += 55
@@ -78,8 +83,9 @@ class KMHomeRecommondView: BaseXibView {
         if let productContents = others?.content {
             othersBGView.isHidden = false
             var viewYValue: CGFloat = CGRectGetHeight(othersBGView.frame) - 28 - 36
+            
             for item: KMAdvertisementItemInfo in productContents {
-                var view = ComponentNavBarItem()
+                let view = ComponentNavBarItem()
                 view.frame = CGRectMake(0, viewYValue, CGRectGetWidth(othersBGView.frame), 36)
                 view.autoresizingMask = [.width, .minYMargin]
                 othersBGView.addSubview(view)
@@ -89,11 +95,25 @@ class KMHomeRecommondView: BaseXibView {
                 view.setTarget(self, action: #selector(othersItemClick(_:)))
                 viewYValue -= 44
             }
+            
         } else {
             othersBGView.isHidden = true
         }
-        
-        
+         
+        if IAPProductsManager.default().isAvailableAllFunction() {
+            adsView.isHidden = true
+        } else {
+            adsView.isHidden = false
+            let adsData = KMAdvertisementManager.manager.info.advertisement?.content
+             guard let model = adsData?.first else {
+                adsView.isHidden = true
+                return
+            }
+            let url = URL(string: KMAdvertisementModelTransition.transitionImagePath(image: model.image, highlight: false))
+            self.adsImageView.image = KMAdvertisementImage.imageWithURL(url: url, completion: { [weak self] image in
+                self?.adsImageView.image = image
+            })
+        }
         
     }
     
@@ -119,4 +139,10 @@ class KMHomeRecommondView: BaseXibView {
             }
         }
     }
+    
+    @IBAction func closeAdsImageview(_ sender: Any) {
+        
+    }
+    
+    
 }

+ 26 - 4
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRecommondView/KMHomeRecommondView.xib

@@ -8,6 +8,9 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMHomeRecommondView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
+                <outlet property="adsCloseBtn" destination="GtZ-J5-weo" id="pFy-JB-xKO"/>
+                <outlet property="adsImageView" destination="PK4-eH-K8G" id="yfG-4j-FV4"/>
+                <outlet property="adsView" destination="ESC-nr-GbN" id="4BN-lz-CeP"/>
                 <outlet property="dividerView" destination="YRy-uF-FZ7" id="GMI-95-6WB"/>
                 <outlet property="othersBGView" destination="IJL-5u-vFu" id="mgG-fx-ICN"/>
                 <outlet property="othersLabel" destination="opO-9D-1D8" id="tlD-dq-C7a"/>
@@ -69,18 +72,34 @@
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="ESC-nr-GbN">
                             <rect key="frame" x="0.0" y="0.0" width="208" height="117"/>
                             <subviews>
-                                <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GtZ-J5-weo">
-                                    <rect key="frame" x="140" y="90" width="75" height="32"/>
-                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-                                    <buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="xJ8-sU-9Ro">
+                                <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="PK4-eH-K8G">
+                                    <rect key="frame" x="0.0" y="0.0" width="208" height="117"/>
+                                    <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="f9F-42-U0L"/>
+                                </imageView>
+                                <button translatesAutoresizingMaskIntoConstraints="NO" id="GtZ-J5-weo">
+                                    <rect key="frame" x="186" y="95" width="16" height="16"/>
+                                    <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="ads_closeBtn" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="xJ8-sU-9Ro">
                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                         <font key="font" metaFont="system"/>
                                     </buttonCell>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="16" id="8EI-t2-p8D"/>
+                                        <constraint firstAttribute="width" constant="16" id="9NB-en-h0U"/>
+                                    </constraints>
+                                    <connections>
+                                        <action selector="closeAdsImageview:" target="-2" id="2Rp-Zz-ysl"/>
+                                    </connections>
                                 </button>
                             </subviews>
                             <constraints>
+                                <constraint firstAttribute="trailing" secondItem="PK4-eH-K8G" secondAttribute="trailing" id="3cu-Xp-DQx"/>
+                                <constraint firstItem="GtZ-J5-weo" firstAttribute="top" secondItem="ESC-nr-GbN" secondAttribute="top" constant="6" id="95J-G2-ffA"/>
+                                <constraint firstAttribute="bottom" secondItem="PK4-eH-K8G" secondAttribute="bottom" id="9s4-xM-QAo"/>
+                                <constraint firstItem="PK4-eH-K8G" firstAttribute="top" secondItem="ESC-nr-GbN" secondAttribute="top" id="Dti-ct-XvM"/>
                                 <constraint firstAttribute="width" constant="208" id="kfG-1F-rqI"/>
+                                <constraint firstItem="PK4-eH-K8G" firstAttribute="leading" secondItem="ESC-nr-GbN" secondAttribute="leading" id="mfZ-hB-sdH"/>
                                 <constraint firstAttribute="height" constant="117" id="pwC-8G-4Yk"/>
+                                <constraint firstAttribute="trailing" secondItem="GtZ-J5-weo" secondAttribute="trailing" constant="6" id="xs0-Cl-A4Y"/>
                             </constraints>
                         </customView>
                     </subviews>
@@ -109,4 +128,7 @@
             <point key="canvasLocation" x="-73" y="266.5"/>
         </customView>
     </objects>
+    <resources>
+        <image name="ads_closeBtn" width="18" height="18"/>
+    </resources>
 </document>

+ 12 - 0
PDF Office/PDF Master/KMClass/KMHomeViewController/home.xcassets/ads_closeBtn.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "ads_closeBtn.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
PDF Office/PDF Master/KMClass/KMHomeViewController/home.xcassets/ads_closeBtn.imageset/ads_closeBtn.pdf