refactor search bar

This commit is contained in:
Bob Sun 2017-02-03 13:01:41 +08:00
parent 89c9b82ac9
commit bd8ba02061
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
3 changed files with 146 additions and 143 deletions

View file

@ -13,6 +13,7 @@
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914941E434301007FF592 /* LabelTableViewCell.swift */; };
DC4914971E434301007FF592 /* LabelTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DC4914951E434301007FF592 /* LabelTableViewCell.xib */; };
DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */; };
DC5734AE1E439AD400D09270 /* PasswordsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5734AD1E439AD400D09270 /* PasswordsViewController.swift */; };
DC7E6EEA1E432E48006C2443 /* Password.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC7E6EE91E432E48006C2443 /* Password.swift */; };
DC8963BE1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BD1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift */; };
DC8963C01E38EEB900828B09 /* SSHKeySettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BF1E38EEB900828B09 /* SSHKeySettingTableViewController.swift */; };
@ -42,6 +43,7 @@
DC4914951E434301007FF592 /* LabelTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LabelTableViewCell.xib; sourceTree = "<group>"; };
DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailTableViewController.swift; sourceTree = "<group>"; };
DC4A746D1E30FBDE00E8EB18 /* Objective-CBridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Objective-CBridgingHeader.h"; sourceTree = "<group>"; };
DC5734AD1E439AD400D09270 /* PasswordsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordsViewController.swift; sourceTree = "<group>"; };
DC7E6EE91E432E48006C2443 /* Password.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Password.swift; sourceTree = "<group>"; };
DC8963BD1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitRepositoryAuthenticationSettingTableViewController.swift; sourceTree = "<group>"; };
DC8963BF1E38EEB900828B09 /* SSHKeySettingTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSHKeySettingTableViewController.swift; sourceTree = "<group>"; };
@ -112,6 +114,7 @@
DC4914941E434301007FF592 /* LabelTableViewCell.swift */,
DC4A746D1E30FBDE00E8EB18 /* Objective-CBridgingHeader.h */,
DC1208551E35D0BA0042942E /* PasswordsTableViewController.swift */,
DC5734AD1E439AD400D09270 /* PasswordsViewController.swift */,
DC917BD61E2E8231000FDF54 /* AppDelegate.swift */,
DC8963BF1E38EEB900828B09 /* SSHKeySettingTableViewController.swift */,
DC8963BD1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift */,
@ -298,6 +301,7 @@
DCA0499A1E335CC800522E8F /* GitServerSettingTableViewController.swift in Sources */,
DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */,
DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */,
DC5734AE1E439AD400D09270 /* PasswordsViewController.swift in Sources */,
DC8963BE1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift in Sources */,
DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */,
DCA049981E33586A00522E8F /* DefaultKeys.swift in Sources */,

View file

