//
//  AppUpdateView.swift
//  OrderScheduling
//
//  Created by 中道 on 2023/8/21.
//

import Foundation
import DDControlsKit_Private
import SnapKit
import DDAutoUIKit_Private

open class AppUpdateView : DDView {
    private let radiusView : DDView
    private let scrollView : DDScrollView
    private let scrollContentView : DDView
    public let contentLabel : DDLabel
    public let ignoreButton : DDButton
    public let updateButton : DDButton
    public override init(frame: CGRect) {
        radiusView = DDView.init()
        scrollView = DDScrollView()
        scrollContentView = DDView.init()
        contentLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(14)), textColor: .black.alpha(0.5))
        ignoreButton = DDButton.dd_initCustom()
        updateButton = DDButton.dd_initCustom()
        super.init(frame: frame)
        addSubview(radiusView)
        radiusView.addSubview(scrollView)
        scrollView.addSubview(scrollContentView)
        contentLabel.numberOfLines = 0
        scrollContentView.addSubview(contentLabel)
        ignoreButton.setTitle("忽略", for: .normal)
        ignoreButton.titleLabel?.font = .mediumFont(auto(14))
        ignoreButton.backgroundColor = .white
        ignoreButton.setTitleColor(.black.alpha(0.3), for: .normal)
        ignoreButton.layer.borderColor = UIColor.hex("000000").alpha(0.3).cgColor
        ignoreButton.layer.borderWidth = 0.5
        ignoreButton.layer.cornerRadius = auto(15)
        radiusView.addSubview(ignoreButton)
        updateButton.setTitle("更新", for: .normal)
        updateButton.setTitleColor(.white, for: .normal)
        updateButton.titleLabel?.font = .mediumFont(auto(14))
        updateButton.backgroundColor = .hex("1C62D9")
        updateButton.layer.cornerRadius = auto(15)
        radiusView.addSubview(updateButton)
        
        radiusView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        scrollView.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(-auto(70))
        }
        
        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().offset(auto(20))
            make.right.equalTo(-auto(20))
            make.bottom.equalTo(scrollContentView)
        }
        
        ignoreButton.snp.makeConstraints { make in
            make.bottom.equalToSuperview().offset(-auto(20))
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
            make.centerX.equalToSuperview().offset(-auto(60))
        }
        
        updateButton.snp.makeConstraints { make in
            make.bottom.equalToSuperview().offset(-auto(20))
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
            make.centerX.equalToSuperview().offset(auto(60))
        }
    }
    
    public required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
