-
Notifications
You must be signed in to change notification settings - Fork 6
/
LeavesListVC.swift
39 lines (32 loc) · 1.1 KB
/
LeavesListVC.swift
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
//
// LeavesListVC.swift
// Twackup
//
// Created by Daniil on 16.12.2022.
//
import UIKit
class LeavesListVC: DpkgListVC {
private lazy var shareListButton: UIBarButtonItem = {
UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(shareList))
}()
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.leftBarButtonItem = shareListButton
}
override func endReloadingData() {
super.endReloadingData()
shareListButton.isEnabled = !model.dataProvider.packages.isEmpty
}
@objc
func shareList() {
let packagesText = model.dataProvider.packages
.enumerated()
.map { index, package in
String(format: "%3d. %@ - %@", index + 1, package.id, package.version)
}
.joined(separator: "\n")
let activityVC = UIActivityViewController(activityItems: [packagesText], applicationActivities: nil)
activityVC.popoverPresentationController?.barButtonItem = shareListButton
present(activityVC, animated: true, completion: nil)
}
}