@ -11,61 +11,63 @@
</dependencies>
<scenes>
<!--Password Store-->
<scene sceneID="2hn-YS-T8K">
<scene sceneID="Qd0-Fd-Lct">
<objects>
<tableViewController id="vGH-8E-Zez" customClass="PasswordsTableViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="Cow-I6-Nig">
<viewController id="cwm-DY-Eli" customClass="PasswordsViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="zEx-Wa-Uh0"/>
<viewControllerLayoutGuide type="bottom" id="G6Y-6n-xyC"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="dfS-FV-A7r">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="passwordTableViewCell" textLabel="E7G-EA-HbK" style="IBUITableViewCellStyleDefault" id="kff-Zw-ti1">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="kff-Zw-ti1" id="x1h-9k-B9w">
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="E7G-EA-HbK">
<rect key="frame" x="15" y="0.0" width="325" height="43.5"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="Tn1-q5-vaJ">
<rect key="frame" x="0.0" y="44" width="375" height="623"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="passwordTableViewCell" textLabel="Eu3-i0-M5v" style="IBUITableViewCellStyleDefault" id="bEm-K1-de5">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bEm-K1-de5" id="kV8-N2-jWc">
<rect key="frame" x="0.0" y="0.0" width="342" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="tW4-E9-CGv" kind="show" identifier="showPasswordDetail" id="OrR-Ve-XMm"/>
</connections>
</tableViewCell>
</prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="vGH-8E-Zez" id="WBi-YU-wSW"/>
<outlet property="delegate" destination="vGH-8E-Zez" id="EG1-wX-VRt"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Password Store" id="2I8-8c-JEA">
<barButtonItem key="backBarButtonItem" title="Back" id="OCO-gr-goM"/>
<barButtonItem key="rightBarButtonItem" systemItem="refresh" id="JLS-BH-aaR">
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Eu3-i0-M5v">
<rect key="frame" x="15" y="0.0" width="325" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="tW4-E9-CGv" kind="show" identifier="showPasswordDetail" id="26n-ZD-G0k"/>
</connections>
</tableViewCell>
</prototypes>
<sections/>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" title="Password Store" id="Cio-ZG-zCS">
<barButtonItem key="backBarButtonItem" title="Back" id="New-sD-9Z1"/>
<barButtonItem key="rightBarButtonItem" systemItem="refresh" id="sHf-RI-Fgc">
<connections>
<action selector="refreshPasswords:" destination="vGH-8E-Zez" id="nZd-1L-MFr"/>
<action selector="refreshPasswords:" destination="cwm-DY-Eli" id="3AY-0O-aXH"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="CHd-Vz-2cA" userLabel="First Responder" sceneMemberID="firstResponder"/>
<searchDisplayController id="pdj-8n-ZyE">
<connections>
<outlet property="delegate" destination="vGH-8E-Zez" id="Fkb-Ib-yTT"/>
<outlet property="searchContentsController" destination="vGH-8E-Zez" id="9RT-Uy-M4k"/>
<outlet property="searchResultsDataSource" destination="vGH-8E-Zez" id="ya0-IV-wks"/>
<outlet property="searchResultsDelegate" destination="vGH-8E-Zez" id="2Vl-Dg-zmv"/>
<outlet property="tableView" destination="Tn1-q5-vaJ" id="UHc-AS-gXh"/>
</connections>
</searchDisplayController>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="6ju-JT-yds" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2425" y="993"/>
<point key="canvasLocation" x="2424.8000000000002" y="330.58470764617692"/>
</scene>
<!--Settings-->
<scene sceneID="d9R-gZ-ywG">
@ -79,14 +81,14 @@
<tableViewSection headerTitle="GIT REPO" id="5gp-bg-o3n">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="gitServerTableViewCell" textLabel="Nuw-cs-qZN" style="IBUITableViewCellStyleDefault" id="W3D-XV-i9c">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="56" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="W3D-XV-i9c" id="W9C-sq-ric">
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="342" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Git Server" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Nuw-cs-qZN">
<rect key="frame" x="15" y="0.0" width="325" height="43.5"/>
<rect key="frame" x="15" y="0.0" width="325" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
@ -99,14 +101,14 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="sshKeyTableViewCell" textLabel="39M-pD-G4c" style="IBUITableViewCellStyleDefault" id="D5Y-70-cIk">
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="100" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="D5Y-70-cIk" id="j3q-u1-biY">
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="342" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="SSH Key" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="39M-pD-G4c">
<rect key="frame" x="15" y="0.0" width="325" height="43.5"/>
<rect key="frame" x="15" y="0.0" width="325" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
@ -123,21 +125,21 @@
<tableViewSection headerTitle="CRYPTO" id="3cS-Ls-IQU">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="pgpKeyTableViewCell" textLabel="9z4-m8-sRO" detailTextLabel="eUn-QA-sUA" style="IBUITableViewCellStyleValue1" id="x7b-p5-sQR">
<rect key="frame" x="0.0" y="199.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="201" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="x7b-p5-sQR" id="wqT-nH-PgF">
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="342" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="PGP Key" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="9z4-m8-sRO">
<rect key="frame" x="15" y="12" width="66" height="20.5"/>
<rect key="frame" x="15" y="11" width="66" height="21"/>
<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="eUn-QA-sUA">
<rect key="frame" x="282" y="12" width="58" height="20.5"/>
<rect key="frame" x="282" y="11" width="58" height="21"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
@ -181,7 +183,7 @@
<rect key="frame" x="0.0" y="35" width="375" 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="375" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Git Repository URL" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ugx-bs-r9H">
@ -210,7 +212,7 @@
<rect key="frame" x="0.0" y="87" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="RWE-qh-fFI" id="fSL-1c-C64">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Username" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wO6-YQ-5na">
@ -239,7 +241,7 @@
<rect key="frame" x="0.0" y="139" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vIU-mk-Lbm" id="6VP-wN-g64">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Password" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Jt-ds-Hhi">
@ -272,18 +274,18 @@
<rect key="frame" x="0.0" y="227" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="skE-NA-SBb" id="xec-0B-cTD">
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="342" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Authentication" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Gar-Yh-ZKL">
<rect key="frame" x="15" y="12" width="111" height="20.5"/>
<rect key="frame" x="15" y="11" width="111" height="21"/>
<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="Tjx-af-c7u">
<rect key="frame" x="282" y="12" width="58" height="20.5"/>
<rect key="frame" x="282" y="11" width="58" height="21"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
@ -344,11 +346,11 @@
<rect key="frame" x="0.0" y="35" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="GZS-hV-7Yy" id="wRk-ML-bpj">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Password" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="pyY-6T-Ar4">
<rect key="frame" x="15" y="0.0" width="345" height="43.5"/>
<rect key="frame" x="15" y="0.0" width="345" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
@ -364,11 +366,11 @@
<rect key="frame" x="0.0" y="79" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ahw-Sp-Et2" id="gjE-7z-REN">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="SSH Key" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="844-Ya-Uiz">
<rect key="frame" x="15" y="0.0" width="345" height="43.5"/>
<rect key="frame" x="15" y="0.0" width="345" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
@ -413,7 +415,7 @@
<rect key="frame" x="0.0" y="35" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="BYZ-9g-xZy" id="Zfn-rK-sN1">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PGP Key URL" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dWi-eh-7Eq">
@ -442,7 +444,7 @@
<rect key="frame" x="0.0" y="87" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="qrQ-bd-sV8" id="7ts-YH-1tP">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Passphrase" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KFQ-DQ-XNg">
@ -528,7 +530,7 @@
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="vGH-8E-Zez" kind="relationship" relationship="rootViewController" id="Zi5-Xc-g3i"/>
<segue destination="cwm-DY-Eli" kind="relationship" relationship="rootViewController" id="hWN-RY-v31"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="25X-hm-lLo" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -606,7 +608,7 @@
<rect key="frame" x="0.0" y="35" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Jy1-4S-Lvf" id="tJE-ww-okf">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Public Key URL" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Oys-xP-ZrB">
@ -635,7 +637,7 @@
<rect key="frame" x="0.0" y="87" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="MA5-lE-8dT" id="pTv-Wj-psC">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Private Key URL" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="C2w-dd-roS">
@ -664,7 +666,7 @@
<rect key="frame" x="0.0" y="139" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="yER-vT-YTO" id="Mip-zw-xLu">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Passphrase" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Rnj-2x-ksO">

