simplify password repository setting

This commit is contained in:
Bob Sun 2017-02-21 13:07:14 +08:00
parent 2829e9145d
commit 87dd4f96a3
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
6 changed files with 153 additions and 169 deletions

View file

@ -12,7 +12,6 @@
DC037CA81E4B898100609409 /* BasicStaticTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CA71E4B898100609409 /* BasicStaticTableViewController.swift */; };
DC037CAA1E4B8EAE00609409 /* SpecialThanksTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CA91E4B8EAE00609409 /* SpecialThanksTableViewController.swift */; };
DC037CAC1E4C1C7100609409 /* FavIcon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC037CAB1E4C1C7100609409 /* FavIcon.framework */; };
DC037CAE1E4C9B9B00609409 /* PasswordRepositorySettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CAD1E4C9B9B00609409 /* PasswordRepositorySettingsTableViewController.swift */; };
DC037CB01E4CA51F00609409 /* GeneralSettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CAF1E4CA51F00609409 /* GeneralSettingsTableViewController.swift */; };
DC037CB21E4CAB1700609409 /* AboutRepositoryTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CB11E4CAB1700609409 /* AboutRepositoryTableViewController.swift */; };
DC037CB81E4DD1A500609409 /* AddPasswordTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CB71E4DD1A500609409 /* AddPasswordTableViewController.swift */; };
@ -69,7 +68,6 @@
DC037CA71E4B898100609409 /* BasicStaticTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicStaticTableViewController.swift; sourceTree = "<group>"; };
DC037CA91E4B8EAE00609409 /* SpecialThanksTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpecialThanksTableViewController.swift; sourceTree = "<group>"; };
DC037CAB1E4C1C7100609409 /* FavIcon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FavIcon.framework; path = Carthage/Build/iOS/FavIcon.framework; sourceTree = "<group>"; };
DC037CAD1E4C9B9B00609409 /* PasswordRepositorySettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordRepositorySettingsTableViewController.swift; sourceTree = "<group>"; };
DC037CAF1E4CA51F00609409 /* GeneralSettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralSettingsTableViewController.swift; sourceTree = "<group>"; };
DC037CB11E4CAB1700609409 /* AboutRepositoryTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutRepositoryTableViewController.swift; sourceTree = "<group>"; };
DC037CB71E4DD1A500609409 /* AddPasswordTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddPasswordTableViewController.swift; sourceTree = "<group>"; };
@ -164,7 +162,6 @@
DC037CA51E4B883900609409 /* OpenSourceComponentsTableViewController.swift */,
DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */,
DCFB77A81E502FF6008DE471 /* PasswordEditorTableViewController.swift */,
DC037CAD1E4C9B9B00609409 /* PasswordRepositorySettingsTableViewController.swift */,
DC5734AD1E439AD400D09270 /* PasswordsViewController.swift */,
DCA0499B1E3362F400522E8F /* PGPKeySettingTableViewController.swift */,
DCAAF7441E2FA66800AB94BC /* SettingsTableViewController.swift */,
@ -432,7 +429,6 @@
DCFB77A71E502DF9008DE471 /* EditPasswordTableViewController.swift in Sources */,
DCA0499A1E335CC800522E8F /* GitServerSettingTableViewController.swift in Sources */,
DCDDEAB31E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift in Sources */,
DC037CAE1E4C9B9B00609409 /* PasswordRepositorySettingsTableViewController.swift in Sources */,
DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */,
DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */,
DC962CDF1E4B62C10033B5D8 /* AboutTableViewController.swift in Sources */,

View file

