Add some form of image for when no configurations are available.
This commit is contained in:
parent
d12542a0c2
commit
03c257cfcc
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 {
|
class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsControllerDelegate {
|
||||||
|
|
||||||
private weak var tableView: UITableView?
|
private weak var tableView: UITableView?
|
||||||
|
private var arrowImage: UIImageView?
|
||||||
|
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
init(tableView: UITableView) {
|
init(tableView: UITableView) {
|
||||||
|
@ -196,6 +197,7 @@ class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsController
|
||||||
|
|
||||||
func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController<Tunnel>) {
|
func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController<Tunnel>) {
|
||||||
tableView?.reloadData()
|
tableView?.reloadData()
|
||||||
|
updateEmptyIndicator(controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController<Tunnel>) {
|
func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController<Tunnel>) {
|
||||||
|
@ -204,6 +206,7 @@ class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsController
|
||||||
|
|
||||||
func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController<Tunnel>) {
|
func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController<Tunnel>) {
|
||||||
tableView?.endUpdates()
|
tableView?.endUpdates()
|
||||||
|
updateEmptyIndicator(controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchedResultsController(_ controller: FetchedResultsController<Tunnel>, didChangeObject change: FetchedResultsObjectChange<Tunnel>) {
|
func fetchedResultsController(_ controller: FetchedResultsController<Tunnel>, didChangeObject change: FetchedResultsObjectChange<Tunnel>) {
|
||||||
|
@ -233,6 +236,23 @@ class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsController
|
||||||
tableView.deleteSections(IndexSet(integer: index), with: .automatic)
|
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 {
|
protocol TunnelTableViewCellDelegate: class {
|
||||||
|
|
Loading…
Reference in New Issue