SearchingTableViewCell.swift
2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// SearchingTableViewCell.swift
// browser
//
// Created by Artem Talko on 29.09.2023.
//
import UIKit
class SearchingTableViewCell: UITableViewCell {
var model: String? {
didSet {
handleUI()
}
}
var searchImage: UIImageView = {
let obj = UIImageView()
obj.image = UIImage(systemName: "magnifyingglass")
obj.tintColor = .gray
return obj
}()
var searchLabel: UILabel = {
let obj = UILabel()
obj.font = FontConstants.regularFont_14
return obj
}()
var siteLogoImage: UIImageView = {
let obj = UIImageView()
return obj
}()
var linkImage: UIImageView = {
let obj = UIImageView()
obj.image = UIImage(systemName: "arrow.up.left")
obj.tintColor = .gray
return obj
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup() {
contentView.addSubview(searchImage)
contentView.addSubview(searchLabel)
contentView.addSubview(siteLogoImage)
contentView.addSubview(linkImage)
setupConstraints()
}
private func setupConstraints() {
searchImage.snp.makeConstraints { make in
make.top.equalToSuperview().offset(8.sizeH)
make.leading.equalToSuperview().offset(8.sizeW)
make.bottom.equalToSuperview().offset(-8.sizeH)
}
searchLabel.snp.makeConstraints { make in
make.top.equalToSuperview().inset(8.sizeH)
make.leading.equalTo(searchImage.snp.trailing).offset(8.sizeW)
}
siteLogoImage.snp.makeConstraints { make in
make.top.equalToSuperview().inset(8.sizeH)
make.height.width.equalTo(18.sizeH)
}
linkImage.snp.makeConstraints { make in
make.top.equalToSuperview().inset(8.sizeH)
make.leading.equalTo(siteLogoImage.snp.trailing).offset(8.sizeW)
make.trailing.equalToSuperview().inset(8.sizeW)
}
}
}
extension SearchingTableViewCell {
private func handleUI() {
searchLabel.text = model
}
}