add password title with image placeholder

This commit is contained in:
Bob Sun 2017-02-06 20:48:20 +08:00
parent 7eee62fa01
commit ceba7d271b
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
10 changed files with 149 additions and 12 deletions

View file

@ -30,6 +30,8 @@
DCC408A41E2FCC9E00F29B0E /* PasswordStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */; }; DCC408A41E2FCC9E00F29B0E /* PasswordStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */; };
DCC408C71E307DBB00F29B0E /* SVProgressHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */; }; DCC408C71E307DBB00F29B0E /* SVProgressHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */; };
DCDDEAB01E4639F300F68193 /* LabelTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DCDDEAAF1E4639F300F68193 /* LabelTableViewCell.xib */; }; DCDDEAB01E4639F300F68193 /* LabelTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DCDDEAAF1E4639F300F68193 /* LabelTableViewCell.xib */; };
DCDDEAB31E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCDDEAB11E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift */; };
DCDDEAB41E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DCDDEAB21E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -61,6 +63,8 @@
DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SVProgressHUD.framework; path = Carthage/Build/iOS/SVProgressHUD.framework; sourceTree = "<group>"; }; DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SVProgressHUD.framework; path = Carthage/Build/iOS/SVProgressHUD.framework; sourceTree = "<group>"; };
DCC408C91E30BA1300F29B0E /* pass.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = pass.xcdatamodel; sourceTree = "<group>"; }; DCC408C91E30BA1300F29B0E /* pass.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = pass.xcdatamodel; sourceTree = "<group>"; };
DCDDEAAF1E4639F300F68193 /* LabelTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LabelTableViewCell.xib; sourceTree = "<group>"; }; DCDDEAAF1E4639F300F68193 /* LabelTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LabelTableViewCell.xib; sourceTree = "<group>"; };
DCDDEAB11E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailTitleTableViewCell.swift; sourceTree = "<group>"; };
DCDDEAB21E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordDetailTitleTableViewCell.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -117,6 +121,7 @@
DCA049991E335CC800522E8F /* GitServerSettingTableViewController.swift */, DCA049991E335CC800522E8F /* GitServerSettingTableViewController.swift */,
DCA0499D1E33BAC100522E8F /* Globals.swift */, DCA0499D1E33BAC100522E8F /* Globals.swift */,
DC4914941E434301007FF592 /* LabelTableViewCell.swift */, DC4914941E434301007FF592 /* LabelTableViewCell.swift */,
DCDDEAB11E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift */,
DC7E6EE91E432E48006C2443 /* Password.swift */, DC7E6EE91E432E48006C2443 /* Password.swift */,
DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */, DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */,
DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */, DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */,
@ -128,6 +133,7 @@
DCDDEAAF1E4639F300F68193 /* LabelTableViewCell.xib */, DCDDEAAF1E4639F300F68193 /* LabelTableViewCell.xib */,
DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */, DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */,
DC917BDA1E2E8231000FDF54 /* Main.storyboard */, DC917BDA1E2E8231000FDF54 /* Main.storyboard */,
DCDDEAB21E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib */,
DCC408C81E30BA1300F29B0E /* pass.xcdatamodeld */, DCC408C81E30BA1300F29B0E /* pass.xcdatamodeld */,
); );
path = pass; path = pass;
@ -211,6 +217,7 @@
files = ( files = (
DC917BE11E2E8231000FDF54 /* LaunchScreen.storyboard in Resources */, DC917BE11E2E8231000FDF54 /* LaunchScreen.storyboard in Resources */,
DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */, DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */,
DCDDEAB41E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib in Resources */,
DCDDEAB01E4639F300F68193 /* LabelTableViewCell.xib in Resources */, DCDDEAB01E4639F300F68193 /* LabelTableViewCell.xib in Resources */,
DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */, DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */,
); );
@ -295,6 +302,7 @@
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */, DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */,
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */, DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */,
DCA0499A1E335CC800522E8F /* GitServerSettingTableViewController.swift in Sources */, DCA0499A1E335CC800522E8F /* GitServerSettingTableViewController.swift in Sources */,
DCDDEAB31E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift in Sources */,
DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */, DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */,
DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */, DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */,
DC5734AE1E439AD400D09270 /* PasswordsViewController.swift in Sources */, DC5734AE1E439AD400D09270 /* PasswordsViewController.swift in Sources */,

View file

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "PasswordImagePlaceHolder.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "PasswordImagePlaceHolder@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "PasswordImagePlaceHolder@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 KiB

View file

@ -498,7 +498,7 @@
<scene sceneID="9wY-d0-fB1"> <scene sceneID="9wY-d0-fB1">
<objects> <objects>
<tableViewController id="tW4-E9-CGv" customClass="PasswordDetailTableViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController"> <tableViewController id="tW4-E9-CGv" customClass="PasswordDetailTableViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="hfi-6O-04U"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="hfi-6O-04U">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/> <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>

View file

