//
//  PQEditSubtitleInfoModel.swift
//  PQSpeed
//
//  Created by ak on 2020/12/5.
//  Copyright © 2020 BytesFlow. All rights reserved.
//

import ObjectMapper
import RealmSwift
import UIKit
import BFCommonKit

public class PQEditSubtitleInfoModel: PQEditBaseModel {
    @objc dynamic public var layoutType: String = ""
    @objc dynamic public var text: String = "" {
        didSet {
            itemHeigth = sizeWithText(text: text, font: UIFont.systemFont(ofSize: 17), size: CGSize(width: cScreenWidth - cDefaultMargin * 9, height: CGFloat.greatestFiniteMagnitude)).height
            if itemHeigth < cDefaultMargin * 2 {
                itemHeigth = cDefaultMargin * 2
            }
            BFLog(message: "text== \(text),itemHeigth = \(itemHeigth)")
        }
    }

    @objc dynamic public var font: String = ""
    @objc dynamic public var fontColor: String = ""
    @objc dynamic public var bgColor: String = ""
    @objc dynamic public var fontSize: Int = 0
    // cell高度
    public var itemHeigth: CGFloat = 20
    required convenience init?(map _: Map) {
        self.init()
    }

    // 过滤itemHeigth
    public override class func ignoredProperties() -> [String] {
        return ["itemHeigth"]
    }

    public  override func mapping(map: Map) {
        layoutType <- map["layoutType"]
        text <- map["text"]
        font <- map["font"]
        fontColor <- map["fontColor"]
        bgColor <- map["bgColor"]
        fontSize <- map["fontSize"]
    }
}
