From ca66cd8e6c4a0d63bc9a2215ab42c33ddc2646b6 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Fri, 24 Mar 2017 01:34:45 +0800 Subject: [PATCH] Fix the color the passwords - in the password editing view - color of some characters --- pass/Helpers/Utils.swift | 2 +- pass/Views/FillPasswordTableViewCell.swift | 5 +++++ pass/Views/FillPasswordTableViewCell.xib | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pass/Helpers/Utils.swift b/pass/Helpers/Utils.swift index 726e107..462c83c 100644 --- a/pass/Helpers/Utils.swift +++ b/pass/Helpers/Utils.swift @@ -133,7 +133,7 @@ class Utils { for (index, element) in plainPassword.unicodeScalars.enumerated() { if NSCharacterSet.decimalDigits.contains(element) { attributedPassword.addAttribute(NSForegroundColorAttributeName, value: Globals.red, range: NSRange(location: index, length: 1)) - } else if NSCharacterSet.punctuationCharacters.contains(element) { + } else if !NSCharacterSet.letters.contains(element) { attributedPassword.addAttribute(NSForegroundColorAttributeName, value: Globals.blue, range: NSRange(location: index, length: 1)) } } diff --git a/pass/Views/FillPasswordTableViewCell.swift b/pass/Views/FillPasswordTableViewCell.swift index b7a9ae0..e97edde 100644 --- a/pass/Views/FillPasswordTableViewCell.swift +++ b/pass/Views/FillPasswordTableViewCell.swift @@ -33,6 +33,11 @@ class FillPasswordTableViewCell: ContentTableViewCell { self.delegate?.generateAndCopyPassword() } + // re-color + @IBAction func textFieldDidChange(_ sender: UITextField) { + contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "") + } + override func getContent() -> String? { return contentTextField.attributedText?.string } diff --git a/pass/Views/FillPasswordTableViewCell.xib b/pass/Views/FillPasswordTableViewCell.xib index 0f6d8b2..c27362f 100644 --- a/pass/Views/FillPasswordTableViewCell.xib +++ b/pass/Views/FillPasswordTableViewCell.xib @@ -27,6 +27,9 @@ + + +