//
//  PlayListManageView.swift
//  TSLiveWallpaper
//
//  Created by nkl on 2024/12/26.
//

import Foundation

class PlayListManageView: UIView {
    lazy var titleLabel: UILabel = .simpleLabel(text: "", font: .font(size: 18), color: .black)
    lazy var hStack: UIStackView = {
        let mStack = UIStackView()
        mStack.axis = .horizontal
        mStack.spacing = 12
        return mStack
    }()

    lazy var sortButton: UIButton = {
        let bt = UIButton(frame: CGRect(x: 0, y: 0, width: 42, height: 42))
        bt.backgroundColor = UIColor.white.withAlphaComponent(0.1)
        bt.setImage(.icNavSort, for: .normal)
        bt.customCornerRadius = 20
        bt.backgroundColor = .white
        return bt
    }()

    lazy var manageButton: UIButton = {
        let bt = UIButton(frame: CGRect(x: 0, y: 0, width: 42, height: 42))
        bt.backgroundColor = UIColor.white.withAlphaComponent(0.1)
        bt.setImage(.icNavManage, for: .normal)
        bt.customCornerRadius = 20
        bt.backgroundColor = .white
        return bt
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        addChildren()
        makeConstraints()
    }

    func addChildren() {
        addSubview(titleLabel)
        addSubview(hStack)
        hStack.addArrangedSubview(sortButton)
        hStack.addArrangedSubview(manageButton)
    }

    func makeConstraints() {
        titleLabel.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(16)
            make.centerY.equalToSuperview()
            make.trailing.equalTo(hStack.snp.leading).offset(-12)
        }

        hStack.snp.makeConstraints { make in
            make.trailing.equalToSuperview().offset(-16)
            make.centerY.equalToSuperview()
        }
        
        sortButton.snp.makeConstraints { make in
            make.width.height.equalTo(36)
        }
        
        manageButton.snp.makeConstraints { make in
            make.width.height.equalTo(36)
        }
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
