From dd3c8b9164a18e1344dad351546886bc63c6d064 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Fri, 26 May 2017 00:37:00 +0800 Subject: [PATCH 01/18] Hide the password generation setting on Apple Keychain style (close #84) --- .../AddPasswordTableViewController.swift | 7 +- .../EditPasswordTableViewController.swift | 8 +- .../PasswordEditorTableViewController.swift | 3 + pass/Views/FillPasswordTableViewCell.xib | 93 +++++++++---------- pass/Views/LabelTableViewCell.xib | 6 +- 5 files changed, 63 insertions(+), 54 deletions(-) diff --git a/pass/Controllers/AddPasswordTableViewController.swift b/pass/Controllers/AddPasswordTableViewController.swift index e56c1af..1569380 100644 --- a/pass/Controllers/AddPasswordTableViewController.swift +++ b/pass/Controllers/AddPasswordTableViewController.swift @@ -16,11 +16,14 @@ class AddPasswordTableViewController: PasswordEditorTableViewController { override func viewDidLoad() { tableData = [ [[.type: PasswordEditorCellType.nameCell, .title: "name"]], - [[.type: PasswordEditorCellType.fillPasswordCell, .title: "password"], - [.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"]], + [[.type: PasswordEditorCellType.fillPasswordCell, .title: "password"]], [[.type: PasswordEditorCellType.additionsCell, .title: "additions"]], [[.type: PasswordEditorCellType.scanQRCodeCell]] ] + if let lengthSetting = Globals.passwordDefaultLength[Defaults[.passwordGeneratorFlavor]], + lengthSetting.max > lengthSetting.min { + tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"]) + } super.viewDidLoad() } diff --git a/pass/Controllers/EditPasswordTableViewController.swift b/pass/Controllers/EditPasswordTableViewController.swift index 6e69839..6deaae7 100644 --- a/pass/Controllers/EditPasswordTableViewController.swift +++ b/pass/Controllers/EditPasswordTableViewController.swift @@ -7,17 +7,21 @@ // import UIKit +import SwiftyUserDefaults class EditPasswordTableViewController: PasswordEditorTableViewController { override func viewDidLoad() { tableData = [ [[.type: PasswordEditorCellType.nameCell, .title: "name", .content: password!.namePath]], - [[.type: PasswordEditorCellType.fillPasswordCell, .title: "password", .content: password!.password], - [.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"]], + [[.type: PasswordEditorCellType.fillPasswordCell, .title: "password", .content: password!.password]], [[.type: PasswordEditorCellType.additionsCell, .title: "additions", .content: password!.getAdditionsPlainText()]], [[.type: PasswordEditorCellType.scanQRCodeCell], [.type: PasswordEditorCellType.deletePasswordCell]] ] + if let lengthSetting = Globals.passwordDefaultLength[Defaults[.passwordGeneratorFlavor]], + lengthSetting.max > lengthSetting.min { + tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"]) + } super.viewDidLoad() } diff --git a/pass/Controllers/PasswordEditorTableViewController.swift b/pass/Controllers/PasswordEditorTableViewController.swift index 3441490..cd17f38 100644 --- a/pass/Controllers/PasswordEditorTableViewController.swift +++ b/pass/Controllers/PasswordEditorTableViewController.swift @@ -89,6 +89,9 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl fillPasswordCell = tableView.dequeueReusableCell(withIdentifier: "fillPasswordCell", for: indexPath) as? FillPasswordTableViewCell fillPasswordCell?.delegate = self fillPasswordCell?.setContent(content: cellData[PasswordEditorCellKey.content] as? String) + if tableData[passwordSection].count == 1 { + fillPasswordCell?.settingButton.isHidden = true + } return fillPasswordCell! case .passwordLengthCell: passwordLengthCell = tableView.dequeueReusableCell(withIdentifier: "passwordLengthCell", for: indexPath) as? SliderTableViewCell diff --git a/pass/Views/FillPasswordTableViewCell.xib b/pass/Views/FillPasswordTableViewCell.xib index e78839d..715a3d3 100644 --- a/pass/Views/FillPasswordTableViewCell.xib +++ b/pass/Views/FillPasswordTableViewCell.xib @@ -1,11 +1,11 @@ - + - + @@ -16,55 +16,54 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + diff --git a/pass/Views/LabelTableViewCell.xib b/pass/Views/LabelTableViewCell.xib index 04d3234..cd316bb 100644 --- a/pass/Views/LabelTableViewCell.xib +++ b/pass/Views/LabelTableViewCell.xib @@ -1,11 +1,11 @@ - + - + @@ -16,7 +16,7 @@ - +