diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index 71595f6..9d1350d 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -52,6 +52,8 @@ DCDDEAB41E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DCDDEAB21E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib */; }; DCFB779A1E4F3BCF008DE471 /* TitleTextFieldTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB77981E4F3BCF008DE471 /* TitleTextFieldTableViewCell.swift */; }; DCFB779B1E4F3BCF008DE471 /* TitleTextFieldTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DCFB77991E4F3BCF008DE471 /* TitleTextFieldTableViewCell.xib */; }; + DCFB779E1E4F40C7008DE471 /* FillPasswordTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB779C1E4F40C7008DE471 /* FillPasswordTableViewCell.swift */; }; + DCFB779F1E4F40C7008DE471 /* FillPasswordTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DCFB779D1E4F40C7008DE471 /* FillPasswordTableViewCell.xib */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -105,6 +107,8 @@ DCDDEAB21E4896BF00F68193 /* PasswordDetailTitleTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = PasswordDetailTitleTableViewCell.xib; path = ../PasswordDetailTitleTableViewCell.xib; sourceTree = ""; }; DCFB77981E4F3BCF008DE471 /* TitleTextFieldTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TitleTextFieldTableViewCell.swift; sourceTree = ""; }; DCFB77991E4F3BCF008DE471 /* TitleTextFieldTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TitleTextFieldTableViewCell.xib; sourceTree = ""; }; + DCFB779C1E4F40C7008DE471 /* FillPasswordTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FillPasswordTableViewCell.swift; sourceTree = ""; }; + DCFB779D1E4F40C7008DE471 /* FillPasswordTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FillPasswordTableViewCell.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -182,6 +186,8 @@ DC19400F1E4B3A9E0077E0A3 /* Views */ = { isa = PBXGroup; children = ( + DCFB779C1E4F40C7008DE471 /* FillPasswordTableViewCell.swift */, + DCFB779D1E4F40C7008DE471 /* FillPasswordTableViewCell.xib */, DCFB77981E4F3BCF008DE471 /* TitleTextFieldTableViewCell.swift */, DCFB77991E4F3BCF008DE471 /* TitleTextFieldTableViewCell.xib */, DC4914941E434301007FF592 /* LabelTableViewCell.swift */, @@ -316,6 +322,7 @@ DCDDEAB01E4639F300F68193 /* LabelTableViewCell.xib in Resources */, DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */, DCFB779B1E4F3BCF008DE471 /* TitleTextFieldTableViewCell.xib in Resources */, + DCFB779F1E4F40C7008DE471 /* FillPasswordTableViewCell.xib in Resources */, DC037CC01E4ED4E100609409 /* TextViewTableViewCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -412,6 +419,7 @@ DC037CAA1E4B8EAE00609409 /* SpecialThanksTableViewController.swift in Sources */, DC037CA61E4B883900609409 /* OpenSourceComponentsTableViewController.swift in Sources */, DC037CA81E4B898100609409 /* BasicStaticTableViewController.swift in Sources */, + DCFB779E1E4F40C7008DE471 /* FillPasswordTableViewCell.swift in Sources */, DC037CB21E4CAB1700609409 /* AboutRepositoryTableViewController.swift in Sources */, DC037CB01E4CA51F00609409 /* GeneralSettingsTableViewController.swift in Sources */, DC8963BE1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift in Sources */, diff --git a/pass/Controllers/AddPasswordTableViewController.swift b/pass/Controllers/AddPasswordTableViewController.swift index 70761bb..6cb7df3 100644 --- a/pass/Controllers/AddPasswordTableViewController.swift +++ b/pass/Controllers/AddPasswordTableViewController.swift @@ -16,6 +16,8 @@ class AddPasswordTableViewController: UITableViewController { super.viewDidLoad() tableView.register(UINib(nibName: "TextFieldTableViewCell", bundle: nil), forCellReuseIdentifier: "textFieldCell") tableView.register(UINib(nibName: "TextViewTableViewCell", bundle: nil), forCellReuseIdentifier: "textViewCell") + tableView.register(UINib(nibName: "FillPasswordTableViewCell", bundle: nil), forCellReuseIdentifier: "fillPasswordCell") + tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 48 @@ -31,11 +33,15 @@ class AddPasswordTableViewController: UITableViewController { } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if tableTitles[indexPath.section] == "additions" { + switch tableTitles[indexPath.section] { + case "additions": let cell = tableView.dequeueReusableCell(withIdentifier: "textViewCell", for: indexPath) as! TextViewTableViewCell cell.contentTextView.text = "" return cell - } else { + case "password": + let cell = tableView.dequeueReusableCell(withIdentifier: "fillPasswordCell", for: indexPath) as! FillPasswordTableViewCell + return cell + default: let cell = tableView.dequeueReusableCell(withIdentifier: "textFieldCell", for: indexPath) as! TextFieldTableViewCell cell.contentTextField.placeholder = tableTitles[indexPath.section] return cell @@ -52,7 +58,7 @@ class AddPasswordTableViewController: UITableViewController { override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "saveAddPasswordSegue" { let nameCell = getCellForName(name: "name")! as! TextFieldTableViewCell - let passwordCell = getCellForName(name: "password")! as! TextFieldTableViewCell + let passwordCell = getCellForName(name: "password")! as! FillPasswordTableViewCell let additionsCell = getCellForName(name: "additions")! as! TextViewTableViewCell password = Password(name: nameCell.contentTextField.text!, plainText: "\(passwordCell.contentTextField.text!)\n\(additionsCell.contentTextView.text!)") } diff --git a/pass/Views/FillPasswordTableViewCell.swift b/pass/Views/FillPasswordTableViewCell.swift new file mode 100644 index 0000000..99a5544 --- /dev/null +++ b/pass/Views/FillPasswordTableViewCell.swift @@ -0,0 +1,28 @@ +// +// FillPasswordTableViewCell.swift +// pass +// +// Created by Mingshen Sun on 11/2/2017. +// Copyright © 2017 Bob Sun. All rights reserved. +// + +import UIKit + +class FillPasswordTableViewCell: UITableViewCell { + + @IBOutlet weak var contentTextField: UITextField! + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + + @IBAction func generatePassword(_ sender: UIButton) { + contentTextField.text = "4-r4d0m-p455w0rd" + } +} diff --git a/pass/Views/FillPasswordTableViewCell.xib b/pass/Views/FillPasswordTableViewCell.xib new file mode 100644 index 0000000..37d8523 --- /dev/null +++ b/pass/Views/FillPasswordTableViewCell.xib @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +