HistoryToolbarView.swift
1.35 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
//
// ToolbarView.swift
// browser
//
// Created by Artem Talko on 29.09.2023.
//
import UIKit
enum historyToolbarElementType {
case clean
}
final class HistoryToolbarView: UIView {
var action: ((historyToolbarElementType) -> Void)?
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: "Clearing will remove history, cookies and other browsing data. History will be cleared from devices signed into your iCloud Account. Clear from:", children: menuItems)
obj.showsMenuAsPrimaryAction = true
return obj
}()
override init(frame: CGRect) {
super.init(frame: frame)
setup()
setupConstraints()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setup() {
backgroundColor = .white
addSubview(cleanHistoryButton)
}
private func setupConstraints() {
cleanHistoryButton.snp.makeConstraints { make in
make.trailing.equalToSuperview().inset(20.sizeW)
make.height.equalTo(20.sizeH)
make.top.bottom.equalToSuperview()
}
}
}