-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathListsSubmenuView.swift
More file actions
79 lines (64 loc) · 2.23 KB
/
ListsSubmenuView.swift
File metadata and controls
79 lines (64 loc) · 2.23 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
//
// ListsSubmenuView.swift
// LockdownSandbox
//
// Created by Aliaksandr Dvoineu on 23.03.23.
//
import UIKit
final class ListsSubmenuView: UIView {
private(set) var buttonCallback: () -> () = { }
@discardableResult
func onButtonPressed(_ callback: @escaping () -> ()) -> Self {
buttonCallback = callback
return self
}
// MARK: - Properties
lazy var topButton: UIButton = {
let button = UIButton(type: .system)
button.tintColor = .tunnelsBlue
button.setTitle("Create New List...", for: .normal)
button.setImage(UIImage(named: "icn_create_list"), for: .normal)
button.setTitleColor(.label, for: .normal)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 0)
return button
}()
lazy var bottomButton: UIButton = {
let button = UIButton(type: .system)
button.tintColor = .tunnelsBlue
button.setTitle("Import Block List...", for: .normal)
button.setImage(UIImage(named: "icn_import_list"), for: .normal)
button.setTitleColor(.label, for: .normal)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 0)
return button
}()
lazy var stackView: UIStackView = {
let stackView = UIStackView()
stackView.addArrangedSubview(topButton)
stackView.addArrangedSubview(bottomButton)
stackView.axis = .vertical
stackView.distribution = .fillEqually
stackView.alignment = .leading
stackView.spacing = 12
return stackView
}()
// MARK: - Initializer
override init(frame: CGRect) {
super.init(frame: frame)
configure()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Functions
func configure() {
backgroundColor = .systemBackground
addSubview(stackView)
stackView.anchors.top.marginsPin()
stackView.anchors.bottom.marginsPin()
stackView.anchors.leading.marginsPin(inset: 10)
stackView.anchors.trailing.marginsPin(inset: 16)
}
@objc func buttonDidPress() {
buttonCallback()
}
}