View file

@ -1,8 +1,8 @@
//
// PasswordTableViewController.swift
// PasswordsViewController.swift
// pass
//
// Created by Mingshen Sun on 18/1/2017.
// Created by Mingshen Sun on 3/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
@ -10,12 +10,14 @@ import UIKit
import Result
import SVProgressHUD
class PasswordsTableViewController: UITableViewController {
class PasswordsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
private var passwordEntities: [PasswordEntity]?
var filteredPasswordEntities = [PasswordEntity]()
let searchController = UISearchController(searchResultsController: nil)
var sections : [(index: Int, length :Int, title: String)] = Array()
var searchActive : Bool = false
let searchController = UISearchController(searchResultsController: nil)
@IBOutlet weak var tableView: UITableView!
@IBAction func refreshPasswords(_ sender: UIBarButtonItem) {
SVProgressHUD.setDefaultMaskType(.black)
@ -23,7 +25,7 @@ class PasswordsTableViewController: UITableViewController {
DispatchQueue.global(qos: .userInitiated).async {
if PasswordStore.shared.pullRepository(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: "Pull Remote Repository")
SVProgressHUD.showProgress(Float(git_transfer_progress.pointee.received_objects)/Float(git_transfer_progress.pointee.total_objects), status: "Pull Remote Repository")
}
}) {
DispatchQueue.main.async {
@ -42,18 +44,51 @@ class PasswordsTableViewController: UITableViewController {
super.viewDidLoad()
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
NotificationCenter.default.addObserver(self, selector: #selector(PasswordsTableViewController.actOnPasswordUpdatedNotification), name: NSNotification.Name(rawValue: "passwordUpdated"), object: nil)
generateSections(item: passwordEntities!)
tableView.delegate = self
tableView.dataSource = self
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.sizeToFit()
definesPresentationContext = true
// tableView.setContentOffset(CGPoint(x: 0, y: 44), animated: false)
generateSections(item: passwordEntities!)
tableView.tableHeaderView = searchController.searchBar
let searchBarView = UIView(frame: CGRect(x: 0, y: 64, width: searchController.searchBar.frame.size.width, height: 44))
searchBarView.addSubview(searchController.searchBar)
view.addSubview(searchBarView)
}
override func numberOfSections(in tableView: UITableView) -> Int {
func numberOfSections(in tableView: UITableView) -> Int {
return sections.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return sections[section].length
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath)
var password: PasswordEntity
let index = sections[indexPath.section].index + indexPath.row
if searchController.isActive && searchController.searchBar.text != "" {
password = filteredPasswordEntities[index]
} else {
password = passwordEntities![index]
}
cell.textLabel?.text = password.name
return cell
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return sections[section].title
}
func sectionIndexTitles(for tableView: UITableView) -> [String]? {
return sections.map { $0.title }
}
func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
return index
}
func generateSections(item: [PasswordEntity]) {
sections.removeAll()
if item.count == 0 {
@ -77,6 +112,30 @@ class PasswordsTableViewController: UITableViewController {
sections.append(newSection)
}
func actOnPasswordUpdatedNotification() {
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
generateSections(item: passwordEntities!)
self.tableView.reloadData()
print("actOnPasswordUpdatedNotification")
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showPasswordDetail" {
if let viewController = segue.destination as? PasswordDetailTableViewController {
let selectedIndexPath = self.tableView.indexPath(for: sender as! UITableViewCell)!
let index = sections[selectedIndexPath.section].index + selectedIndexPath.row
let password: PasswordEntity
if searchController.isActive && searchController.searchBar.text != "" {
password = filteredPasswordEntities[index]
} else {
password = passwordEntities![index]
}
viewController.passwordEntity = password
viewController.navigationItem.title = password.name
}
}
}
func filterContentForSearchText(searchText: String, scope: String = "All") {
filteredPasswordEntities = passwordEntities!.filter { password in
return password.name!.lowercased().contains(searchText.lowercased())
@ -88,72 +147,10 @@ class PasswordsTableViewController: UITableViewController {
}
tableView.reloadData()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
func actOnPasswordUpdatedNotification() {
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
self.tableView.reloadData()
print("actOnPasswordUpdatedNotification")
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// if searchController.isActive && searchController.searchBar.text != "" {
// return filteredPasswordEntities.count
// }
// return passwordEntities!.count
return sections[section].length
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath)
var password: PasswordEntity
let index = sections[indexPath.section].index + indexPath.row
if searchController.isActive && searchController.searchBar.text != "" {
password = filteredPasswordEntities[index]
} else {
password = passwordEntities![index]
}
cell.textLabel?.text = password.name
return cell
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return sections[section].title
}
override func sectionIndexTitles(for tableView: UITableView) -> [String]? {
return sections.map { $0.title }
}
override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
return index
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showPasswordDetail" {
if let viewController = segue.destination as? PasswordDetailTableViewController {
let selectedIndexPath = self.tableView.indexPath(for: sender as! UITableViewCell)!
let index = sections[selectedIndexPath.section].index + selectedIndexPath.row
let password: PasswordEntity
if searchController.isActive && searchController.searchBar.text != "" {
password = filteredPasswordEntities[index]
} else {
password = passwordEntities![index]
}
viewController.passwordEntity = password
viewController.navigationItem.title = password.name
}
}
}
}
extension PasswordsTableViewController: UISearchResultsUpdating {
extension PasswordsViewController: UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
filterContentForSearchText(searchText: searchController.searchBar.text!)
}
}