@ -100,7 +100,7 @@
<segue destination="ljx-el-KZL" kind="show" id="Jhf-o6-vIP"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="gWn-ib-STb" style="IBUITableViewCellStyleDefault" id="2rc-ZW-XKd">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="gWn-ib-STb" detailTextLabel="Myq-fV-riz" style="IBUITableViewCellStyleValue1" id="2rc-ZW-XKd">
<rect key="frame" x="0.0" y="79" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2rc-ZW-XKd" id="CpT-zb-QEP">
@ -108,16 +108,23 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Password Repository" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="gWn-ib-STb">
<rect key="frame" x="15" y="0.0" width="364" height="43.666666666666664"/>
<rect key="frame" x="15" y="11.999999999999998" width="160.33333333333334" height="20.333333333333332"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Not Set" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Myq-fV-riz">
<rect key="frame" x="321.33333333333331" y="11.999999999999998" width="57.666666666666664" height="20.333333333333332"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.5568627451" green="0.5568627451" blue="0.57647058819999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="MfV-9e-wxc" kind="show" id="Zx0-mn-gYO"/>
<segue destination="K0b-qZ-UOk" kind="show" identifier="showGitServerSettingSegue" id="gbo-er-kAn"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="pgpKeyTableViewCell" textLabel="RR9-xr-9ko" detailTextLabel="7lc-Vh-G9W" style="IBUITableViewCellStyleValue1" id="1ze-MS-Xbj">
@ -248,6 +255,7 @@
<navigationItem key="navigationItem" title="Settings" id="WH4-7R-4TQ"/>
<connections>
<outlet property="passcodeTableViewCell" destination="6Y0-mj-qhA" id="vkI-h5-GRo"/>
<outlet property="passwordRepositoryTableViewCell" destination="2rc-ZW-XKd" id="aFq-K7-eIj"/>
<outlet property="pgpKeyTableViewCell" destination="1ze-MS-Xbj" id="hXe-eD-0R4"/>
<outlet property="touchIDTableViewCell" destination="wB7-Km-Oel" id="0fi-Sb-qMa"/>
<segue destination="ZUt-x1-TJu" kind="show" identifier="setPGPKeyByURLSegue" id="i0b-Yz-K9q"/>
@ -270,10 +278,10 @@
<tableViewSection headerTitle="Git Repository URL" id="pbe-W6-w4V">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="gitRepositoryURLTabelViewCell" rowHeight="52" id="FRr-pf-aPO">
<rect key="frame" x="0.0" y="55.333333333333336" width="414" height="52"/>
<rect key="frame" x="0.0" y="55.5" width="414" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="FRr-pf-aPO" id="60A-PS-qGe">
<rect key="frame" x="0.0" y="0.0" width="414" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Git Repository URL" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="EVT-VU-sCi">
@ -296,10 +304,10 @@
<tableViewSection headerTitle="Username" id="fRu-A2-SCk">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="usernameTableVIewCell" rowHeight="52" id="tnj-5U-kMB">
<rect key="frame" x="0.0" y="163.33333333333334" width="414" height="52"/>
<rect key="frame" x="0.0" y="163.5" width="414" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="tnj-5U-kMB" id="f0c-pI-MSJ">
<rect key="frame" x="0.0" y="0.0" width="414" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Username" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="TMg-Gk-7nG">
@ -321,38 +329,65 @@
</tableViewSection>
<tableViewSection headerTitle="Authentication Method" id="h0N-tI-shZ">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="g8q-ZH-D62" style="IBUITableViewCellStyleDefault" id="KrP-nb-haa">
<rect key="frame" x="0.0" y="271.33333333333337" width="414" height="44"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="2" indentationWidth="0.0" shouldIndentWhileEditing="NO" id="KrP-nb-haa">
<rect key="frame" x="0.0" y="271.5" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KrP-nb-haa" id="1uB-oE-kfI">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.666666666666664"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Password" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="g8q-ZH-D62">
<rect key="frame" x="15" y="0.0" width="384" height="43.666666666666664"/>
<autoresizingMask key="autoresizingMask"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Password" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LfQ-Af-j2O">
<rect key="frame" x="62" y="0.0" width="343" height="44"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" tag="1001" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="✓" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Scc-5J-bu1">
<rect key="frame" x="23" y="11.333333333333332" width="15.666666666666664" height="21.666666666666668"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="Scc-5J-bu1" firstAttribute="leading" secondItem="1uB-oE-kfI" secondAttribute="leadingMargin" constant="15" id="8Z8-4c-oDD"/>
<constraint firstItem="LfQ-Af-j2O" firstAttribute="top" secondItem="1uB-oE-kfI" secondAttribute="topMargin" constant="-8" id="OPg-oc-KZy"/>
<constraint firstItem="LfQ-Af-j2O" firstAttribute="leading" secondItem="1uB-oE-kfI" secondAttribute="leadingMargin" constant="54" id="TCp-fd-Sim"/>
<constraint firstAttribute="trailingMargin" secondItem="LfQ-Af-j2O" secondAttribute="trailing" constant="1" id="dDF-2l-XhB"/>
<constraint firstAttribute="bottomMargin" secondItem="LfQ-Af-j2O" secondAttribute="bottom" constant="-8.3333333333333357" id="e3U-qA-37g"/>
<constraint firstItem="Scc-5J-bu1" firstAttribute="centerY" secondItem="1uB-oE-kfI" secondAttribute="centerY" id="eyS-Gb-VOi"/>
</constraints>
</tableViewCellContentView>
<inset key="separatorInset" minX="62" minY="0.0" maxX="0.0" maxY="0.0"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="sxE-SV-Giu" style="IBUITableViewCellStyleDefault" id="5Rr-sX-WIa">
<rect key="frame" x="0.0" y="315.33333333333337" width="414" height="44"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" accessoryType="detailButton" hidesAccessoryWhenEditing="NO" indentationLevel="2" indentationWidth="0.0" shouldIndentWhileEditing="NO" id="Qmt-bo-CuJ">
<rect key="frame" x="0.0" y="315.5" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="5Rr-sX-WIa" id="eBT-sa-6Gu">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.666666666666664"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Qmt-bo-CuJ" id="p3u-8b-h3U">
<rect key="frame" x="0.0" y="0.0" width="367" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="SSH Key" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="sxE-SV-Giu">
<rect key="frame" x="15" y="0.0" width="384" height="43.666666666666664"/>
<autoresizingMask key="autoresizingMask"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SSH Key" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ezz-76-a53">
<rect key="frame" x="62" y="0.0" width="296" height="44"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" tag="1001" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="✓" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wbx-rk-i8H">
<rect key="frame" x="23" y="10.666666666666664" width="16.333333333333336" height="21.666666666666671"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="wbx-rk-i8H" firstAttribute="leading" secondItem="p3u-8b-h3U" secondAttribute="leadingMargin" constant="15" id="1gS-CT-W2C"/>
<constraint firstAttribute="bottomMargin" secondItem="Ezz-76-a53" secondAttribute="bottom" constant="-8.3333333333333357" id="NW7-VO-yjh"/>
<constraint firstItem="Ezz-76-a53" firstAttribute="leading" secondItem="p3u-8b-h3U" secondAttribute="leadingMargin" constant="54" id="Ols-7H-4Lb"/>
<constraint firstAttribute="trailingMargin" secondItem="Ezz-76-a53" secondAttribute="trailing" constant="1" id="hLu-eh-HXR"/>
<constraint firstItem="Ezz-76-a53" firstAttribute="top" secondItem="p3u-8b-h3U" secondAttribute="topMargin" constant="-8" id="jVn-3g-0ax"/>
<constraint firstItem="wbx-rk-i8H" firstAttribute="centerY" secondItem="p3u-8b-h3U" secondAttribute="centerY" id="jwk-j5-WsJ"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
@ -378,17 +413,18 @@
</navigationItem>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="authPasswordCell" destination="KrP-nb-haa" id="Ein-sy-U8j"/>
<outlet property="authSSHKeyCell" destination="5Rr-sX-WIa" id="pTY-Hc-AlX"/>
<outlet property="authPasswordCell" destination="KrP-nb-haa" id="zjH-sg-dfJ"/>
<outlet property="authSSHKeyCell" destination="Qmt-bo-CuJ" id="11L-Tt-MgM"/>
<outlet property="gitRepositoryURLTextField" destination="EVT-VU-sCi" id="2EH-Uq-tbU"/>
<outlet property="usernameTextField" destination="TMg-Gk-7nG" id="htL-4C-WJF"/>
<segue destination="7K9-cE-9qq" kind="unwind" identifier="saveGitServerSettingSegue" unwindAction="saveGitServerSettingWithSegue:" id="5UN-sC-xCA"/>
<segue destination="hqC-Ic-NMi" kind="show" identifier="showSSHKeySettingSegue" id="AP7-FV-2Ow"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="7c1-c7-Qyp" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="7K9-cE-9qq" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="6084" y="2202"/>
<point key="canvasLocation" x="6082.608695652174" y="2201.9021739130435"/>
</scene>
<!--PGP Key-->
<scene sceneID="8Hi-tl-elT">
@ -791,29 +827,6 @@
</objects>
<point key="canvasLocation" x="5132" y="2893"/>
</scene>
<!--Password Repository Settings Table View Controller-->
<scene sceneID="Wxu-vK-gsd">
<objects>
<tableViewController id="MfV-9e-wxc" customClass="PasswordRepositorySettingsTableViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="5QH-CA-h5X">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<sections/>
<connections>
<outlet property="dataSource" destination="MfV-9e-wxc" id="GCE-BU-gho"/>
<outlet property="delegate" destination="MfV-9e-wxc" id="Iaf-6q-8uh"/>
</connections>
</tableView>
<connections>
<segue destination="K0b-qZ-UOk" kind="show" identifier="showGitServerSettingSegue" id="Dnn-Qa-IEO"/>
<segue destination="hqC-Ic-NMi" kind="show" identifier="showSSHKeySettingSegue" id="LUG-xC-Xer"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="6MI-wG-QGS" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3938" y="2707"/>
</scene>
<!--General Settings Table View Controller-->
<scene sceneID="fho-xr-1Ah">
<objects>

