HistoryToolbarView.swift
1.27 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
//
// ToolbarView.swift
// browser
//
// Created by Artem Talko on 29.09.2023.
//
//MARK: Checked
import UIKit
enum historyToolbarElementType {
case clean
}
final class HistoryToolbarView: UIView {
var action: ((historyToolbarElementType) -> Void)?
private let cleanHistoryButton: UIButton = {
let obj = UIButton()
obj.setTitle("Clean", for: .normal)
obj.setTitleColor(.systemBlue, for: .normal)
let menuItems: [UIMenuElement] = menuCases.allCases.map { $0.action }
obj.menu = UIMenu(title: StringConstants.menuTitle, children: menuItems)
obj.showsMenuAsPrimaryAction = true
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() {
backgroundColor = .white
addSubview(cleanHistoryButton)
setupConstraints()
}
private func setupConstraints() {
cleanHistoryButton.snp.makeConstraints { make in
make.trailing.equalToSuperview().inset(20.sizeW)
make.height.equalTo(20.sizeH)
make.top.bottom.equalToSuperview()
}
}
}