// // KMProductModel.swift // PDF Reader Pro // // Created by wanjun on 2024/11/6. // import Foundation import Combine @objc enum KMCompareTableType : Int { case trial = 0 // 试用比较表 case dmg_Base // DMG 基础版 case dmg_MacWindows // DMG Mac&Windows双平台高级版永久 case lite_Base // Lite 基础版 case lite_MacWindows // Lite Mac&Windows双平台高级版永久 case pro_Base // Pro 基础版 case pro_Advanced // Pro Mac单平台高级版永久 } @objc enum KMCompareProductType : Int { case free = 0 // 免费 case freeTrial // 试用 case allPlatformStandard // 全平台标准版年订阅 case dualPlatformAdvanced // Mac&Windows双平台高级版永久 case allPlatformAdvanced_6 // 全平台高级版6个月订阅 case allPlatformAdvanced_12 // 全平台高级版12个月订阅 case macPlatformAdvanced // MAC单平台高级版永久 } @objcMembers class KMProductModel: ObservableObject { /** 比较表类型 */ @Published var state: KMCompareTableType = .trial /** 高级版半年 或 年订阅,true为年订阅,false为半年订阅,默认true为年订阅 */ @Published var isPurchaseSwitch: Bool = true // MARK: Public Method /** @abstract 根据当前权益获取比较表类型 @param */ func getCurrentComparisonTableType() -> Void { if KMMemberInfo.shared.canTrail { state = .trial } else { #if VERSION_FREE #if VERSION_DMG // DMG if KMMemberInfo.shared.vip_levels == "1" { state = .dmg_Base } else if KMMemberInfo.shared.vip_levels == "2" { state = .dmg_MacWindows } #else // AppStore 免费版本 if KMMemberInfo.shared.vip_levels == "1" { state = .lite_Base } else if KMMemberInfo.shared.vip_levels == "2" { state = .lite_MacWindows } #endif #else // AppStore 付费版 if KMMemberInfo.shared.vip_levels == "1" { state = .pro_Base } else if KMMemberInfo.shared.vip_levels == "2" { state = .pro_Advanced } #endif } } /** 对应商品价格 */ func getProductPrice(_ type: KMCompareProductType) -> String { if type == .freeTrial { } else if type == .allPlatformStandard { } else if type == .dualPlatformAdvanced { } else if type == .allPlatformAdvanced_6 { if let allAccessProduct = IAPProductsManager.default().advancedSixMonthPlan_lite, allAccessProduct.isOffers { return allAccessProduct.offersPrice() } } else if type == .allPlatformAdvanced_12 { #if VERSION_FREE #if VERSION_DMG // DMG #else // AppStore 免费版本 if let allAccessProduct = IAPProductsManager.default().advancedAnnualPlan_lite, allAccessProduct.isOffers { return allAccessProduct.offersPrice() } else { return IAPProductsManager.default().advancedAnnualPlan_lite.price() } #endif #else // AppStore 付费版 #endif } else if type == .macPlatformAdvanced { } return "" } // MARK: Private Method // MARK: Action Method /** 恢复购买 */ func productRestore() -> Void { IAPProductsManager.default().restoreSubscriptions() } func privacyPolicyAction() -> Void { NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/privacy-policy")!) } func termOfSerAction() -> Void { NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/terms_of_service")!) } // MARK: Get & Set /** 当前比较表产品列表内容 */ var products: [KMCompareProductType] { if state == .trial { return [.free, .freeTrial] } else if state == .dmg_Base { return [.free, .allPlatformStandard, .allPlatformAdvanced_12, .dualPlatformAdvanced] } else if state == .dmg_MacWindows { return [.allPlatformAdvanced_12] } else if state == .lite_Base { return [.free, .allPlatformAdvanced_6, .allPlatformAdvanced_12, .dualPlatformAdvanced] } else if state == .lite_MacWindows { return [.allPlatformAdvanced_12] } else if state == .pro_Base { return [.allPlatformAdvanced_12, .macPlatformAdvanced] } else if state == .pro_Advanced { return [.allPlatformAdvanced_12] } return [] } /** 比较表数据源 */ var dataSource: [Any] { if isPurchaseSwitch { // 试用 全平台标准版年订阅 全平台高级版6/12个月订阅 Mac&Windows双平台高级版永久 MAC单平台高级版永久 //MAC单平台标准版永久 return [ "Benefit", ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"], ["Maximum number of accessible devices", "2 devices", "4 devices", "4 devices", "2 devices", "1 devices"], "PDF to Office", ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "Only first 10 pages", "Standard", "Advanced", "Advanced", "Advanced"], ["Turn PDF to PPT, Excel, RTF, CSV, and more", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"], ["Convert PDF to TIFF, BMP, GIF or TGA files", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"], "Edit PDF", ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"], ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"], "OCR", ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"], "Organize Pages", ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"], ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"], "Advanced Editing Tools", ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "∞", "∞"], ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"], ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"], ["Add Bates Number", "X", "✓", "✓", "✓", "✓"], ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"], ["Create fattened copies", "X", "✓", "✓", "✓", "✓"], ["Extract Images", "X", "✓", "✓", "✓", "✓"], ["Extract tables", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"], ["Measuring Tools", "X", "✓", "✓", "✓", "✓"], "Fill & Sign", ["Create digital signature", "X", "✓", "✓", "✓", "✓"], ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"], "Security", ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"], ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"], ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"], "Create PDF", ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"], ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"], "Annotations", ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"], ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"], ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"], ["Table", "X", "✓", "✓", "✓", "✓"], "View PDF", ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"], ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"], ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"], ["Split View to compare files", "X", "✓", "✓", "✓", "✓"], "Subscription Based Solution", ["Access all premium features in app", "X", "12 months", "12 months", "∞", "∞"], ["Priority customer support", "X", "✓", "✓", "✓", "✓"], ["Ad-free", "X", "✓", "✓", "✓", "✓"] ] } else { return [ "Benefit", ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"], ["Maximum number of accessible devices", "2 devices", "4 devices", "4 devices", "2 devices", "1 devices"], "PDF to Office", ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "Only first 10 pages", "Standard", "Advanced", "Advanced", "Advanced"], ["Turn PDF to PPT, Excel, RTF, CSV, and more", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"], ["Convert PDF to TIFF, BMP, GIF or TGA files", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"], "Edit PDF", ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"], ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"], "OCR", ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"], "Organize Pages", ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"], ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"], "Advanced Editing Tools", ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "∞", "∞"], ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"], ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"], ["Add Bates Number", "X", "✓", "✓", "✓", "✓"], ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"], ["Create fattened copies", "X", "✓", "✓", "✓", "✓"], ["Extract Images", "X", "✓", "✓", "✓", "✓"], ["Extract tables", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"], ["Measuring Tools", "X", "✓", "✓", "✓", "✓"], "Fill & Sign", ["Create digital signature", "X", "✓", "✓", "✓", "✓"], ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"], "Security", ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"], ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"], ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"], "Create PDF", ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"], ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"], "Annotations", ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"], ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"], ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"], ["Table", "X", "✓", "✓", "✓", "✓"], "View PDF", ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"], ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"], ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"], ["Split View to compare files", "X", "✓", "✓", "✓", "✓"], "Subscription Based Solution", ["Access all premium features in app", "X", "6 months", "6 months", "∞", "∞"], ["Priority customer support", "X", "✓", "✓", "✓", "✓"], ["Ad-free", "X", "✓", "✓", "✓", "✓"] ] } } }