View file

@ -19,7 +19,22 @@ class GitServerSettingTableViewController: UITableViewController {
var authenticationMethod = Defaults[.gitRepositoryAuthenticationMethod]
private func checkAuthenticationMethod(method: String) {
let passwordCheckView = authPasswordCell.viewWithTag(1001)!
let sshKeyCheckView = authSSHKeyCell.viewWithTag(1001)!
switch method {
case "Password":
passwordCheckView.isHidden = false
sshKeyCheckView.isHidden = true
case "SSH Key":
passwordCheckView.isHidden = true
sshKeyCheckView.isHidden = false
default:
passwordCheckView.isHidden = false
sshKeyCheckView.isHidden = true
}
}
override func viewDidLoad() {
super.viewDidLoad()
if let url = Defaults[.gitRepositoryURL] {
@ -27,18 +42,18 @@ class GitServerSettingTableViewController: UITableViewController {
}
usernameTextField.text = Defaults[.gitRepositoryUsername]
password = PasswordStore.shared.gitRepositoryPassword
authenticationMethod = Defaults[.gitRepositoryAuthenticationMethod]
if authenticationMethod == nil {
authPasswordCell.accessoryType = .checkmark
authenticationMethod = "Password"
} else {
switch authenticationMethod! {
case "Password":
authPasswordCell.accessoryType = .checkmark
case "SSH Key":
authSSHKeyCell.accessoryType = .checkmark
default:
authPasswordCell.accessoryType = .checkmark
}
checkAuthenticationMethod(method: authenticationMethod!)
authSSHKeyCell.accessoryType = .detailButton
}
override func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
if cell == authSSHKeyCell {
performSegue(withIdentifier: "showSSHKeySettingSegue", sender: self)
}
}
@ -72,21 +87,16 @@ class GitServerSettingTableViewController: UITableViewController {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
if cell == authPasswordCell {
authPasswordCell.accessoryType = .checkmark
authSSHKeyCell.accessoryType = .none
authenticationMethod = "Password"
} else if cell == authSSHKeyCell {
authPasswordCell.accessoryType = .none
authSSHKeyCell.accessoryType = .checkmark
if Defaults[.gitRepositorySSHPublicKeyURL] == nil && Defaults[.gitRepositorySSHPrivateKeyURL] == nil {
Utils.alert(title: "Cannot Select SSH Key", message: "Please setup SSH key first.", controller: self, completion: nil)
authenticationMethod = "Password"
authSSHKeyCell.accessoryType = .none
authPasswordCell.accessoryType = .checkmark
} else {
authenticationMethod = "SSH Key"
}
}
checkAuthenticationMethod(method: authenticationMethod!)
tableView.deselectRow(at: indexPath, animated: true)
}

View file

@ -1,102 +0,0 @@
//
// PasswordRepositorySettingsTableViewController.swift
// pass
//
// Created by Mingshen Sun on 9/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
import SwiftyUserDefaults
import SVProgressHUD
class PasswordRepositorySettingsTableViewController: BasicStaticTableViewController {
override func viewDidLoad() {
let url = Defaults[.gitRepositoryURL]?.host
tableData = [
[[.style: CellDataStyle.value1, .title: "Git Server", .action: "segue", .link: "showGitServerSettingSegue", .detailText: url ?? ""],
[.style: CellDataStyle.value1, .title: "SSH Key", .action: "segue", .link: "showSSHKeySettingSegue", .detailText: "Not Set"],],
]
navigationItemTitle = "Repository"
super.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let url = Defaults[.gitRepositoryURL] {
if let cell = tableView.cellForRow(at: IndexPath(row: 0, section: 0)) {
cell.detailTextLabel!.text = url.host
}
}
if Defaults[.gitRepositorySSHPublicKeyURL] != nil {
if let cell = tableView.cellForRow(at: IndexPath(row: 1, section: 0)) {
cell.detailTextLabel!.text = "Set"
}
}
}
@IBAction func cancelGitServerSetting(segue: UIStoryboardSegue) {
}
@IBAction func saveGitServerSetting(segue: UIStoryboardSegue) {
if let controller = segue.source as? GitServerSettingTableViewController {
let gitRepostiroyURL = controller.gitRepositoryURLTextField.text!
let username = controller.usernameTextField.text!
let password = controller.password
let auth = controller.authenticationMethod
if Defaults[.gitRepositoryURL] == nil ||
Defaults[.gitRepositoryURL]!.absoluteString != gitRepostiroyURL ||
auth != Defaults[.gitRepositoryAuthenticationMethod] ||
username != Defaults[.gitRepositoryUsername] ||
password != PasswordStore.shared.gitRepositoryPassword {
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.show(withStatus: "Prepare Repository")
var gitCredential: GitCredential
if auth == "Password" {
gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password!))
} else {
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: username, password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Globals.sshPublicKeyURL, privateKeyFile: Globals.sshPrivateKeyURL))
}
let dispatchQueue = DispatchQueue.global(qos: .userInitiated)
dispatchQueue.async {
do {
try PasswordStore.shared.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
credential: gitCredential,
transferProgressBlock:{ (git_transfer_progress, stop) in
DispatchQueue.main.async {
SVProgressHUD.showProgress(Float(git_transfer_progress.pointee.received_objects)/Float(git_transfer_progress.pointee.total_objects), status: "Clone Remote Repository")
}
},
checkoutProgressBlock: { (path, completedSteps, totalSteps) in
DispatchQueue.main.async {
SVProgressHUD.showProgress(Float(completedSteps)/Float(totalSteps), status: "Checkout Master Branch")
}
})
DispatchQueue.main.async {
PasswordStore.shared.updatePasswordEntityCoreData()
Defaults[.lastUpdatedTime] = Date()
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
Defaults[.gitRepositoryUsername] = username
Defaults[.gitRepositoryAuthenticationMethod] = auth
Defaults[.gitRepositoryPasswordAttempts] = 0
SVProgressHUD.showSuccess(withStatus: "Done")
SVProgressHUD.dismiss(withDelay: 1)
}
} catch {
DispatchQueue.main.async {
print(error)
SVProgressHUD.showError(withStatus: error.localizedDescription)
SVProgressHUD.dismiss(withDelay: 1)
}
}
}
}
}
}
}

