mirror of
https://github.com/confirmedcode/Lockdown-iOS.git
synced 2025-12-21 12:14:02 +01:00
80 lines
2.3 KiB
Swift
80 lines
2.3 KiB
Swift
//
|
|
// 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 createNewListButton: 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 importBlockListButton: 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(createNewListButton)
|
|
stackView.addArrangedSubview(importBlockListButton)
|
|
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()
|
|
}
|
|
}
|