Improve the password length slider

- the slider appears after clicking "generate"
- the slider goes away after clicking a non-password-related section
- generate new password if the slider value changes
This commit is contained in:
Yishi Lin 2017-03-23 01:28:46 +08:00
parent e4e20b1d6f
commit 5a02cb726e
6 changed files with 75 additions and 25 deletions

View file

@ -9,7 +9,7 @@
import UIKit
protocol FillPasswordTableViewCellDelegate {
func generatePassword() -> String
func generateAndCopyPassword()
}
class FillPasswordTableViewCell: ContentTableViewCell {
@ -30,9 +30,7 @@ class FillPasswordTableViewCell: ContentTableViewCell {
}
@IBAction func generatePassword(_ sender: UIButton) {
let plainPassword = self.delegate?.generatePassword() ?? Utils.generatePassword(length: 16)
self.setContent(content: plainPassword)
Utils.copyToPasteboard(textToCopy: plainPassword)
self.delegate?.generateAndCopyPassword()
}
override func getContent() -> String? {