//
//  DiyElement.swift
//  ClockWidget
//
//  Created by fff on 2024/6/28.
//

import ObjectMapper

let ElementEditInset: CGFloat = 12.0

enum DiyElementEditType {
    case none
//    case 
    case delete
    case flip
    case scaleRotate
    case click
}

enum DiyElementSelectMode {
    case normal         // 可编辑
    case unable         // 不可选中
    case clickable      // 不可编辑, 但可点击
}

// 数据元 不能用class, 否则后期无法兼容组件
protocol DiyElement {
    var elementView: DiyElementView { get }
    
    var supportEditActions: EditElementAction { get }
}

extension DiyElement {
    var supportEditActions: EditElementAction {
        return .all
    }
    
    var showCornerLine: Bool {
        return supportEditActions.contains(.delete) || supportEditActions.contains(.flip) || supportEditActions.contains(.scale)
    }
}

// 视图
protocol DiyElementView where Self: UIView {
    var element: DiyElement { get set }
}

struct DiyElementTransform {
    var size: CGSize?               // 照片 | 贴纸 尺寸
    var maxWidth: CGFloat?          // 文本最大宽度
    var position: CGPoint
    var transform: CGAffineTransform = .identity
    var rotateAngle: CGFloat?
    var corRadius: CGFloat?
    var blur: CGFloat?
    
    var inset: UIEdgeInsets?
    var zIndexForIV: Int?
}

enum DiyElementScene {
    case detail
    case inList
}
