Password with "Apple" flavor has a fixed length
This commit is contained in:
parent
fe4ea4e79c
commit
c93a63d8cc
3 changed files with 18 additions and 5 deletions
|
|
@ -7,6 +7,8 @@
|
|||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftyUserDefaults
|
||||
|
||||
enum PasswordEditorCellType {
|
||||
case textFieldCell, textViewCell, fillPasswordCell, passwordLengthCell, deletePasswordCell
|
||||
}
|
||||
|
|
@ -76,7 +78,12 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
|||
return fillPasswordCell!
|
||||
case .passwordLengthCell:
|
||||
passwordLengthCell = tableView.dequeueReusableCell(withIdentifier: "passwordLengthCell", for: indexPath) as? SliderTableViewCell
|
||||
passwordLengthCell?.reset(title: "Length", minimumValue: Globals.passwordMinimumLength, maximumValue: Globals.passwordMaximumLength, defaultValue: Globals.passwordDefaultLength)
|
||||
let lengthSetting = Globals.passwordDefaultLength[Defaults[.passwordGeneratorFlavor]] ??
|
||||
Globals.passwordDefaultLength["Random"]
|
||||
passwordLengthCell?.reset(title: "Length",
|
||||
minimumValue: lengthSetting?.min ?? 0,
|
||||
maximumValue: lengthSetting?.max ?? 0,
|
||||
defaultValue: lengthSetting?.def ?? 0)
|
||||
passwordLengthCell?.delegate = self
|
||||
return passwordLengthCell!
|
||||
case .deletePasswordCell:
|
||||
|
|
@ -148,7 +155,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
|||
hidePasswordSettings = false
|
||||
tableView.reloadSections([passwordSection], with: .fade)
|
||||
}
|
||||
let length = passwordLengthCell?.roundedValue ?? Globals.passwordDefaultLength
|
||||
let length = passwordLengthCell?.roundedValue ?? 0
|
||||
let plainPassword = Utils.generatePassword(length: length)
|
||||
Utils.copyToPasteboard(textToCopy: plainPassword)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,8 @@ class Globals {
|
|||
static let red = UIColor(red:1.00, green:0.23, blue:0.19, alpha:1.0)
|
||||
static let blue = UIColor(red:0.00, green:0.48, blue:1.00, alpha:1.0)
|
||||
|
||||
static let passwordMinimumLength = 6
|
||||
static let passwordMaximumLength = 24
|
||||
static let passwordDefaultLength = 16
|
||||
static let passwordDefaultLength = ["Random": (min: 6, max: 24, def: 16),
|
||||
"Apple": (min: 15, max: 15, def: 15)]
|
||||
|
||||
static let passwordDots = "••••••••••••"
|
||||
static let passwordFonts = "Menlo"
|
||||
|
|
|
|||
|
|
@ -58,6 +58,13 @@ class SliderTableViewCell: ContentTableViewCell {
|
|||
slider.maximumValue = Float(maximumValue)
|
||||
slider.value = Float(defaultValue)
|
||||
valueLabel.text = String(defaultValue)
|
||||
|
||||
// "not editable"
|
||||
if minimumValue == maximumValue {
|
||||
titleLabel.textColor = UIColor.gray
|
||||
valueLabel.textColor = UIColor.gray
|
||||
slider.isUserInteractionEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue