From 1c103c639d181dbc98da1063ec00cbee6bc71d3f Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 18 Mar 2019 20:14:59 +0100 Subject: [PATCH 1/9] Add shortcuts view controller stub --- Passepartout-iOS/Global/SwiftGen+Segues.swift | 1 + .../Organizer/OrganizerViewController.swift | 24 ++++++ .../Organizer/ShortcutsViewController.swift | 54 ++++++++++++ .../en.lproj/Organizer.storyboard | 86 +++++++++++++++++-- Passepartout.xcodeproj/project.pbxproj | 4 + .../Resources/en.lproj/Localizable.strings | 2 + Passepartout/Sources/SwiftGen+Strings.swift | 8 ++ 7 files changed, 170 insertions(+), 9 deletions(-) create mode 100644 Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift diff --git a/Passepartout-iOS/Global/SwiftGen+Segues.swift b/Passepartout-iOS/Global/SwiftGen+Segues.swift index a329d831..aee35534 100644 --- a/Passepartout-iOS/Global/SwiftGen+Segues.swift +++ b/Passepartout-iOS/Global/SwiftGen+Segues.swift @@ -26,6 +26,7 @@ internal enum StoryboardSegue { case importHostSegueIdentifier = "ImportHostSegueIdentifier" case selectProfileSegueIdentifier = "SelectProfileSegueIdentifier" case showImportedHostsSegueIdentifier = "ShowImportedHostsSegueIdentifier" + case siriShortcutsSegueIdentifier = "SiriShortcutsSegueIdentifier" case versionSegueIdentifier = "VersionSegueIdentifier" } } diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index 14cbc0df..094ef709 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -45,12 +45,19 @@ class OrganizerViewController: UITableViewController, TableModelHost { let model: TableModel = TableModel() model.add(.providers) model.add(.hosts) + if #available(iOS 12, *) { + model.add(.siri) + } model.add(.about) model.add(.destruction) model.setHeader(L10n.Organizer.Sections.Providers.header, for: .providers) model.setHeader(L10n.Organizer.Sections.Hosts.header, for: .hosts) model.setFooter(L10n.Organizer.Sections.Providers.footer, for: .providers) model.setFooter(L10n.Organizer.Sections.Hosts.footer, for: .hosts) + if #available(iOS 12, *) { + model.setHeader(L10n.Organizer.Sections.Siri.header, for: .siri) + model.set([.siriShortcuts], in: .siri) + } model.set([.openAbout], in: .about) model.set([.uninstall], in: .destruction) if AppConstants.Flags.isBeta { @@ -179,6 +186,10 @@ class OrganizerViewController: UITableViewController, TableModelHost { private func addNewHost() { perform(segue: StoryboardSegue.Organizer.showImportedHostsSegueIdentifier) } + + private func addShortcuts() { + perform(segue: StoryboardSegue.Organizer.siriShortcutsSegueIdentifier) + } private func removeProfile(at indexPath: IndexPath) { let sectionObject = model.section(for: indexPath.section) @@ -269,6 +280,8 @@ extension OrganizerViewController { case hosts + case siri + case about case destruction @@ -283,6 +296,8 @@ extension OrganizerViewController { case addHost + case siriShortcuts + case openAbout case uninstall @@ -347,6 +362,12 @@ extension OrganizerViewController { cell.leftText = L10n.Organizer.Cells.AddHost.caption return cell + case .siriShortcuts: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.applyAction(Theme.current) + cell.leftText = L10n.Organizer.Cells.SiriShortcuts.caption + return cell + case .openAbout: let cell = Cells.setting.dequeue(from: tableView, for: indexPath) cell.leftText = L10n.Organizer.Cells.About.caption(GroupConstants.App.name) @@ -381,6 +402,9 @@ extension OrganizerViewController { case .addHost: addNewHost() + case .siriShortcuts: + addShortcuts() + case .openAbout: about() diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift new file mode 100644 index 00000000..a8fa287a --- /dev/null +++ b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift @@ -0,0 +1,54 @@ +// +// ShortcutsViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 3/18/19. +// Copyright (c) 2019 Davide De Rosa. All rights reserved. +// +// https://github.com/passepartoutvpn +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit +import IntentsUI +import Passepartout_Core + +class ShortcutsViewController: UITableViewController { + + // MARK: UIViewController + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Organizer.Cells.SiriShortcuts.caption +// itemNext.title = L10n.Global.next + } + + @IBAction private func close() { + dismiss(animated: true, completion: nil) + } +} + +extension ShortcutsViewController { + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 3 + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return UITableViewCell() + } +} diff --git a/Passepartout-iOS/en.lproj/Organizer.storyboard b/Passepartout-iOS/en.lproj/Organizer.storyboard index 94f21074..6fe4a080 100644 --- a/Passepartout-iOS/en.lproj/Organizer.storyboard +++ b/Passepartout-iOS/en.lproj/Organizer.storyboard @@ -153,6 +153,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -294,6 +345,7 @@ + @@ -328,34 +380,34 @@ - + - + - +