Add shortcuts view controller stub

This commit is contained in:
Davide De Rosa 2019-03-18 20:14:59 +01:00
parent cb1dc5ed54
commit 1c103c639d
7 changed files with 170 additions and 9 deletions

View File

@ -26,6 +26,7 @@ internal enum StoryboardSegue {
case importHostSegueIdentifier = "ImportHostSegueIdentifier"
case selectProfileSegueIdentifier = "SelectProfileSegueIdentifier"
case showImportedHostsSegueIdentifier = "ShowImportedHostsSegueIdentifier"
case siriShortcutsSegueIdentifier = "SiriShortcutsSegueIdentifier"
case versionSegueIdentifier = "VersionSegueIdentifier"
}
}

View File

@ -45,12 +45,19 @@ class OrganizerViewController: UITableViewController, TableModelHost {
let model: TableModel<SectionType, RowType> = 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()

View File

@ -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 <http://www.gnu.org/licenses/>.
//
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()
}
}

View File

@ -153,6 +153,57 @@
</objects>
<point key="canvasLocation" x="-834" y="-356"/>
</scene>
<!--Shortcuts View Controller-->
<scene sceneID="DZ6-JX-NTd">
<objects>
<tableViewController id="UUM-it-Wcf" customClass="ShortcutsViewController" customModule="Passepartout" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="EE0-S0-zhO">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="vJl-Bj-QJQ" detailTextLabel="t9p-Gq-UhR" style="IBUITableViewCellStyleValue1" id="Fgj-eE-8oE" customClass="SettingTableViewCell" customModule="Passepartout" customModuleProvider="target">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Fgj-eE-8oE" id="g5J-4k-Ueu">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="vJl-Bj-QJQ">
<rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="t9p-Gq-UhR">
<rect key="frame" x="315" y="12" width="44" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="UUM-it-Wcf" id="SoZ-Y9-5eU"/>
<outlet property="delegate" destination="UUM-it-Wcf" id="Buc-8S-1hG"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="TGo-tN-opo">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="Bcv-uG-dfC">
<connections>
<action selector="close" destination="UUM-it-Wcf" id="N0M-V9-RdD"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="DmZ-b1-eTb" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="860" y="-815"/>
</scene>
<!--ServiceIdentifier-->
<scene sceneID="YUB-k7-E5Y">
<objects>
@ -294,6 +345,7 @@
<segue destination="NVA-bQ-iIE" kind="presentation" identifier="AddProviderSegueIdentifier" modalPresentationStyle="formSheet" id="Win-5U-mIc"/>
<segue destination="a3d-vD-Pr7" kind="presentation" identifier="AboutSegueIdentifier" id="fd4-we-46n"/>
<segue destination="z6E-m6-Op0" kind="presentation" identifier="ShowImportedHostsSegueIdentifier" modalPresentationStyle="formSheet" id="TZv-OK-8vU"/>
<segue destination="ejR-kf-6bg" kind="presentation" identifier="SiriShortcutsSegueIdentifier" id="BUE-3W-fXq"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="bGp-H5-24W" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -328,34 +380,34 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kan-Ro-DbI">
<rect key="frame" x="0.0" y="0.0" width="375" height="491"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="309"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RP1-au-v0h">
<rect key="frame" x="28" y="40" width="319" height="411"/>
<rect key="frame" x="28" y="40" width="319" height="229"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="eRj-AM-Edq">
<rect key="frame" x="59.5" y="0.0" width="200" height="200"/>
<rect key="frame" x="150.5" y="0.0" width="18" height="18"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="&lt;title&gt;" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zek-qD-saW">
<rect key="frame" x="0.0" y="220" width="319" height="29"/>
<rect key="frame" x="0.0" y="38" width="319" height="29"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="&lt;version&gt;" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tOJ-Gb-6TL">
<rect key="frame" x="0.0" y="254" width="319" height="20.5"/>
<rect key="frame" x="0.0" y="72" width="319" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="&lt;intro&gt;" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="F6g-5X-yGY">
<rect key="frame" x="0.0" y="294.5" width="319" height="20.5"/>
<rect key="frame" x="0.0" y="112.5" width="319" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wV2-Nx-RuF">
<rect key="frame" x="0.0" y="335" width="319" height="33"/>
<rect key="frame" x="0.0" y="153" width="319" height="33"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<state key="normal" title="&lt;CL&gt;"/>
<connections>
@ -363,7 +415,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rtK-wa-fgh">
<rect key="frame" x="0.0" y="378" width="319" height="33"/>
<rect key="frame" x="0.0" y="196" width="319" height="33"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<state key="normal" title="&lt;CRD&gt;"/>
<connections>
@ -624,9 +676,25 @@
</objects>
<point key="canvasLocation" x="-1012" y="-2248"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="SVr-p5-qdp">
<objects>
<navigationController id="ejR-kf-6bg" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="piC-Hz-9BT">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="UUM-it-Wcf" kind="relationship" relationship="rootViewController" id="Rt4-VJ-JcK"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="DVM-PV-jJN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="42" y="-815"/>
</scene>
</scenes>
<resources>
<image name="logo" width="200" height="200"/>
<image name="logo" width="18.75" height="18.75"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="kwN-PZ-Zg5"/>

