Introduce enum for password generator flavour
This commit is contained in:
parent
1f57305203
commit
3cd8df310c
10 changed files with 102 additions and 47 deletions
|
|
@ -33,7 +33,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
self.perform(#selector(postSearchNotification), with: nil, afterDelay: 0.4)
|
||||
}
|
||||
}
|
||||
Utils.initDefaultKeys()
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
|
|||
[[.type: PasswordEditorCellType.additionsCell, .title: "additions"]],
|
||||
[[.type: PasswordEditorCellType.scanQRCodeCell]]
|
||||
]
|
||||
if let lengthSetting = Globals.passwordDefaultLength[SharedDefaults[.passwordGeneratorFlavor]],
|
||||
lengthSetting.max > lengthSetting.min {
|
||||
if PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]) == PasswordGeneratorFlavour.RANDOM {
|
||||
tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"])
|
||||
}
|
||||
tableData[1].append([.type: PasswordEditorCellType.memorablePasswordGeneratorCell])
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ class EditPasswordTableViewController: PasswordEditorTableViewController {
|
|||
[[.type: PasswordEditorCellType.scanQRCodeCell],
|
||||
[.type: PasswordEditorCellType.deletePasswordCell]]
|
||||
]
|
||||
if let lengthSetting = Globals.passwordDefaultLength[SharedDefaults[.passwordGeneratorFlavor]],
|
||||
lengthSetting.max > lengthSetting.min {
|
||||
if PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]) == PasswordGeneratorFlavour.RANDOM {
|
||||
tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"])
|
||||
}
|
||||
tableData[1].append([.type: PasswordEditorCellType.memorablePasswordGeneratorCell])
|
||||
|
|
|
|||
|
|
@ -104,11 +104,10 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
|||
return fillPasswordCell!
|
||||
case .passwordLengthCell:
|
||||
passwordLengthCell = tableView.dequeueReusableCell(withIdentifier: "passwordLengthCell", for: indexPath) as? SliderTableViewCell
|
||||
let lengthSetting = Globals.passwordDefaultLength[SharedDefaults[.passwordGeneratorFlavor]] ??
|
||||
Globals.passwordDefaultLength["Random"]
|
||||
let minimumLength = lengthSetting?.min ?? 0
|
||||
let maximumLength = lengthSetting?.max ?? 0
|
||||
var defaultLength = lengthSetting?.def ?? 0
|
||||
let lengthSetting = PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]).defaultLength
|
||||
let minimumLength = lengthSetting.min
|
||||
let maximumLength = lengthSetting.max
|
||||
var defaultLength = lengthSetting.def
|
||||
if let currentPasswordLength = (tableData[passwordSection][0][PasswordEditorCellKey.content] as? String)?.count,
|
||||
currentPasswordLength >= minimumLength,
|
||||
currentPasswordLength <= maximumLength {
|
||||
|
|
@ -203,7 +202,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
|||
showPasswordSettings()
|
||||
|
||||
let length = passwordLengthCell?.roundedValue ?? 0
|
||||
let plainPassword = Password.generatePassword(length: length)
|
||||
let plainPassword = PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]).generatePassword(length: length)
|
||||
SecurePasteboard.shared.copy(textToCopy: plainPassword)
|
||||
|
||||
// update tableData so to make sure reloadData() works correctly
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue