From 98160fdccb6d1faf11c46947a9db22c8e1c133dc Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 18 Mar 2019 20:59:28 +0100 Subject: [PATCH] Split shortcuts into VPN and Trust --- .../Organizer/ShortcutsViewController.swift | 28 +++++++++++-------- .../Resources/en.lproj/Localizable.strings | 2 ++ Passepartout/Sources/SwiftGen+Strings.swift | 10 +++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift index f3d66e90..41f675a8 100644 --- a/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift @@ -33,16 +33,12 @@ class ShortcutsViewController: UITableViewController, TableModelHost { let model: TableModel = { let model: TableModel = TableModel() - model.add(.shortcutCreation) - model.set([ - .connect, - .enableVPN, - .disableVPN, - .trustWiFi, - .untrustWiFi, - .trustCellular, - .untrustCellular - ], in: .shortcutCreation) + model.add(.vpn) + model.add(.trust) + model.set([.connect, .enableVPN, .disableVPN], in: .vpn) + model.set([.trustWiFi, .untrustWiFi, .trustCellular, .untrustCellular], in: .trust) + model.setHeader(L10n.Shortcuts.Sections.Vpn.header, for: .vpn) + model.setHeader(L10n.Shortcuts.Sections.Trust.header, for: .trust) return model }() @@ -61,7 +57,9 @@ class ShortcutsViewController: UITableViewController, TableModelHost { extension ShortcutsViewController { enum SectionType { - case shortcutCreation + case vpn + + case trust } enum RowType { @@ -80,6 +78,14 @@ extension ShortcutsViewController { 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 { return model.count(for: section) } diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index 43a50c4e..a8e27766 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -192,6 +192,8 @@ "issue_reporter.email.body" = "Hi,\n\n%@\n\n%@\n\nRegards"; "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.enable_vpn.caption" = "Enable VPN"; "shortcuts.cells.disable_vpn.caption" = "Disable VPN"; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 2de7e60d..be660261 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -681,6 +681,16 @@ public enum L10n { 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 {