summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNikolay Davydov <nik.davidov@gmail.com>2022-08-21 20:08:25 +0400
committerAndrej Mihajlov <and@mullvad.net>2022-08-23 13:34:27 +0200
commit066614cfbe34fc9d05f3156405214d1ec3523480 (patch)
tree2cc072599635a18ef88ff5e25fc7deea6e0a853c
parent98a05d57e134aebf19a2b1db72233139a39dd912 (diff)
downloadmullvadvpn-066614cfbe34fc9d05f3156405214d1ec3523480.tar.xz
mullvadvpn-066614cfbe34fc9d05f3156405214d1ec3523480.zip
ShortcutsDataSource: add table view section header
-rw-r--r--ios/MullvadVPN/ShortcutsDataSource.swift35
1 files changed, 35 insertions, 0 deletions
diff --git a/ios/MullvadVPN/ShortcutsDataSource.swift b/ios/MullvadVPN/ShortcutsDataSource.swift
index d021e6f458..1719af12c1 100644
--- a/ios/MullvadVPN/ShortcutsDataSource.swift
+++ b/ios/MullvadVPN/ShortcutsDataSource.swift
@@ -21,6 +21,17 @@ final class ShortcutsDataSource: NSObject, UITableViewDataSource, UITableViewDel
}
}
+ private enum HeaderFooterReuseIdentifier: String, CaseIterable {
+ case spacer
+
+ var reusableViewClass: AnyClass {
+ switch self {
+ case .spacer:
+ return EmptyTableViewHeaderFooterView.self
+ }
+ }
+ }
+
enum Section: String {
case shortcuts
}
@@ -42,6 +53,12 @@ final class ShortcutsDataSource: NSObject, UITableViewDataSource, UITableViewDel
forCellReuseIdentifier: cellIdentifier.rawValue
)
}
+ HeaderFooterReuseIdentifier.allCases.forEach { reuseIdentifier in
+ tableView.register(
+ reuseIdentifier.reusableViewClass,
+ forHeaderFooterViewReuseIdentifier: reuseIdentifier.rawValue
+ )
+ }
tableView.dataSource = self
tableView.delegate = self
}
@@ -91,6 +108,24 @@ final class ShortcutsDataSource: NSObject, UITableViewDataSource, UITableViewDel
delegate?.shortcutsDataSource(self, didSelectItem: item)
tableView.deselectRow(at: indexPath, animated: true)
}
+
+ func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+ return tableView.dequeueReusableHeaderFooterView(
+ withIdentifier: HeaderFooterReuseIdentifier.spacer.rawValue
+ )
+ }
+
+ func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
+ return nil
+ }
+
+ func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+ return UIMetrics.sectionSpacing
+ }
+
+ func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
+ return 0
+ }
}
extension ShortcutsDataSource.Item {