View File

@ -60,6 +60,7 @@
0E3152DD223FA06100F61841 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0E05C5DF20D198B9006EE732 /* Localizable.strings */; };
0E3152DE223FA06400F61841 /* Web in Resources */ = {isa = PBXBuildFile; fileRef = 0E0EABC721DF853C0069DAE7 /* Web */; };
0E3152DF223FA1DD00F61841 /* ConnectionService.json in Resources */ = {isa = PBXBuildFile; fileRef = 0EBBE8F121822B4D00106008 /* ConnectionService.json */; };
0E36D24D2240234B006AF062 /* ShortcutsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E36D24C2240234B006AF062 /* ShortcutsViewController.swift */; };
0E3DA371215CB5BF00B40FC9 /* VersionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */; };
0E4C9CBB20DCF0D600A0C59C /* DestructiveTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4C9CBA20DCF0D600A0C59C /* DestructiveTableViewCell.swift */; };
0E4FD7F120D58618002221FF /* Macros.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7F020D58618002221FF /* Macros.swift */; };
@ -172,6 +173,7 @@
0E31529E223F9EF500F61841 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0E3152A3223F9EF500F61841 /* Passepartout-CoreTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Passepartout-CoreTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
0E3152AC223F9EF500F61841 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0E36D24C2240234B006AF062 /* ShortcutsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutsViewController.swift; sourceTree = "<group>"; };
0E39BCEF214B9EF10035E9DE /* WebServices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebServices.swift; sourceTree = "<group>"; };
0E39BCF2214DA9310035E9DE /* AppConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConstants.swift; sourceTree = "<group>"; };
0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionViewController.swift; sourceTree = "<group>"; };
@ -406,6 +408,7 @@
0EB67D6A2184581E00BA6200 /* ImportedHostsViewController.swift */,
0EFD943F215BED8E00529B64 /* LabelViewController.swift */,
0EBE3A78213C4E5400BFA2F5 /* OrganizerViewController.swift */,
0E36D24C2240234B006AF062 /* ShortcutsViewController.swift */,
0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */,
0ED38AD8213F33150004D387 /* WizardHostViewController.swift */,
0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */,
@ -1002,6 +1005,7 @@
0EB60FDA2111136E00AD27F3 /* UITextView+Search.swift in Sources */,
0EB67D6B2184581E00BA6200 /* ImportedHostsViewController.swift in Sources */,
0E57F63E20C83FC5008323CF /* ServiceViewController.swift in Sources */,
0E36D24D2240234B006AF062 /* ShortcutsViewController.swift in Sources */,
0EA068F4218475F800C320AD /* ParsingResult+Alerts.swift in Sources */,
0E57F63C20C83FC5008323CF /* AppDelegate.swift in Sources */,
0ED31C2920CF2A340027975F /* AccountViewController.swift in Sources */,

View File

@ -39,9 +39,11 @@
"organizer.sections.providers.footer" = "Here you find a few public infrastructures offering preset configuration profiles.";
"organizer.sections.hosts.header" = "Hosts";
"organizer.sections.hosts.footer" = "Import hosts from raw .ovpn configuration files.";
"organizer.sections.siri.header" = "Siri";
"organizer.cells.profile.value.current" = "In use";
"organizer.cells.add_provider.caption" = "Add new network";
"organizer.cells.add_host.caption" = "Add new host";
"organizer.cells.siri_shortcuts.caption" = "Add shortcuts";
"organizer.cells.about.caption" = "About %@";
"organizer.cells.uninstall.caption" = "Remove VPN configuration";
"organizer.alerts.exhausted_providers.message" = "You have created profiles for any available network.";

View File

@ -352,6 +352,10 @@ public enum L10n {
public static let current = L10n.tr("Localizable", "organizer.cells.profile.value.current")
}
}
public enum SiriShortcuts {
/// Add shortcuts
public static let caption = L10n.tr("Localizable", "organizer.cells.siri_shortcuts.caption")
}
public enum Uninstall {
/// Remove VPN configuration
public static let caption = L10n.tr("Localizable", "organizer.cells.uninstall.caption")
@ -370,6 +374,10 @@ public enum L10n {
/// Networks
public static let header = L10n.tr("Localizable", "organizer.sections.providers.header")
}
public enum Siri {
/// Siri
public static let header = L10n.tr("Localizable", "organizer.sections.siri.header")
}
}
}