SearchingView.swift 1.88 KB
//
//  SearchingView.swift
//  browser
//
//  Created by Artem Talko on 29.09.2023.
//

import UIKit

final class SearchingView: UIView, UITextFieldDelegate {
    let searchingButton: UIButton = {
        let obj = UIButton()
        obj.setImage(UIImage(systemName: "arrow.left"), for: .normal)
        return obj
    }()
    
    let searchingLabel: UILabel = {
        let obj = UILabel()
        obj.text = "Searching"
        obj.font = FontConstants.semiboldFont_18
        return obj
    }()
    
    let searchTableView: UITableView = {
        let obj = UITableView()
        obj.backgroundColor = .clear
        obj.separatorStyle = .none
        return obj
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setup() {
        addSubview(searchingButton)
        addSubview(searchingLabel)
        addSubview(searchTableView)
        setupConstaraints()
        backgroundColor = .white
    }
    
    private func setupConstaraints() {
        searchingButton.snp.makeConstraints { make in
            make.top.equalTo(safeAreaLayoutGuide.snp.top).offset(16.sizeH)
            make.leading.equalToSuperview().offset(16.sizeW)
            make.height.equalTo(24.sizeH)
        }
        
        searchingLabel.snp.makeConstraints { make in
            make.top.equalTo(safeAreaLayoutGuide.snp.top).offset(16.sizeH)
            make.leading.equalTo(searchingButton.snp.trailing).offset(109.sizeW)
            make.trailing.equalToSuperview().offset(-138.sizeW)
        }
        
        searchTableView.snp.makeConstraints { make in
            make.top.equalTo(searchingLabel.snp.bottom).offset(16.sizeH)
            make.leading.trailing.equalToSuperview().inset(16.sizeW)
            make.bottom.equalToSuperview()
        }
    }
}