//
//  AcceptOrderView.swift
//  OrderScheduling
//
//  Created by 中道 on 2023/8/25.
//

import Foundation
import DDControlsKit_Private
import SnapKit
import DDAutoUIKit_Private

open class AcceptOrderView : DDView {
    private let radiusView : DDView
    private let scrollView : DDScrollView
    private let scrollContentView : DDView
    public let titleLabel : DDLabel
    public let contentLabel : DDLabel
    public let horizontalLine : DDView
    public let verticalLine : DDView
    public let readButton : DDButton
    public let cancelButton : DDButton
    public override init(frame: CGRect) {
        radiusView = DDView.init()
        scrollView = DDScrollView()
        scrollContentView = DDView.init()
        titleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(16)), textColor: .black)
        contentLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(14)), textColor: .hex("203053"))
        horizontalLine = DDView()
        verticalLine = DDView()
        readButton = DDButton.dd_initCustom()
        cancelButton = DDButton.dd_initCustom()
        super.init(frame: frame)
        radiusView.layer.cornerRadius = auto(10)
        radiusView.layer.masksToBounds = true
        addSubview(radiusView)
        radiusView.addSubview(scrollView)
        scrollView.addSubview(scrollContentView)
        radiusView.addSubview(titleLabel)
        contentLabel.numberOfLines = 0
        contentLabel.textAlignment = .center
        scrollContentView.addSubview(contentLabel)
        horizontalLine.backgroundColor = .hex("979797").alpha(0.35)
        radiusView.addSubview(horizontalLine)
        verticalLine.backgroundColor = .hex("979797").alpha(0.35)
        radiusView.addSubview(verticalLine)
        readButton.titleLabel?.font = .mediumFont(auto(14))
        readButton.backgroundColor = .white
        readButton.setTitleColor(.hex("1D64D2"), for: .normal)
        radiusView.addSubview(readButton)
        cancelButton.titleLabel?.font = .mediumFont(auto(14))
        cancelButton.backgroundColor = .white
        cancelButton.setTitleColor(.hex("999B9F"), for: .normal)
        radiusView.addSubview(cancelButton)
        
        radiusView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        titleLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(auto(20))
        }
    
        scrollView.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(auto(10))
            make.left.right.equalToSuperview()
            make.bottom.equalTo(horizontalLine.snp.top).offset(0)
        }
        
        scrollContentView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
            make.width.equalToSuperview()
        }

        contentLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(auto(20))
            make.top.equalToSuperview()
            make.right.equalTo(-auto(20))
            make.height.greaterThanOrEqualTo(auto(40))
            make.bottom.equalTo(scrollContentView)
        }
        
        horizontalLine.snp.makeConstraints { make in
            make.bottom.equalToSuperview().offset(-auto(40))
            make.left.right.equalToSuperview()
            make.height.equalTo(1)
        }
        
        verticalLine.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(horizontalLine.snp.bottom)
            make.bottom.equalToSuperview()
            make.width.equalTo(1)
        }
        
        readButton.snp.makeConstraints { make in
            make.bottom.equalToSuperview()
            make.right.equalToSuperview()
            make.top.equalTo(horizontalLine.snp.bottom)
            make.left.equalTo(verticalLine.snp.right)
        }
        
        cancelButton.snp.makeConstraints { make in
            make.bottom.equalToSuperview()
            make.left.equalToSuperview()
            make.top.equalTo(horizontalLine.snp.bottom)
            make.right.equalTo(verticalLine.snp.left)
        }
    }
    
    public required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
