123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- //
- // KMAdvertisementConfig.swift
- // KMAdvertisement
- //
- // Created by lizhe on 2022/11/24.
- //
- #if os(OSX)
- import AppKit
- #elseif os(iOS)
- import UIKit
- #endif
- //APP类型
- @objc public enum KMAdvertisementAppNameType: Int, Codable {
- case RecordIt = 0
- case RecordItPro = 1
- case RecordItDMG = 2
- case FilmageScreen = 3
- case FilmageScreenPro = 4
- case FilmageScreenDMG = 5
- case FilmageEditorMac = 6
- case FilmageEditorMacPro = 7
- case FilmageEditorMacDMG = 8
- case FilmageConverterMac = 9
- case FilmageConverterMacPro = 10
- case FilmageConverterMacDMG = 11
- case FilmagePlayerMac = 12
- case FilmagePlayerMacPro = 13
- case FilmagePlayerMacDMG = 14
- case PDFReaderProMac = 15
- case PDFReaderProMacPro = 16
- case PDFReaderProMacDMG = 17
- case PDFReaderProIOS = 18
- case PDFReaderProIOSPro = 19
-
- func string() -> String {
- switch self {
- case .RecordIt: return "RecordIt"
- case .RecordItPro: return "RecordItPro"
- case .RecordItDMG: return "RecordItDMG"
- case .FilmageScreen: return "FilmageScreen"
- case .FilmageScreenPro: return "FilmageScreenPro"
- case .FilmageScreenDMG: return "FilmageScreenDMG"
- case .FilmageEditorMac: return "FilmageEditorMac"
- case .FilmageEditorMacPro: return "FilmageEditorMacPro"
- case .FilmageEditorMacDMG: return "FilmageEditorMacDMG"
- case .FilmageConverterMac: return "FilmageConverterMac"
- case .FilmageConverterMacPro: return "FilmageConverterMacPro"
- case .FilmageConverterMacDMG: return "FilmageConverterMacDMG"
- case .FilmagePlayerMac: return "FilmagePlayerMac"
- case .FilmagePlayerMacPro: return "FilmagePlayerMacPro"
- case .FilmagePlayerMacDMG: return "FilmagePlayerMacDMG"
- case .PDFReaderProMac: return "PDFReaderProMac"
- case .PDFReaderProMacPro: return "PDFReaderProMacPro"
- case .PDFReaderProMacDMG: return "PDFReaderProMacDMG"
- case .PDFReaderProIOS: return "PDFReaderProIOS"
- case .PDFReaderProIOSPro: return "PDFReaderProIOSPro"
- }
- }
- }
- //显示样式
- @objc public enum KMAdvertisementShowType: Int, Codable {
- case unknow = 0
- case list = 1 //列表
- case pop = 2 //弹窗
- case scroll = 3 //循环
- case view = 4 //视图显示
- }
- //平台
- @objc public enum KMAdvertisementPlatformType: Int, Codable {
- case unknow = 0
- case Mac //
- case iOS //
- }
- ////订阅状态
- //@objc public enum KMAdvertisementSubscribeType: Int, Codable {
- // case unknow = 0
- // case unsubscribed = 1 //未订阅
- // case subscribed = 2 //已订阅
- // case all = 3 //无限制
- //}
- @objc public enum KMAdvertisementSubscribeType: Int, Codable {
- case unknow = 0
- case all //免费版跟付费版都需要显示
- case pro //只有付费用户显示
- case lite //只有免费用户显示
- }
- //点击视图后跳转选项
- @objc public enum KMAdvertisementActionType: Int, Codable {
- case unknow = 0
- case URL = 1 //链接
- case comparative = 2 //比价表
- }
- //多语
- @objc public enum KMAdvertisementLanguageType: Int, Codable {
- case unknow
- case en //
- case zhCN //
- case zhTW //
- }
- @objcMembers open class KMAdvertisementConfig: NSObject {
- var isDebug: Bool = false
- var appName: KMAdvertisementAppNameType = .PDFReaderProMacPro
- var platform: KMAdvertisementPlatformType = .Mac
- public var subscribeType: KMAdvertisementSubscribeType = .unknow
- public var language: KMAdvertisementLanguageType = .unknow
-
- func activityBaseURL() -> String {
- if kTestMode == 1{
- return "http://test-store.kdan.cn:3019"
- } else {
- return "https://store.filmagepro.com:3018"
- }
- }
-
- public func initParameters(appName: KMAdvertisementAppNameType, subscribeType:KMAdvertisementSubscribeType, platform: KMAdvertisementPlatformType) {
- self.appName = appName
- self.subscribeType = subscribeType
- self.platform = platform
- }
- }
- extension KMAdvertisementConfig {
- static func adapterDark(light: AnyObject, dark: AnyObject) -> AnyObject {
- if self.isDarkModel() {
- return dark
- } else {
- return light
- }
- }
-
- static func isDarkModel() -> Bool {
- #if os(iOS)
- if #available(iOS 12.0, *) {
- if UITraitCollection.current.userInterfaceStyle == UIUserInterfaceStyle.dark {
- return true
- } else {
- return false
- }
- }
- #elseif os(OSX)
- if #available(macOS 10.14, *) {
- let dict = UserDefaults.standard.persistentDomain(forName: UserDefaults.globalDomain) ?? nil
- guard let dicts: Dictionary = dict else {
- // print("不是字典类型")
- return false
- }
-
- guard let style = dicts["AppleInterfaceStyle"] as? String else {
- // print("style is not string")
- return false
- }
-
- let isDarkMode : Bool = style.compare("Dark").rawValue == 0
-
- if isDarkMode {
- // print("暗黑模式\(style)")
- return true
- } else {
- // print("正常模式\(style)")
- return false
- }
- } else {
- return false
- }
- #endif
- }
- }
|