소스 검색

【订阅】错误提示弹窗添加

lizhe 1 년 전
부모
커밋
0d3119308e

+ 24 - 0
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -1841,6 +1841,12 @@
 		ADD272D429B9CFE20032B5D6 /* KMLightNoNetworkView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADD272D329B9CFE20032B5D6 /* KMLightNoNetworkView.xib */; };
 		ADD272D529B9CFE20032B5D6 /* KMLightNoNetworkView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADD272D329B9CFE20032B5D6 /* KMLightNoNetworkView.xib */; };
 		ADD272D629B9CFE20032B5D6 /* KMLightNoNetworkView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADD272D329B9CFE20032B5D6 /* KMLightNoNetworkView.xib */; };
+		ADD5AE552A64D31200C14249 /* KMPurchaseAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD5AE542A64D31200C14249 /* KMPurchaseAlertView.swift */; };
+		ADD5AE562A64D31200C14249 /* KMPurchaseAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD5AE542A64D31200C14249 /* KMPurchaseAlertView.swift */; };
+		ADD5AE572A64D31200C14249 /* KMPurchaseAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD5AE542A64D31200C14249 /* KMPurchaseAlertView.swift */; };
+		ADD5AE592A64DD2600C14249 /* KMPurchaseAlertView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADD5AE582A64DD2600C14249 /* KMPurchaseAlertView.xib */; };
+		ADD5AE5A2A64DD2600C14249 /* KMPurchaseAlertView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADD5AE582A64DD2600C14249 /* KMPurchaseAlertView.xib */; };
+		ADD5AE5B2A64DD2600C14249 /* KMPurchaseAlertView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADD5AE582A64DD2600C14249 /* KMPurchaseAlertView.xib */; };
 		ADE3C19F29A3894900793B13 /* KMSearchTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE3C19E29A3894900793B13 /* KMSearchTableRowView.swift */; };
 		ADE3C1A029A3894900793B13 /* KMSearchTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE3C19E29A3894900793B13 /* KMSearchTableRowView.swift */; };
 		ADE3C1A129A3894900793B13 /* KMSearchTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE3C19E29A3894900793B13 /* KMSearchTableRowView.swift */; };
@@ -4270,6 +4276,8 @@
 		ADD1B70929471FA500C3FFF7 /* KMPrintChoosePresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPrintChoosePresenter.swift; sourceTree = "<group>"; };
 		ADD272CF29B9CFD30032B5D6 /* KMLightNoNetworkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMLightNoNetworkView.swift; sourceTree = "<group>"; };
 		ADD272D329B9CFE20032B5D6 /* KMLightNoNetworkView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMLightNoNetworkView.xib; sourceTree = "<group>"; };
+		ADD5AE542A64D31200C14249 /* KMPurchaseAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPurchaseAlertView.swift; sourceTree = "<group>"; };
+		ADD5AE582A64DD2600C14249 /* KMPurchaseAlertView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMPurchaseAlertView.xib; sourceTree = "<group>"; };
 		ADE3C19E29A3894900793B13 /* KMSearchTableRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMSearchTableRowView.swift; sourceTree = "<group>"; };
 		ADE3C1A929A4779E00793B13 /* KMPrintAccessoryController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPrintAccessoryController.swift; sourceTree = "<group>"; };
 		ADE3C1AA29A4779E00793B13 /* KMPrintAccessoryController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMPrintAccessoryController.xib; sourceTree = "<group>"; };
@@ -6303,6 +6311,7 @@
 		AD53B70129ACC63D00D61E81 /* Tools */ = {
 			isa = PBXGroup;
 			children = (
+				ADD5AE532A64D29600C14249 /* Alert */,
 				AD53B70229ACC64300D61E81 /* Email */,
 			);
 			path = Tools;
@@ -7342,6 +7351,15 @@
 			path = TextField;
 			sourceTree = "<group>";
 		};
