123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- //
- // KMAdvertisementModel.swift
- // KMAdvertisement
- //
- // Created by lizhe on 2022/11/30.
- //
- //参考链接 https://www.jianshu.com/p/a24cf8f37860
- //func encode<T>(of model: T) throws where T: Codable {
- // let encoder = JSONEncoder()
- // encoder.outputFormatting = .prettyPrinted
- // let encodedData = try encoder.encode(model)
- // print(String(data: encodedData, encoding: .utf8)!)
- //}
- //func decode<T>(of jsonString: String, type: T.Type) throws -> T where T: Codable {
- // let data = jsonString.data(using: .utf8)!
- // let decoder = JSONDecoder()
- // let model = try! decoder.decode(T.self, from: data)
- // return model
- //}
- /**
-
- */
- @objcMembers public class KMAdvertisementModel: NSObject, Codable {
- public var appName: KMAdvertisementAppNameType = .FilmageEditorMac //产品名
- public var platform: KMAdvertisementPlatformType = .Mac //平台
- public var showType: KMAdvertisementShowType = .view //显示类型
- public let startTime: String? //开始时间 时间戳
- public let endTime: String? //结束时间 时间戳
- public let version: String? //小于等于此版本生效
- public let hidden: Bool? //是否显示
- let subscribeType: KMAdvertisementSubscribeType? //是否订阅
- public var content: [KMAdvertisementModelSection]?
- }
- @objcMembers public class KMAdvertisementModelSection: NSObject, Codable {
- public let sectionTitle: KMAdvertisementModelItem.Text?
- public var content: [KMAdvertisementModelItem]?
- }
- @objcMembers public class KMAdvertisementModelItem: NSObject, Codable {
- public var productID: String?
- public let startTime: String? //开始时间 时间戳
- public let endTime: String? //结束时间 时间戳
- public var hidden: Bool?
-
- public var index: Int?
- public let title: Text?
- public let imageURL: Image?
- public let ipadImageURL: Image?
- public let linkURL: Language?
- public let tips: Language?
- public let button: Text?
- public var actionType: KMAdvertisementActionType = .URL
-
- public struct Text: Codable {
- public let font: Font?
- public let color: Color?
- public let background: Background?
- public let language: Language?
- }
-
- public struct Font: Codable {
- public let name: String?
- public let size: Int?
- }
-
- public struct Color: Codable {
- let height: ColorState?
- let normal: ColorState?
-
- struct ColorState: Codable {
- public let dark: ColorInfo?
- public let universal: ColorInfo?
-
- struct ColorInfo: Codable {
- public var hex: String?
- public var alpha: Float?
- }
- }
- }
- public struct Background: Codable {
- let color: Color?
- let layer: Layer?
-
- struct Layer: Codable {
- public let cornerRadius: CGFloat?
- public let borderWidth: CGFloat?
- public let borderColor: Color?
- }
- }
-
- public struct Image: Codable {
- public let height: ImageInfo?
- public let normal: ImageInfo?
- public let background: Background?
- }
-
- public struct ImageInfo: Codable {
- public let dark: Language?
- public let universal: Language?
- }
-
- public class Language: NSObject, Codable {
- public let en: String?
- public let zh_TW: String?
- public let zh_CN: String?
- }
- }
|