diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index 2c4cf07..09019ee 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -30,6 +30,8 @@ DCC408A41E2FCC9E00F29B0E /* PasswordStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */; }; DCC408C71E307DBB00F29B0E /* SVProgressHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */; }; 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 */ /* 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 = ""; }; DCC408C91E30BA1300F29B0E /* pass.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = pass.xcdatamodel; sourceTree = ""; }; DCDDEAAF1E4639F300F68193 /* LabelTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LabelTableViewCell.xib; sourceTree = ""; }; + DCDDEAB11E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailTitleTableViewCell.swift; sourceTree = ""; }; + DCDDEAB21E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordDetailTitleTableViewCell.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -117,6 +121,7 @@ DCA049991E335CC800522E8F /* GitServerSettingTableViewController.swift */, DCA0499D1E33BAC100522E8F /* Globals.swift */, DC4914941E434301007FF592 /* LabelTableViewCell.swift */, + DCDDEAB11E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift */, DC7E6EE91E432E48006C2443 /* Password.swift */, DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */, DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */, @@ -128,6 +133,7 @@ DCDDEAAF1E4639F300F68193 /* LabelTableViewCell.xib */, DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */, DC917BDA1E2E8231000FDF54 /* Main.storyboard */, + DCDDEAB21E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib */, DCC408C81E30BA1300F29B0E /* pass.xcdatamodeld */, ); path = pass; @@ -211,6 +217,7 @@ files = ( DC917BE11E2E8231000FDF54 /* LaunchScreen.storyboard in Resources */, DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */, + DCDDEAB41E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib in Resources */, DCDDEAB01E4639F300F68193 /* LabelTableViewCell.xib in Resources */, DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */, ); @@ -295,6 +302,7 @@ DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */, DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */, DCA0499A1E335CC800522E8F /* GitServerSettingTableViewController.swift in Sources */, + DCDDEAB31E4896BF00F68193 /* PasswordDetailTitleTableViewCell.swift in Sources */, DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */, DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */, DC5734AE1E439AD400D09270 /* PasswordsViewController.swift in Sources */, diff --git a/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/Contents.json b/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/Contents.json new file mode 100644 index 0000000..b0b59b7 --- /dev/null +++ b/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/Contents.json @@ -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" + } +} \ No newline at end of file diff --git a/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder.png b/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder.png new file mode 100644 index 0000000..605d7c2 Binary files /dev/null and b/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder.png differ diff --git a/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@2x.png b/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@2x.png new file mode 100644 index 0000000..a8b160b Binary files /dev/null and b/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@2x.png differ diff --git a/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@3x.png b/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@3x.png new file mode 100644 index 0000000..c459810 Binary files /dev/null and b/pass/Assets.xcassets/PasswordImagePlaceHolder.imageset/PasswordImagePlaceHolder@3x.png differ diff --git a/pass/Base.lproj/Main.storyboard b/pass/Base.lproj/Main.storyboard index ab3a923..758e02f 100644 --- a/pass/Base.lproj/Main.storyboard +++ b/pass/Base.lproj/Main.storyboard @@ -498,7 +498,7 @@ - + diff --git a/pass/PasswordDetailTableViewController.swift b/pass/PasswordDetailTableViewController.swift index ceb6463..44aed71 100644 --- a/pass/PasswordDetailTableViewController.swift +++ b/pass/PasswordDetailTableViewController.swift @@ -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?) { diff --git a/pass/PasswordDetailTitleTableViewCell.swift b/pass/PasswordDetailTitleTableViewCell.swift new file mode 100644 index 0000000..68fce90 --- /dev/null +++ b/pass/PasswordDetailTitleTableViewCell.swift @@ -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 + } + +} diff --git a/pass/PasswordDetailTitleTableViewCell.xib b/pass/PasswordDetailTitleTableViewCell.xib new file mode 100644 index 0000000..9d36397 --- /dev/null +++ b/pass/PasswordDetailTitleTableViewCell.xib @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pass/PasswordsViewController.swift b/pass/PasswordsViewController.swift index 840eedb..61d36fb 100644 --- a/pass/PasswordsViewController.swift +++ b/pass/PasswordsViewController.swift @@ -182,7 +182,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV passwordEntity = passwordEntities![index] } viewController.passwordEntity = passwordEntity - viewController.navigationItem.title = passwordEntity.name } } }