aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorJeroen Leenarts <jeroen.leenarts@gmail.com>2018-10-02 21:33:24 +0200
committerJeroen Leenarts <jeroen.leenarts@gmail.com>2018-10-02 21:33:24 +0200
commitbc279b1e79bbcf175984b4188a6974af06acc7db (patch)
tree9e88bb30b50c65e0ac6aa42d8fbd458cb56ee7e2 /WireGuard
parentDismiss qr scan vc on cancel. (diff)
downloadwireguard-apple-bc279b1e79bbcf175984b4188a6974af06acc7db.tar.xz
wireguard-apple-bc279b1e79bbcf175984b4188a6974af06acc7db.zip
Add some form of image for when no configurations are available.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/Assets.xcassets/Arrow.imageset/Arrow.pdfbin0 -> 8558 bytes
-rw-r--r--WireGuard/Assets.xcassets/Arrow.imageset/Contents.json15
-rw-r--r--WireGuard/ViewControllers/TunnelsTableViewController.swift20
3 files changed, 35 insertions, 0 deletions
diff --git a/WireGuard/Assets.xcassets/Arrow.imageset/Arrow.pdf b/WireGuard/Assets.xcassets/Arrow.imageset/Arrow.pdf
new file mode 100644
index 0000000..781e309
--- /dev/null
+++ b/WireGuard/Assets.xcassets/Arrow.imageset/Arrow.pdf
Binary files differ
diff --git a/WireGuard/Assets.xcassets/Arrow.imageset/Contents.json b/WireGuard/Assets.xcassets/Arrow.imageset/Contents.json
new file mode 100644
index 0000000..77459c6
--- /dev/null
+++ b/WireGuard/Assets.xcassets/Arrow.imageset/Contents.json
@@ -0,0 +1,15 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "Arrow.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "preserves-vector-representation" : true
+ }
+} \ No newline at end of file
diff --git a/WireGuard/ViewControllers/TunnelsTableViewController.swift b/WireGuard/ViewControllers/TunnelsTableViewController.swift
index 37354b0..26932d9 100644
--- a/WireGuard/ViewControllers/TunnelsTableViewController.swift
+++ b/WireGuard/ViewControllers/TunnelsTableViewController.swift
@@ -188,6 +188,7 @@ extension TunnelsTableViewController: Identifyable {}
class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsControllerDelegate {
private weak var tableView: UITableView?
+ private var arrowImage: UIImageView?
// MARK: - Lifecycle
init(tableView: UITableView) {
@@ -196,6 +197,7 @@ class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsController
func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController<Tunnel>) {
tableView?.reloadData()
+ updateEmptyIndicator(controller)
}
func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController<Tunnel>) {
@@ -204,6 +206,7 @@ class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsController
func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController<Tunnel>) {
tableView?.endUpdates()
+ updateEmptyIndicator(controller)
}
func fetchedResultsController(_ controller: FetchedResultsController<Tunnel>, didChangeObject change: FetchedResultsObjectChange<Tunnel>) {
@@ -233,6 +236,23 @@ class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsController
tableView.deleteSections(IndexSet(integer: index), with: .automatic)
}
}
+
+ private func updateEmptyIndicator(_ controller: FetchedResultsController<Tunnel>) {
+ guard let tableView = tableView else { return }
+ if controller.count > 0 {
+ tableView.backgroundView = nil
+ arrowImage = nil
+ } else {
+ if arrowImage == nil {
+ let imageView = UIImageView(image: UIImage(named: "Arrow"))
+ imageView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
+ imageView.frame = tableView.bounds
+ imageView.contentMode = .bottomRight
+ tableView.backgroundView = imageView
+ arrowImage = imageView
+ }
+ }
+ }
}
protocol TunnelTableViewCellDelegate: class {