@ -27,12 +27,13 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
tableView.register(UINib(nibName: "LabelTableViewCell", bundle: nil), forCellReuseIdentifier: "labelCell") tableView.register(UINib(nibName: "LabelTableViewCell", bundle: nil), forCellReuseIdentifier: "labelCell")
tableView.register(UINib(nibName: "PasswordDetailTitleTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordDetailTitleTableViewCell")
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(PasswordDetailTableViewController.tapMenu(recognizer:))) let tapGesture = UITapGestureRecognizer(target: self, action: #selector(PasswordDetailTableViewController.tapMenu(recognizer:)))
tableView.addGestureRecognizer(tapGesture) tableView.addGestureRecognizer(tapGesture)
tapGesture.delegate = self tapGesture.delegate = self
tableView.contentInset = UIEdgeInsetsMake(-36, 0, 0, 0);
tableView.rowHeight = UITableViewAutomaticDimension tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 52 tableView.estimatedRowHeight = 52
let indicatorLable = UILabel(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 21)) let indicatorLable = UILabel(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 21))
@ -100,25 +101,42 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
} }
override func numberOfSections(in tableView: UITableView) -> Int { override func numberOfSections(in tableView: UITableView) -> Int {
return tableData.count return tableData.count + 1
} }
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableData[section].item.count if section == 0 {
return 1
}
return tableData[section - 1].item.count
} }
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "labelCell", for: indexPath) as! LabelTableViewCell let sectionIndex = indexPath.section
let rowIndex = indexPath.row
let titleData = tableData[indexPath.section].item[indexPath.row].title if sectionIndex == 0 && rowIndex == 0 {
let contentData = tableData[indexPath.section].item[indexPath.row].content let cell = tableView.dequeueReusableCell(withIdentifier: "passwordDetailTitleTableViewCell", for: indexPath) as! PasswordDetailTitleTableViewCell
cell.isPasswordCell = (titleData == "password" ? true : false) cell.passwordImageImageView.image = #imageLiteral(resourceName: "PasswordImagePlaceHolder")
cell.cellData = LabelTableViewCellData(title: titleData, content: contentData) cell.nameLabel.text = passwordEntity?.name
return cell cell.categoryLabel.text = "category1 > category2"
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "labelCell", for: indexPath) as! LabelTableViewCell
let titleData = tableData[sectionIndex - 1].item[rowIndex].title
let contentData = tableData[sectionIndex - 1].item[rowIndex].content
cell.isPasswordCell = (titleData == "password" ? true : false)
cell.cellData = LabelTableViewCellData(title: titleData, content: contentData)
return cell
}
} }
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return tableData[section].title if section == 0 {
return nil
}
return tableData[section - 1].title
} }
override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) { override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {

View file

@ -0,0 +1,26 @@
//
// PasswordDetailTitleTableViewCell.swift
// pass
//
// Created by Mingshen Sun on 6/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
class PasswordDetailTitleTableViewCell: UITableViewCell {
@IBOutlet weak var categoryLabel: UILabel!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var passwordImageImageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}

View file

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="passwordDetailTitleTableViewCell" rowHeight="74" id="KGk-i7-Jjw" customClass="PasswordDetailTitleTableViewCell" customModule="pass" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="75"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="74"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="gKV-Cd-wIk">
<rect key="frame" x="16" y="14" width="54" height="54"/>
<constraints>
<constraint firstAttribute="height" constant="54" id="Liw-y2-PDc"/>
<constraint firstAttribute="width" constant="54" id="RZX-VV-Uln"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KvF-3d-EbG">
<rect key="frame" x="86" y="18" width="226" height="20.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="category1 &gt; category2" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ctk-b6-pjw">
<rect key="frame" x="86" y="34.5" width="226" height="16"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="bottomMargin" secondItem="KvF-3d-EbG" secondAttribute="bottom" constant="27" id="6DF-bd-MtM"/>
<constraint firstItem="KvF-3d-EbG" firstAttribute="leading" secondItem="gKV-Cd-wIk" secondAttribute="trailing" constant="16" id="B4p-uV-LTm"/>
<constraint firstItem="Ctk-b6-pjw" firstAttribute="leading" secondItem="KvF-3d-EbG" secondAttribute="leading" id="CfQ-pR-HTm"/>
<constraint firstAttribute="trailingMargin" secondItem="Ctk-b6-pjw" secondAttribute="trailing" id="GbW-iJ-02i"/>
<constraint firstItem="gKV-Cd-wIk" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="6" id="JX5-qI-8f8"/>
<constraint firstItem="KvF-3d-EbG" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="10" id="OFd-QE-rRm"/>
<constraint firstAttribute="bottomMargin" secondItem="gKV-Cd-wIk" secondAttribute="bottom" constant="6" id="fyJ-BI-Jls"/>
<constraint firstAttribute="trailingMargin" secondItem="KvF-3d-EbG" secondAttribute="trailing" id="jPo-Fz-5h5"/>
<constraint firstItem="Ctk-b6-pjw" firstAttribute="top" secondItem="KvF-3d-EbG" secondAttribute="bottom" constant="-4" id="wDX-Mb-bsB"/>
<constraint firstItem="gKV-Cd-wIk" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="8" id="wjc-N6-2b9"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="categoryLabel" destination="Ctk-b6-pjw" id="dtM-9v-xH2"/>
<outlet property="nameLabel" destination="KvF-3d-EbG" id="JBt-bD-efA"/>
<outlet property="passwordImageImageView" destination="gKV-Cd-wIk" id="Vmf-b7-Zcv"/>
</connections>
<point key="canvasLocation" x="34" y="69.5"/>
</tableViewCell>
</objects>
</document>

View file

@ -182,7 +182,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
passwordEntity = passwordEntities![index] passwordEntity = passwordEntities![index]
} }
viewController.passwordEntity = passwordEntity viewController.passwordEntity = passwordEntity
viewController.navigationItem.title = passwordEntity.name
} }
} }
} }