Split shortcuts into VPN and Trust

This commit is contained in:
Davide De Rosa 2019-03-18 20:59:28 +01:00
parent 7e11f7bf81
commit 98160fdccb
3 changed files with 29 additions and 11 deletions

View File

@ -33,16 +33,12 @@ class ShortcutsViewController: UITableViewController, TableModelHost {
let model: TableModel<SectionType, RowType> = { let model: TableModel<SectionType, RowType> = {
let model: TableModel<SectionType, RowType> = TableModel() let model: TableModel<SectionType, RowType> = TableModel()
model.add(.shortcutCreation) model.add(.vpn)
model.set([ model.add(.trust)
.connect, model.set([.connect, .enableVPN, .disableVPN], in: .vpn)
.enableVPN, model.set([.trustWiFi, .untrustWiFi, .trustCellular, .untrustCellular], in: .trust)
.disableVPN, model.setHeader(L10n.Shortcuts.Sections.Vpn.header, for: .vpn)
.trustWiFi, model.setHeader(L10n.Shortcuts.Sections.Trust.header, for: .trust)
.untrustWiFi,
.trustCellular,
.untrustCellular
], in: .shortcutCreation)
return model return model
}() }()
@ -61,7 +57,9 @@ class ShortcutsViewController: UITableViewController, TableModelHost {
extension ShortcutsViewController { extension ShortcutsViewController {
enum SectionType { enum SectionType {
case shortcutCreation case vpn
case trust
} }
enum RowType { enum RowType {
@ -80,6 +78,14 @@ extension ShortcutsViewController {
case untrustCellular case untrustCellular
} }
override func numberOfSections(in tableView: UITableView) -> Int {
return model.count
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return model.header(for: section)
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return model.count(for: section) return model.count(for: section)
} }

View File

@ -192,6 +192,8 @@
"issue_reporter.email.body" = "Hi,\n\n%@\n\n%@\n\nRegards"; "issue_reporter.email.body" = "Hi,\n\n%@\n\n%@\n\nRegards";
"issue_reporter.email.description" = "description of the issue:"; "issue_reporter.email.description" = "description of the issue:";
"shortcuts.sections.vpn.header" = "VPN";
"shortcuts.sections.trust.header" = "Trust";
"shortcuts.cells.connect.caption" = "Connect to"; "shortcuts.cells.connect.caption" = "Connect to";
"shortcuts.cells.enable_vpn.caption" = "Enable VPN"; "shortcuts.cells.enable_vpn.caption" = "Enable VPN";
"shortcuts.cells.disable_vpn.caption" = "Disable VPN"; "shortcuts.cells.disable_vpn.caption" = "Disable VPN";

View File

@ -681,6 +681,16 @@ public enum L10n {
public static let caption = L10n.tr("Localizable", "shortcuts.cells.untrust_wifi.caption") public static let caption = L10n.tr("Localizable", "shortcuts.cells.untrust_wifi.caption")
} }
} }
public enum Sections {
public enum Trust {
/// Trust
public static let header = L10n.tr("Localizable", "shortcuts.sections.trust.header")
}
public enum Vpn {
/// VPN
public static let header = L10n.tr("Localizable", "shortcuts.sections.vpn.header")
}
}
} }
public enum Version { public enum Version {