+		ADD5AE532A64D29600C14249 /* Alert */ = {
+			isa = PBXGroup;
+			children = (
+				ADD5AE542A64D31200C14249 /* KMPurchaseAlertView.swift */,
+				ADD5AE582A64DD2600C14249 /* KMPurchaseAlertView.xib */,
+			);
+			path = Alert;
+			sourceTree = "<group>";
+		};
 		ADE3C1A729A3A05400793B13 /* View */ = {
 			isa = PBXGroup;
 			children = (
@@ -9792,6 +9810,7 @@
 				ADB1FEA22975303F00ED072D /* KMBatchBatesNumberView.xib in Resources */,
 				8942F7F32926087200389627 /* KMSearchViewController.xib in Resources */,
 				ADF9ED3329A850D200C4A943 /* KMAccountInfoView.xib in Resources */,
+				ADD5AE592A64DD2600C14249 /* KMPurchaseAlertView.xib in Resources */,
 				BB7F7C0029AA586800A3E4E7 /* signAdd.png in Resources */,
 				9F0CB46A2967E5CB00007028 /* KMPropertiesPanelSubViewController.xib in Resources */,
 				9F0CB4722967E63100007028 /* KMPropertiesPanelNameSubVC.xib in Resources */,
@@ -10278,6 +10297,7 @@
 				AD0FA50729A8E61B00EDEB50 /* KMLightMemberAlertView.xib in Resources */,
 				BB69C963299116FD0001A9B1 /* horizontal_line.pdf in Resources */,
 				BBFE6E612930809A00142C01 /* KMMergeCollectionPageViewItem.xib in Resources */,
+				ADD5AE5A2A64DD2600C14249 /* KMPurchaseAlertView.xib in Resources */,
 				BB89723E294B3C840045787C /* KMWatermarkPropertyController.xib in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -10304,6 +10324,7 @@
 				ADCB98DF2924775B00B51A03 /* KMBatchProcessingOrderTableCell.xib in Resources */,
 				89E4E7432964160F002DBA6F /* KMAnnotationLinkViewController.xib in Resources */,
 				ADBC373929CA975B00D93208 /* KMCompatative.xcassets in Resources */,
+				ADD5AE5B2A64DD2600C14249 /* KMPurchaseAlertView.xib in Resources */,
 				BB8F454C295A9CDC0037EA22 /* KMHeaderFooterListController.xib in Resources */,
 				AD0FA51029A9E75000EDEB50 /* KMLoginInputPasswordView.xib in Resources */,
 				ADBC372F29CA951E00D93208 /* KMComparativeOutlineView.xib in Resources */,
@@ -11230,6 +11251,7 @@
 				89D2D2E2294C452B00BFF5FE /* KMPDFThumbnailView.swift in Sources */,
 				ADD1B6B729420B2300C3FFF7 /* KMPrintChooseView.swift in Sources */,
 				BB146FFF299DC0D100784A6A /* OIDRedirectHTTPHandler.m in Sources */,
+				ADD5AE552A64D31200C14249 /* KMPurchaseAlertView.swift in Sources */,
 				BB1AF3F22938AD8B00EEC459 /* KMCustomAlertView.swift in Sources */,
 				9F705F76291A3A84005199AD /* KMHistoryFileDeleteWindowController.swift in Sources */,
 				BB147002299DC0D100784A6A /* OIDScopeUtilities.m in Sources */,
@@ -11904,6 +11926,7 @@
 				ADC63E382A49813E00854E02 /* KMSubscribeSuccessWindowController.swift in Sources */,
 				AD71E7C52990A8A4001C5D3F /* KMBatchRemoveViewModel.swift in Sources */,
 				F3732309292DF9410013862C /* CPDFLineAnnotation+PDFListView.m in Sources */,
+				ADD5AE562A64D31200C14249 /* KMPurchaseAlertView.swift in Sources */,
 				F34BF927295303E8002C25A2 /* NSCursor+PDFListView.m in Sources */,
 				ADB2D6EE2947415E0029D2B3 /* KMPrintPaperSetView.swift in Sources */,
 				89E4E7142963D7FF002DBA6F /* NSFont_SKExtensions.m in Sources */,
@@ -12926,6 +12949,7 @@
 				9F080B16298CFDB300FC27DA /* KMTextImageButtonVC.swift in Sources */,
 				BBFBE74828DD7DB8008B2335 /* AppDelegate.swift in Sources */,
 				BB8B173E2907CDD9001C5EA5 /* NibLoadable.swift in Sources */,
+				ADD5AE572A64D31200C14249 /* KMPurchaseAlertView.swift in Sources */,
 				ADCB9964292B8DAB00B51A03 /* KMOCRManager.swift in Sources */,
 				ADF6B86E2A480C5F0090CB78 /* KMComparativeView.swift in Sources */,
 				AD9527BC295291F20039D2BC /* KMPrintPage.swift in Sources */,

+ 4 - 21
PDF Office/PDF Master/Class/KMLightMember/Controller/ComparativeTable/KMComparativeTableViewController.swift

@@ -218,7 +218,7 @@ class KMComparativeTableViewController: NSWindowController {
     func subscribeAction(controller: KMComparativeTableViewController, isRestore: Bool = false) {
         //loading
         controller.comparativeView.beginLoading(backgroundColor: NSColor.black.withAlphaComponent(0.2))
-        
+
         if KMLightMemberManager.manager.isLogin() {
             if isRestore {
                 KMPurchaseManager.manager.restorePurchases { isSuccess, error in
@@ -242,7 +242,7 @@ class KMComparativeTableViewController: NSWindowController {
                         comparativeMainWindow?.endSheet(controller.window!)
                         comparativeMainWindow = nil
                         controller.close()
-                        
+
                         DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
                             if NSApp.mainWindow != nil {
                                 _ = KMSubscribeSuccessWindowController.show(window: NSApp.mainWindow!)
@@ -260,7 +260,7 @@ class KMComparativeTableViewController: NSWindowController {
             comparativeMainWindow?.endSheet(controller.window!)
             comparativeMainWindow = nil
             controller.close()
-            
+
             var email: String = UserDefaults.standard.value(forKey: "kLoginEmail") as? String ?? ""
             if email.count == 0 {
                 let tempController = KMLoginWindowController.show(window: NSApp.mainWindow!, .ComparativeTable, .register)
@@ -272,24 +272,7 @@ class KMComparativeTableViewController: NSWindowController {
     
     static func purchasefailed(state: KMInAppPurchaseState) {
         DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: {
-            let alert = NSAlert()
-            alert.messageText = NSLocalizedString(state.rawValue, comment: "")
-            alert.informativeText = NSLocalizedString("", comment: "")
-//            alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-            alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-            var window = NSApp.mainWindow
-            if NSApp.mainWindow?.sheets.first != nil {
-                window = NSApp.mainWindow?.sheets.first
-            }
-            if window != nil {
-                alert.beginSheetModal(for: window!) { result in
-                    if (result == .alertFirstButtonReturn) {
-
-                    } else if result == .alertSecondButtonReturn {
-                        return
-                    }
-                }
-            }
+            KMPurchaseAlertView.show(view:(comparativeController?.comparativeView)!, string: state.rawValue)
         })
     }
     

+ 91 - 0
PDF Office/PDF Master/Class/KMLightMember/Tools/Alert/KMPurchaseAlertView.swift

@@ -0,0 +1,91 @@
+//
+//  KMPurchaseAlertView.swift
+//  PDF Master
+//
+//  Created by lizhe on 2023/7/17.
+//
+
+import Cocoa
+
+class KMPurchaseAlertView: KMBaseXibView {
+
+    @IBOutlet weak var iconImageView: NSImageView!
+    @IBOutlet weak var titleLabel: NSTextField!
+    @IBOutlet weak var heightConstraint: NSLayoutConstraint!
+    @IBOutlet weak var contentBackgroundView: NSView!
+    
+    var event: Any? = nil
+    deinit {
+        self.removeNotification()
+        KMPrint("KMPurchaseAlertView delloc")
+    }
+    
+    override func draw(_ dirtyRect: NSRect) {
+        super.draw(dirtyRect)
+
+        // Drawing code here.
+    }
+    
+    static func show(view: NSView, string: String) -> KMPurchaseAlertView? {
+//        if let window = NSApp.mainWindow {
+        let alertView = KMPurchaseAlertView(frame: view.bounds )
+        view.addSubview(alertView)
+        alertView.titleLabel.stringValue = string
+        alertView.dismissShow()
+        return alertView
+//        }
+        return nil
+    }
+    
+    func dismissShow() {
+        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3.0) {
+            NSAnimationContext.runAnimationGroup { NSAnimationContext in
+                self.animator().alphaValue = 0
+                self.removeFromSuperview()
+            }
+        }
+    }
+    
+    override func setup() {
+        self.contentBackgroundView.backgroundColor(NSColor(hex: "#000000").withAlphaComponent(1))
+        self.contentBackgroundView.border(NSColor.clear, 0, 4)
+        self.titleLabel.textColor = NSColor(hex: "#FFFFFF")
+        self.titleLabel.font = NSFont.SFProTextRegular(14)
+    }
+    
+    override func addNotification() {
+//        event = NSEvent.addLocalMonitorForEvents(matching: .any) { NSEvent in
+//            return nil
+//        }
+    }
+    
+    override func removeNotification() {
+//        if self.event != nil {
+//            NSEvent.removeMonitor(self.event as Any)
+//            self.event = nil
+//        }
+    }
+}
+
+//MARK: 时间拦截
+extension KMPurchaseAlertView {
+    override func mouseUp(with event: NSEvent) {
+        
+    }
+    
+    override func mouseDown(with event: NSEvent) {
+        
+    }
+    
+    override func mouseMoved(with event: NSEvent) {
+        
+    }
+    
+    override func mouseEntered(with event: NSEvent) {
+        
+    }
+    
+    override func mouseExited(with event: NSEvent) {
+        
+    }
+}

+ 65 - 0
PDF Office/PDF Master/Class/KMLightMember/Tools/Alert/KMPurchaseAlertView.xib

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="KMPurchaseAlertView" customModule="PDF_Master" customModuleProvider="target">
+            <connections>
+                <outlet property="contentBackgroundView" destination="XUl-hB-7sK" id="f5r-6U-duF"/>
+                <outlet property="heightConstraint" destination="PbS-kQ-gV5" id="ZEn-O1-qLT"/>
+                <outlet property="iconImageView" destination="jSr-AR-J79" id="WeA-cJ-HrO"/>
+                <outlet property="titleLabel" destination="ojP-eQ-jrF" id="301-fA-d7z"/>
+            </connections>
+        </customObject>
+        <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="768" height="479"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <subviews>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="XUl-hB-7sK">
+                    <rect key="frame" x="270" y="216" width="229" height="48"/>
+                    <subviews>
+                        <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="jSr-AR-J79">
+                            <rect key="frame" x="16" y="16" width="16" height="16"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="16" id="G0g-yD-f8b"/>
+                                <constraint firstAttribute="height" constant="16" id="tg7-fD-CXI"/>
+                            </constraints>
+                            <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="icon_tips_error_small" id="8cn-Ay-TdH"/>
+                        </imageView>
+                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ojP-eQ-jrF">
+                            <rect key="frame" x="38" y="16" width="177" height="16"/>
+                            <textFieldCell key="cell" lineBreakMode="clipping" title="阿萨德发斯蒂芬去玩儿武器二" id="eZd-NL-okI">
+                                <font key="font" size="13" name=".PingFangSC-Regular"/>
+                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="jSr-AR-J79" firstAttribute="leading" secondItem="XUl-hB-7sK" secondAttribute="leading" constant="16" id="DfT-hd-kGJ"/>
+                        <constraint firstAttribute="height" constant="48" id="PbS-kQ-gV5"/>
+                        <constraint firstItem="jSr-AR-J79" firstAttribute="centerY" secondItem="XUl-hB-7sK" secondAttribute="centerY" id="Vyp-mE-fhi"/>
+                        <constraint firstAttribute="trailing" secondItem="ojP-eQ-jrF" secondAttribute="trailing" constant="16" id="dl8-tN-s4r"/>
+                        <constraint firstItem="ojP-eQ-jrF" firstAttribute="centerY" secondItem="XUl-hB-7sK" secondAttribute="centerY" id="gBV-sw-UzB"/>
+                        <constraint firstItem="ojP-eQ-jrF" firstAttribute="leading" secondItem="jSr-AR-J79" secondAttribute="trailing" constant="8" id="hCC-Je-57m"/>
+                    </constraints>
+                </customView>
+            </subviews>
+            <constraints>
+                <constraint firstItem="XUl-hB-7sK" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="7j0-aA-Bvb"/>
+                <constraint firstItem="XUl-hB-7sK" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="90I-i6-lbJ"/>
+                <constraint firstItem="XUl-hB-7sK" firstAttribute="centerX" secondItem="c22-O7-iKe" secondAttribute="centerX" id="U19-KS-f2m"/>
+                <constraint firstItem="XUl-hB-7sK" firstAttribute="centerX" secondItem="c22-O7-iKe" secondAttribute="centerX" id="skj-Cx-l6w"/>
+            </constraints>
+            <point key="canvasLocation" x="212" y="233.5"/>
+        </customView>
+    </objects>
+    <resources>
+        <image name="icon_tips_error_small" width="16" height="16"/>
+    </resources>
+</document>