From af68f159475b87ba2caaa3e87fbbe1f47328c067 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Wed, 8 Feb 2017 19:18:10 +0800 Subject: [PATCH] improve UI --- pass/PasswordsViewController.swift | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pass/PasswordsViewController.swift b/pass/PasswordsViewController.swift index 56b442d..5387765 100644 --- a/pass/PasswordsViewController.swift +++ b/pass/PasswordsViewController.swift @@ -147,17 +147,24 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } else { password = passwordEntities![index] } - do { - let generator = UIImpactFeedbackGenerator(style: .medium) - let decryptedPassword = try password.decrypt()! - UIPasteboard.general.string = decryptedPassword.password - generator.impactOccurred() - SVProgressHUD.setDefaultMaskType(.clear) - SVProgressHUD.setDefaultStyle(.dark) - SVProgressHUD.showInfo(withStatus: "Password Copied") - SVProgressHUD.dismiss(withDelay: 0.6) - } catch { - print(error) + UIImpactFeedbackGenerator(style: .medium).impactOccurred() + SVProgressHUD.setDefaultMaskType(.clear) + SVProgressHUD.setDefaultStyle(.dark) + SVProgressHUD.show(withStatus: "Decrypting") + DispatchQueue.global(qos: .userInteractive).async { + var decryptedPassword: Password? + do { + decryptedPassword = try password.decrypt()! + } catch { + print(error) + SVProgressHUD.showError(withStatus: error.localizedDescription) + SVProgressHUD.dismiss(withDelay: 1) + } + DispatchQueue.main.async { + UIPasteboard.general.string = decryptedPassword?.password + SVProgressHUD.showSuccess(withStatus: "Password Copied") + SVProgressHUD.dismiss(withDelay: 0.6) + } } }