//
//  CWSearchTextBar.swift
//  ColorfulWallpaper
//
//  Created by nkl on 2024/9/11.
//

import Foundation
import UIKit

class CWSearchTextBar: UIView {
    lazy var searchView: UIView = {
        let v = UIView()
        v.backgroundColor = .white.withAlphaComponent(0.1)
        v.layer.cornerRadius = 12
        v.layer.masksToBounds = true
        return v
    }()

    lazy var textFiled: CustomTextField = {
        let text = CustomTextField()
        text.textAlignment = FitManager.isAr ? .right : .left
        text.tintColor = .white
        text.textColor = .white
        text.clearButtonMode = .always
        return text
    }()

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

    func addChildren() {
        addSubview(searchView)
        searchView.addSubview(textFiled)
    }

    func makeCOnstraints() {
        searchView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }

        textFiled.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(12)
            make.trailing.equalToSuperview()
            make.centerY.equalToSuperview()
        }
    }

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