|
@@ -13,14 +13,49 @@ protocol VLCEditToolbarDelegate: class {
|
|
|
func delete()
|
|
|
func createPlaylist()
|
|
|
func rename()
|
|
|
+ func share()
|
|
|
}
|
|
|
|
|
|
-// Decided to use a UIView instead of UIToolbar because we have more freedom
|
|
|
-// FIXME: Basic structure without UI
|
|
|
class VLCEditToolbar: UIView {
|
|
|
weak var delegate: VLCEditToolbarDelegate?
|
|
|
+ private var category: MediaLibraryBaseModel
|
|
|
+ private var stackView = UIStackView()
|
|
|
+ private var shareButton: UIButton = {
|
|
|
+ let shareButton = UIButton(type: .system)
|
|
|
+ shareButton.addTarget(self, action: #selector(share), for: .touchUpInside)
|
|
|
+ shareButton.setImage(UIImage(named: "share"), for: .normal)
|
|
|
+ shareButton.tintColor = .orange
|
|
|
+ shareButton.widthAnchor.constraint(equalToConstant: 44).isActive = true
|
|
|
+ return shareButton
|
|
|
+ }()
|
|
|
+ private var renameButton: UIButton = {
|
|
|
+ let renameButton = UIButton(type: .system)
|
|
|
+ renameButton.addTarget(self, action: #selector(rename), for: .touchUpInside)
|
|
|
+ renameButton.setImage(UIImage(named: "rename"), for: .normal)
|
|
|
+ renameButton.tintColor = .orange
|
|
|
+ renameButton.widthAnchor.constraint(equalToConstant: 44).isActive = true
|
|
|
+ return renameButton
|
|
|
+ }()
|
|
|
+ private var deleteButton: UIButton = {
|
|
|
+ let deleteButton = UIButton(type: .system)
|
|
|
+ deleteButton.addTarget(self, action: #selector(deleteSelection), for: .touchUpInside)
|
|
|
+ deleteButton.setImage(UIImage(named: "delete"), for: .normal)
|
|
|
+ deleteButton.tintColor = .orange
|
|
|
+ deleteButton.widthAnchor.constraint(equalToConstant: 44).isActive = true
|
|
|
|
|
|
- @objc func createFolder() {
|
|
|
+ return deleteButton
|
|
|
+ }()
|
|
|
+ private var addToPlaylistButton: UIButton = {
|
|
|
+ let addToPlaylistButton = UIButton(type: .system)
|
|
|
+ addToPlaylistButton.setTitle(NSLocalizedString("ADD_TO_PLAYLIST", comment: ""), for: .normal)
|
|
|
+ addToPlaylistButton.titleLabel?.font = UIFont.systemFont(ofSize: 17)
|
|
|
+ addToPlaylistButton.contentHorizontalAlignment = .left
|
|
|
+ addToPlaylistButton.addTarget(self, action: #selector(addToPlaylist), for: .touchUpInside)
|
|
|
+ addToPlaylistButton.tintColor = .orange
|
|
|
+ return addToPlaylistButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ @objc func addToPlaylist() {
|
|
|
delegate?.createPlaylist()
|
|
|
}
|
|
|
|
|
@@ -28,16 +63,39 @@ class VLCEditToolbar: UIView {
|
|
|
delegate?.delete()
|
|
|
}
|
|
|
|
|
|
- @objc func renameSelection() {
|
|
|
+ @objc func rename() {
|
|
|
delegate?.rename()
|
|
|
}
|
|
|
|
|
|
+ @objc func share() {
|
|
|
+ delegate?.share()
|
|
|
+ }
|
|
|
+
|
|
|
+ private func setupStackView() {
|
|
|
+ let stackView = UIStackView(arrangedSubviews: [addToPlaylistButton, deleteButton, shareButton])
|
|
|
+ let file = category.anyfiles.first
|
|
|
+ if !(file is VLCMLAlbum) && !(file is VLCMLArtist) && !(file is VLCMLGenre) {
|
|
|
+ stackView.addArrangedSubview(renameButton)
|
|
|
+ }
|
|
|
+
|
|
|
+ stackView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ addSubview(stackView)
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
+ stackView.topAnchor.constraint(equalTo: topAnchor),
|
|
|
+ stackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 20),
|
|
|
+ stackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -20),
|
|
|
+ stackView.bottomAnchor.constraint(equalTo: bottomAnchor)
|
|
|
+ ])
|
|
|
+ }
|
|
|
+
|
|
|
init(category: MediaLibraryBaseModel) {
|
|
|
+ self.category = category
|
|
|
super.init(frame: .zero)
|
|
|
- //depending on category show edit buttons
|
|
|
+ setupStackView()
|
|
|
}
|
|
|
|
|
|
- required init?(coder aDecoder: NSCoder) {
|
|
|
+ required init(coder: NSCoder) {
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
}
|
|
|
+
|
|
|
}
|