add password title with image placeholder
This commit is contained in:
parent
7eee62fa01
commit
ceba7d271b
10 changed files with 149 additions and 12 deletions
23
pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/Contents.json
vendored
Normal file
23
pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/Contents.json
vendored
Normal 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"
|
||||
}
|
||||
}
|
||||
BIN
pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder.png
vendored
Normal file
BIN
pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 141 KiB |
BIN
pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@2x.png
vendored
Normal file
BIN
pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 376 KiB |
BIN
pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@3x.png
vendored
Normal file
BIN
pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 721 KiB |
|
|
@ -498,7 +498,7 @@
|
|||
<scene sceneID="9wY-d0-fB1">
|
||||
<objects>
|
||||
<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"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
|
|
|
|||
|
|
@ -27,12 +27,13 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
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:)))
|
||||
tableView.addGestureRecognizer(tapGesture)
|
||||
tapGesture.delegate = self
|
||||
|
||||
tableView.contentInset = UIEdgeInsetsMake(-36, 0, 0, 0);
|
||||
tableView.rowHeight = UITableViewAutomaticDimension
|
||||
tableView.estimatedRowHeight = 52
|
||||
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 {
|
||||
return tableData.count
|
||||
return tableData.count + 1
|
||||
}
|
||||
|
||||
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 {
|
||||
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
|
||||
let contentData = tableData[indexPath.section].item[indexPath.row].content
|
||||
cell.isPasswordCell = (titleData == "password" ? true : false)
|
||||
cell.cellData = LabelTableViewCellData(title: titleData, content: contentData)
|
||||
return cell
|
||||
if sectionIndex == 0 && rowIndex == 0 {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordDetailTitleTableViewCell", for: indexPath) as! PasswordDetailTitleTableViewCell
|
||||
cell.passwordImageImageView.image = #imageLiteral(resourceName: "PasswordImagePlaceHolder")
|
||||
cell.nameLabel.text = passwordEntity?.name
|
||||
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? {
|
||||
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?) {
|
||||
|
|
|
|||
26
pass/PasswordDetailTitleTableViewCell.swift
Normal file
26
pass/PasswordDetailTitleTableViewCell.swift
Normal 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
|
||||
}
|
||||
|
||||
}
|
||||
63
pass/PasswordDetailTitleTableViewCell.xib
Normal file
63
pass/PasswordDetailTitleTableViewCell.xib
Normal 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 > 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>
|
||||
|
|
@ -182,7 +182,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
|||
passwordEntity = passwordEntities![index]
|
||||
}
|
||||
viewController.passwordEntity = passwordEntity
|
||||
viewController.navigationItem.title = passwordEntity.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue