Add some form of image for when no configurations are available.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
9906e6ba04
commit
bc279b1e79
Binary file not shown.
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Arrow.pdf"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue