HistorySearchBarView.swift 1.54 KB
//
//  HistorySearchBarView.swift
//  browser
//
//  Created by Artem Talko on 01.10.2023.
//
//MARK: Checked

import UIKit

final class HistorySearchBarView: UIView {
    private let searchImageView: UIImageView = {
        let obj = UIImageView()
        let magnifyImage = UIImage(systemName: "magnifyingglass")?.withTintColor(.gray, renderingMode: .alwaysOriginal)
        obj.image = magnifyImage
        obj.contentMode = .scaleAspectFit
        return obj
    }()
    
    let searchTextFieldView: UITextField = {
        let obj = UITextField()
        obj.text = StringConstants.search
        obj.textColor = ColorConstants.gray
        return obj
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        addSubview(searchImageView)
        addSubview(searchTextFieldView)
        
        setupConstraints()
    }
    
    private func setupConstraints() {
        searchImageView.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(16.sizeW)
            make.top.bottom.equalToSuperview().inset(8.sizeH)
            make.height.equalTo(16.sizeH)
        }
        searchTextFieldView.snp.makeConstraints { make in
            make.leading.equalTo(searchImageView).offset(32.sizeW)
            make.trailing.equalToSuperview().offset(-16.sizeW)
            make.top.bottom.equalToSuperview().inset(8.sizeH)
        }
    }
}