View file

@ -19,6 +19,7 @@ class SettingsTableViewController: UITableViewController {
@IBOutlet weak var pgpKeyTableViewCell: UITableViewCell!
@IBOutlet weak var touchIDTableViewCell: UITableViewCell!
@IBOutlet weak var passcodeTableViewCell: UITableViewCell!
@IBOutlet weak var passwordRepositoryTableViewCell: UITableViewCell!
@IBAction func cancelPGPKey(segue: UIStoryboardSegue) {
}
@ -89,6 +90,71 @@ class SettingsTableViewController: UITableViewController {
}
}
@IBAction func cancelGitServerSetting(segue: UIStoryboardSegue) {
}
@IBAction func saveGitServerSetting(segue: UIStoryboardSegue) {
if let controller = segue.source as? GitServerSettingTableViewController {
let gitRepostiroyURL = controller.gitRepositoryURLTextField.text!
let username = controller.usernameTextField.text!
let password = controller.password
let auth = controller.authenticationMethod
if Defaults[.gitRepositoryURL] == nil ||
Defaults[.gitRepositoryURL]!.absoluteString != gitRepostiroyURL ||
auth != Defaults[.gitRepositoryAuthenticationMethod] ||
username != Defaults[.gitRepositoryUsername] ||
password != PasswordStore.shared.gitRepositoryPassword {
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.show(withStatus: "Prepare Repository")
var gitCredential: GitCredential
if auth == "Password" {
gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password!))
} else {
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: username, password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Globals.sshPublicKeyURL, privateKeyFile: Globals.sshPrivateKeyURL))
}
let dispatchQueue = DispatchQueue.global(qos: .userInitiated)
dispatchQueue.async {
do {
try PasswordStore.shared.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
credential: gitCredential,
transferProgressBlock:{ (git_transfer_progress, stop) in
DispatchQueue.main.async {
SVProgressHUD.showProgress(Float(git_transfer_progress.pointee.received_objects)/Float(git_transfer_progress.pointee.total_objects), status: "Clone Remote Repository")
}
},
checkoutProgressBlock: { (path, completedSteps, totalSteps) in
DispatchQueue.main.async {
SVProgressHUD.showProgress(Float(completedSteps)/Float(totalSteps), status: "Checkout Master Branch")
}
})
DispatchQueue.main.async {
PasswordStore.shared.updatePasswordEntityCoreData()
Defaults[.lastUpdatedTime] = Date()
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
Defaults[.gitRepositoryUsername] = username
Defaults[.gitRepositoryAuthenticationMethod] = auth
Defaults[.gitRepositoryPasswordAttempts] = 0
self.passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults[.gitRepositoryURL]?.host
SVProgressHUD.showSuccess(withStatus: "Done")
SVProgressHUD.dismiss(withDelay: 1)
}
} catch {
DispatchQueue.main.async {
print(error)
SVProgressHUD.showError(withStatus: error.localizedDescription)
SVProgressHUD.dismiss(withDelay: 1)
}
}
}
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(SettingsTableViewController.actOnPasswordStoreErasedNotification), name: NSNotification.Name(rawValue: "passwordStoreErased"), object: nil)

View file

@ -64,6 +64,7 @@ struct GitCredential {
return nil
}
Defaults[.gitRepositoryPasswordAttempts] += 1
PasswordStore.shared.gitRepositoryPassword = newPassword
credential = try? GTCredential(userName: userName, password: newPassword)
case let .ssh(userName, password, publicKeyFile, privateKeyFile):
credential = try? GTCredential(userName: userName, publicKeyURL: publicKeyFile, privateKeyURL: privateKeyFile, passphrase: password)